cgroup/control group config problem

Gary Artim gartim at gmail.com
Tue Sep 24 18:52:21 UTC 2013


i did the following to setup a cgroup, but when I test "it" doesn't
kill the pid, anyone get this working? must be missing
something...program mallocs 32GB...much thanks for advise!

::install::

yum install libcgroup-tools libcgroup

::config::

cd /sys/fs/cgroup/memory
mkdir alpha
echo 4096000000 > alpha/memory.limit_in_bytes
cat alpha/memory.limit_in_bytes
change /etc/cgrules.conf add line:
@users       memory    alpha/
start: cgrulesengd

::test::

check if pid is in alpha/tasks:
cat /sys/fs/cgroup/memory/alpa/tasks
run:
cat > memlimit.c <<"END"
#include <stdlib.h>
#include <stdio.h>
#define  ONEGB  1073741824
int main(void) {
    int i;
    for (i=0; i < 32; i++) {
        char *q = malloc(ONEGB);
        printf ("Malloced: %d / GB\n", (i+1));
    }
    sleep(9999999);
}
END
gcc memlimit.c && ./a.out


More information about the users mailing list