From dcb708a93e68ef4395fe9af88275bafc91aa3fa1 Mon Sep 17 00:00:00 2001 From: Dhaval Giani Date: Tue, 16 Dec 2008 17:14:33 +0000 Subject: libcgroup: Add default group to cgconfig From: Balbir Singh As discussed in the previous thread http://article.gmane.org/gmane.comp.lib.libcg.devel/139, we don't have the concept of default groups and tasks should be able to return back to their default group when done. Here is a fix to the cgconfig script to fix the issue. Please review, comment on it. Signed-off-by: Balbir Singh Signed-off-by: Dhaval Giani git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@236 4f4bb910-9a46-0410-90c8-c897d4f1cd53 --- scripts/init.d/cgconfig | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'scripts/init.d/cgconfig') diff --git a/scripts/init.d/cgconfig b/scripts/init.d/cgconfig index 4e04fb9..58dee65 100644 --- a/scripts/init.d/cgconfig +++ b/scripts/init.d/cgconfig @@ -82,6 +82,56 @@ start() { #log_progress_msg "Starting cgconfig service: " cgconfigparser -l $CONFIG_FILE fi + + declare defaultcgroup + + if [ -f /etc/cgrules.conf ] + then + read user ctrl defaultcgroup <<< \ + `grep -m1 ^\* /etc/cgrules.conf` + if [[ -n $defaultcgroup && $defaultcgroup = "*" ]] + then + log_warning_msg "/etc/cgrules.conf incorrect" + log_warning_msg "Overriding it" + defaultcgroup= + fi + fi + + if [ -z $defaultcgroup ] + then + defaultcgroup=sysdefault/ + fi + # + # Create a default class for tasks to return back to + # + parse_mounts + for i in `seq 1 $maxindex` + do + # + # Ignore if directory already exists + # + mkdir ${MOUNTPOINT[$i]}/$defaultcgroup 2> /dev/null + chmod a+rw ${MOUNTPOINT[$i]}/$defaultcgroup/tasks + # + # special rule for cpusets + # + echo ${MOUNTOPTS[$i]} | grep -q -w cpuset + if [ $? -eq 0 ] + then + cat ${MOUNTPOINT[$i]}/cpuset.cpus > \ + ${MOUNTPOINT[$i]}/$defaultcgroup/cpuset.cpus + cat ${MOUNTPOINT[$i]}/cpuset.mems > \ + ${MOUNTPOINT[$i]}/$defaultcgroup/cpuset.mems + fi + # + # classify everything to default cgroup + # + for j in `ps --no-headers -eL o tid` + do + echo $j > ${MOUNTPOINT[$i]}/$defaultcgroup/tasks 2>/dev/null + done + done + [ $? == 0 ] && touch /var/lock/subsys/$servicename return $? } -- cgit