runscript.sh creates only the toplevel dir for openrc. Is it possible to add the dirs for the rest of mounted cgroups? I had hacked the script with: diff -ur openrc-0.10.5/sh/runscript.sh.in openrc-0.10.5.af/sh/runscript.sh.in --- openrc-0.10.5/sh/runscript.sh.in 2012-07-04 16:23:49.000000000 +0200 +++ openrc-0.10.5.af/sh/runscript.sh.in 2012-09-27 13:00:59.842622715 +0200 @@ -197,6 +197,16 @@ if [ -d /sys/fs/cgroup/openrc ]; then mkdir -p /sys/fs/cgroup/openrc/${RC_SVCNAME} echo $$ > /sys/fs/cgroup/openrc/${RC_SVCNAME}/tasks + if [ ! -d /sys/fs/cgroup/cpu/openrc ]; then + mkdir /sys/fs/cgroup/cpu/openrc + fi + mkdir -p /sys/fs/cgroup/cpu/openrc/${RC_SVCNAME} + echo $$ > /sys/fs/cgroup/cpu/openrc/${RC_SVCNAME}/tasks + if [ ! -d /sys/fs/cgroup/blkio/openrc ]; then + mkdir /sys/fs/cgroup/blkio/openrc + fi + mkdir -p /sys/fs/cgroup/blkio/openrc/${RC_SVCNAME} + echo $$ > /sys/fs/cgroup/blkio/openrc/${RC_SVCNAME}/tasks fi #todo: add processes to cgroups based on settings in conf.d fi but this is not the general solution. Some services (like batch system daemons) need custom cgroup settings.
Currently there are some patches that add additional cgroup support that are reviewed now. (Adding groups to unnamed hierarchy, adding resource limits, an optional ability to kill all cgroup tasks on service stop) Current solution is not provide openrc subgroup in unnamed hierarchy but to create a top level group for each service, e.g. /sys/fs/cgroup/cpu/openrc_${RC_SVCNAME}. This is done because openrc does not provide any PID-1 like service that managed it's children.
the /sys/fs/cgroup/{blkio,cpu}/openrc check doesn't make sense considering you do `mkdir -p` on that path + a subdir right after however, updating those subdirs (cpu/blkio) would only make sense if something was mounted there wouldn't it ? and shouldn't it be "cpuset" rather than "cpu" ?
(In reply to comment #2) > Currently there are some patches that add additional cgroup support that are > reviewed now. (Adding groups to unnamed hierarchy, adding resource limits, > an optional ability to kill all cgroup tasks on service stop) > > Current solution is not provide openrc subgroup in unnamed hierarchy but > to create a top level group for each service, e.g. > /sys/fs/cgroup/cpu/openrc_${RC_SVCNAME}. > > This is done because openrc does not provide any PID-1 like service that > managed it's children. ok. will wait for proper solution.
(In reply to comment #3) > the /sys/fs/cgroup/{blkio,cpu}/openrc check doesn't make sense considering > you do `mkdir -p` on that path + a subdir right after well, a ditry hack. could be done better. > > however, updating those subdirs (cpu/blkio) would only make sense if > something was mounted there wouldn't it ? and shouldn't it be "cpuset" > rather than "cpu" ? sure. there are several cgroups to be treated, in my case "blkio cpu cpuacct cpuset devices freezer hugetlb memory net_cl perf_event" but I need only cpu and blkio for now. The patch was attached only to make clear what I meant.
(In reply to comment #5) might be better then to have the logic be something like: for d in /sys/fs/cgroup/*/ ; do mountpoint -q $d || continue mkdir -p $d/openrc/${RC_SVCNAME} echo $$ > $d/..... done
This has been added to the main tree. The best way appears to be to have one configuration variable per controller and allow the user to specify settings and values they want to change. This is done in commit fac96b4 and will be in openrc-0.12. A special thanks goes to Alexander Vershilov for working with me and helping with testing this.