aboutsummaryrefslogtreecommitdiff
path: root/sh
diff options
context:
space:
mode:
authorWilliam Hubbs <williamh@gentoo.org>2011-11-18 15:54:18 -0600
committerWilliam Hubbs <williamh@gentoo.org>2011-11-18 17:58:37 -0600
commit0510c473d4cd9097401e3a7bc236b0121977b81d (patch)
tree3f22567009d901eb34a13a6a48d0985b2f73b278 /sh
parent9a3d6c76009a58746d42d54c284058725131a854 (diff)
CGroups: /sys/fs/cgroups should be a tmpfs
The kernel documentation states that a cgroup file system should not be mounted here, but a tmpfs. This also means that we should not create a group for each process, but we should allow the user to specify which group a process should be assigned to. The rc_cgroup variable will be used for this purpose. For more information, see /usr/src/linux/Documentation/cgroups/cgroups.txt.
Diffstat (limited to 'sh')
-rw-r--r--sh/runscript.sh.in29
1 files changed, 7 insertions, 22 deletions
diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in
index c7d712be..706a1f7d 100644
--- a/sh/runscript.sh.in
+++ b/sh/runscript.sh.in
@@ -190,18 +190,13 @@ fi
sourcex -e "@SYSCONFDIR@/rc.conf"
# Attach to CGroup - dir existing is enough for us
-if [ -d /sys/fs/cgroup/ ]; then
- # use RC_SVCNAME unless overridden in conf.d
- SVC_CGROUP=${rc_cgroup:-$RC_SVCNAME}
- mkdir -p /sys/fs/cgroup/${SVC_CGROUP}
- for f in cpuset.cpus cpuset.mems; do
- if [ -f /sys/fs/cgroup/${f} ]; then
- cp /sys/fs/cgroup/${f} /sys/fs/cgroup/${SVC_CGROUP}
- fi
- done
- # now attach self to cgroup - any children of this process will inherit this
- echo $$ > /sys/fs/cgroup/${SVC_CGROUP}/tasks
- # TODO: set res limits from conf.d
+if [ -d /sys/fs/cgroup -a -n "${rc_cgroup}" ]; then
+ if [ -d /sys/fs/cgroup/${rc_cgroup} ]; then
+ # attach self to cgroup - any children of this process will inherit this
+ echo $$ > /sys/fs/cgroup/${rc_cgroup}/tasks
+ else
+ eerror "Control group /sys/fs/cgroup/${rc_cgroup} does not exist."
+ fi
fi
# Apply any ulimit defined
@@ -307,14 +302,4 @@ while [ -n "$1" ]; do
exit 1
done
-# CGroup cleanup
-if [ -d /sys/fs/cgroup/ ]; then
- # use RC_SVCNAME unless overridden in conf.d
- SVC_CGROUP=${rc_cgroup:-$RC_SVCNAME}
- # reattach to root cgroup
- echo $$ > /sys/fs/cgroup/tasks
- # remove cgroup if empty, will fail if any task attached
- rmdir /sys/fs/cgroup/${SVC_CGROUP} 2>/dev/null
-fi
-
exit 0