Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 444654 - adding cgroups to openrc, creating dirs in all cgroup mountpoints
Summary: adding cgroups to openrc, creating dirs in all cgroup mountpoints
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: OpenRC (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: OpenRC Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 439098
  Show dependency tree
 
Reported: 2012-11-25 07:28 UTC by Andrej Filipcic
Modified: 2013-02-19 23:35 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrej Filipcic 2012-11-25 07:28:44 UTC

    
Comment 1 Andrej Filipcic 2012-11-25 07:34:07 UTC
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.
Comment 2 Alexander Vershilov (RETIRED) gentoo-dev 2012-11-25 08:33:09 UTC
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.
Comment 3 SpanKY gentoo-dev 2012-11-26 06:29:56 UTC
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" ?
Comment 4 Andrej Filipcic 2012-11-26 07:19:22 UTC
(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.
Comment 5 Andrej Filipcic 2012-11-26 07:24:38 UTC
(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.
Comment 6 SpanKY gentoo-dev 2012-11-26 07:44:51 UTC
(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
Comment 7 William Hubbs gentoo-dev 2013-02-19 23:35:18 UTC
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.