diff options
author | William Hubbs <williamh@gentoo.org> | 2011-12-18 13:33:27 -0600 |
---|---|---|
committer | William Hubbs <williamh@gentoo.org> | 2011-12-18 13:33:27 -0600 |
commit | 461c69acdbf89b029554312392279753127112ee (patch) | |
tree | ae5d2a045f2eaf9b747f13d222b723299e4d154e | |
parent | 879e1acd5dc04eee1f7b0cb49d9c1a84e28c525c (diff) |
cgroups: mount cgroups suggested by the kernel documentation
The linux kernel documentation suggests mounting a separate cgroup
hierarchy for each subsystem you want to control/monitor. This changes
the cgroups mounting code to do this.
-rw-r--r-- | init.d/sysfs.in | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/init.d/sysfs.in b/init.d/sysfs.in index d57c3883..cb44b300 100644 --- a/init.d/sysfs.in +++ b/init.d/sysfs.in @@ -60,27 +60,36 @@ mount_misc() eend $? fi fi +} - # Setup Kernel Support for cgroup - if [ -d /sys/fs/cgroup ]; then - if grep -qs cgroup /proc/filesystems && \ - ! mountinfo -q /sys/fs/cgroup; then +mount_cgroups() +{ + if [ ! -e /proc/cgroups ]; then + return 0 + fi + + if [ -d /sys/fs/cgroup ] && ! mountinfo -q /sys/fs/cgroup; then + if grep -qs cgroup /proc/filesystems; then ebegin "Mounting cgroup filesystem" - mount -n -t tmpfs -o nodev,noexec,nosuid \ - cgroup /sys/fs/cgroup + mount -n -t tmpfs -o nodev,noexec,nosuid,mode=755 \ + cgroup_root /sys/fs/cgroup eend $? fi - if ! mountinfo -q /sys/fs/cgroup/openrc; then - ebegin "creating openrc control group" - mkdir /sys/fs/cgroup/openrc - mount -n -t cgroup -o nodev,noexec,nosuid \ - openrc /sys/fs/cgroup/openrc - echo 1 > /sys/fs/cgroup/openrc/notify_on_release - echo @LIBEXECDIR@/sh/cgroup-release-agent.sh \ - > /sys/fs/cgroup/openrc/release_agent - eend - fi fi + + while read name hier groups enabled rest; do + case "${enabled}" in + 1) mkdir /sys/fs/cgroup/${name} + mount -t cgroup -o nodev,noexec,nosuid,${name} \ + ${name} /sys/fs/cgroup/${name} + ;; + esac + done < /proc/cgroups + + # mkdir /sys/fs/cgroup/openrc + # mount -t cgroup \ + # -o nodev,noexec,nosuid,name=openrc \ + # openrc /sys/fs/cgroup/openrc } start() @@ -90,6 +99,11 @@ start() retval=$? if [ $retval -eq 0 ]; then mount_misc + retval=$? + fi + if [ $retval -eq 0 ]; then + mount_cgroups + retval=$? fi return $retval } |