1

cgrulesengd can't move pid to task file while running as deamon, if I restart cgrulesengd all pids are moved correctly to task file, but new pid's not.

So, if i log in as hello user, and then run from root cgrulesengd -n -d, user hello and all his processes are moved to /cgrup/mem/hello/tasks file. But when i log out and login, user hello isn't affected anymore by cgrulesengd.

This is my test file.

#!/bin/bash
USER='hello'
cgdelete memory:${USER}/

cgclear
/etc/rc.d/rc.cgred stop

umount /cgroup/mem
rm -fr /cgroup/mem/

mkdir /cgroup/mem
mount -t cgroup -o memory mem /cgroup/mem

mkdir /cgroup/mem/${USER}

chown root:root   /cgroup/mem/${USER}/*
chown ${USER}:root /cgroup/mem/${USER}/tasks

echo 100M > /cgroup/mem/${USER}/memory.limit_in_bytes
echo 100M > /cgroup/mem/${USER}/memory.memsw.limit_in_bytes

[ ! -f '/etc/cgrules.conf_orig' ] && cp -pa /etc/cgrules.conf /etc/cgrules.conf_orig
echo "${USER} memory ${USER}/" > /etc/cgrules.conf
#echo "*       *       system/" >> /etc/cgrules.conf

/etc/rc.d/rc.cgred start
#cgrulesengd -n -d

ls -all /cgroup/mem/${USER}/tasks
cat /cgroup/mem/${USER}/tasks

echo -n "memory.limit_in_bytes  "
cat /cgroup/mem/${USER}/memory.limit_in_bytes
echo -n "memory.max_usage_in_byte  "
cat /cgroup/mem/${USER}/memory.max_usage_in_bytes

echo -n "memory.memsw.limit_in_bytes  "
cat /cgroup/mem/${USER}/memory.memsw.limit_in_bytes
echo -n "memory.memsw.max_usage_in_bytes  "
cat /cgroup/mem/${USER}/memory.memsw.max_usage_in_bytes

Output:

./test_cgred.sh 
Stopping CGroup Rules Engine Daemon...                     [  OK  ]
umount: /cgroup/mem: not mounted
Starting CGroup Rules Engine Daemon:                       [  OK  ]
-rw-r--r-- 1 hello root 0 Sep 26 00:46 /cgroup/mem/hello/tasks
memory.limit_in_bytes  104857600
memory.max_usage_in_byte  0
memory.memsw.limit_in_bytes  104857600
memory.memsw.max_usage_in_bytes  0

I just found that when memory.max_usage_in_byte and memory.memsw.max_usage_in_bytes is != 0 all new pids are moved correctly.

My question are:

  1. Why i get 0 in memory.max_usage_in_byte and memory.memsw.max_usage_in_bytes?
  2. Why new pid isn't automatically attached to task file?

Version: libcgroup-0.41-x86_64-1

Temporary solution: added echo $$ >> /cgroup/mem/$USER/tasks to /etc/profile.

0

You must log in to answer this question.

Browse other questions tagged .