From 461c69acdbf89b029554312392279753127112ee Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Sun, 18 Dec 2011 13:33:27 -0600 Subject: 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. --- init.d/sysfs.in | 46 ++++++++++++++++++++++++++++++---------------- 1 file 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 } -- cgit v1.2.3