From 0535f0550f37a4213496eb4309e6909e2817f5a3 Mon Sep 17 00:00:00 2001 From: Piotr Karbowski Date: Sat, 17 Dec 2011 17:45:11 +0100 Subject: [PATCH] Make openrc's cgroup-per-initscript optional and default set to NO. Enforcing openrc-managed cgroups on users isn't good idea nor is suggesting use of libcgroup. Kernel's SCHED_AUTOGROUP handle cgroups per session just fine. For example current openrc's implementation will put all ssh users in one group, unlike sched_autogrup. --- etc/rc.conf.Linux | 3 +++ init.d/sysfs.in | 2 +- sh/runscript.sh.in | 22 ++++++++++++---------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/etc/rc.conf.Linux b/etc/rc.conf.Linux index 9b5859a..350205a 100644 --- a/etc/rc.conf.Linux +++ b/etc/rc.conf.Linux @@ -22,3 +22,6 @@ rc_sys="@RC_SYS_DEFAULT@" # consolefont, numlock, etc ...) rc_tty_number=12 +# Openrc will create a cgroup hierarchy called openrc which will have all +# services it starts and all subsystems attached to it. Default NO. +#rc_cgroups="YES" diff --git a/init.d/sysfs.in b/init.d/sysfs.in index d57c388..cae2e66 100644 --- a/init.d/sysfs.in +++ b/init.d/sysfs.in @@ -70,7 +70,7 @@ mount_misc() cgroup /sys/fs/cgroup eend $? fi - if ! mountinfo -q /sys/fs/cgroup/openrc; then + if yesno ${rc_cgroups:-NO} && ! 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 \ diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in index 07f96d8..c619301 100644 --- a/sh/runscript.sh.in +++ b/sh/runscript.sh.in @@ -132,16 +132,18 @@ start() mark_service_inactive fi if [ "$RC_UNAME" = Linux ]; then - local cgroup=/sys/fs/cgroup/openrc - local svc_cgroup=${cgroup}/${RC_SVCNAME} - if mountinfo -q ${cgroup}; then - mkdir ${svc_cgroup} - for f in cpuset.cpus cpuset.mems; do - if [ -f ${cgroup}/${f} ]; then - cp ${cgroup}/${f} ${svc_cgroup} - fi - done - echo $$ > ${svc_cgroup}/tasks + if yesno "${rc_cgroups:-NO}"; then + local cgroup=/sys/fs/cgroup/openrc + local svc_cgroup=${cgroup}/${RC_SVCNAME} + if mountinfo -q ${cgroup}; then + mkdir ${svc_cgroup} + for f in cpuset.cpus cpuset.mems; do + if [ -f ${cgroup}/${f} ]; then + cp ${cgroup}/${f} ${svc_cgroup} + fi + done + echo $$ > ${svc_cgroup}/tasks + fi fi fi eval start-stop-daemon --start \ -- 1.7.8