Gentoo Archives: gentoo-commits

From: William Hubbs <williamh@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/openrc:master commit in: init.d/, sh/
Date: Sat, 19 Nov 2011 00:06:01
Message-Id: 0510c473d4cd9097401e3a7bc236b0121977b81d.WilliamH@gentoo
1 commit: 0510c473d4cd9097401e3a7bc236b0121977b81d
2 Author: William Hubbs <williamh <AT> gentoo <DOT> org>
3 AuthorDate: Fri Nov 18 21:54:18 2011 +0000
4 Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
5 CommitDate: Fri Nov 18 23:58:37 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=0510c473
7
8 CGroups: /sys/fs/cgroups should be a tmpfs
9
10 The kernel documentation states that a cgroup file system should not be
11 mounted here, but a tmpfs.
12
13 This also means that we should not create a group for each process, but
14 we should allow the user to specify which group a process should be
15 assigned to. The rc_cgroup variable will be used for this purpose.
16
17 For more information, see /usr/src/linux/Documentation/cgroups/cgroups.txt.
18
19 ---
20 init.d/sysfs.in | 2 +-
21 sh/runscript.sh.in | 29 +++++++----------------------
22 2 files changed, 8 insertions(+), 23 deletions(-)
23
24 diff --git a/init.d/sysfs.in b/init.d/sysfs.in
25 index 257f314..a536d5f 100644
26 --- a/init.d/sysfs.in
27 +++ b/init.d/sysfs.in
28 @@ -65,7 +65,7 @@ mount_misc()
29 if [ -d /sys/fs/cgroup ] && ! mountinfo -q /sys/fs/cgroup; then
30 if grep -qs cgroup /proc/filesystems; then
31 ebegin "Mounting cgroup filesystem"
32 - mount -n -t cgroup -o nodev,noexec,nosuid \
33 + mount -n -t tmpfs -o nodev,noexec,nosuid \
34 cgroup /sys/fs/cgroup
35 eend $?
36 fi
37
38 diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in
39 index c7d712b..706a1f7 100644
40 --- a/sh/runscript.sh.in
41 +++ b/sh/runscript.sh.in
42 @@ -190,18 +190,13 @@ fi
43 sourcex -e "@SYSCONFDIR@/rc.conf"
44
45 # Attach to CGroup - dir existing is enough for us
46 -if [ -d /sys/fs/cgroup/ ]; then
47 - # use RC_SVCNAME unless overridden in conf.d
48 - SVC_CGROUP=${rc_cgroup:-$RC_SVCNAME}
49 - mkdir -p /sys/fs/cgroup/${SVC_CGROUP}
50 - for f in cpuset.cpus cpuset.mems; do
51 - if [ -f /sys/fs/cgroup/${f} ]; then
52 - cp /sys/fs/cgroup/${f} /sys/fs/cgroup/${SVC_CGROUP}
53 - fi
54 - done
55 - # now attach self to cgroup - any children of this process will inherit this
56 - echo $$ > /sys/fs/cgroup/${SVC_CGROUP}/tasks
57 - # TODO: set res limits from conf.d
58 +if [ -d /sys/fs/cgroup -a -n "${rc_cgroup}" ]; then
59 + if [ -d /sys/fs/cgroup/${rc_cgroup} ]; then
60 + # attach self to cgroup - any children of this process will inherit this
61 + echo $$ > /sys/fs/cgroup/${rc_cgroup}/tasks
62 + else
63 + eerror "Control group /sys/fs/cgroup/${rc_cgroup} does not exist."
64 + fi
65 fi
66
67 # Apply any ulimit defined
68 @@ -307,14 +302,4 @@ while [ -n "$1" ]; do
69 exit 1
70 done
71
72 -# CGroup cleanup
73 -if [ -d /sys/fs/cgroup/ ]; then
74 - # use RC_SVCNAME unless overridden in conf.d
75 - SVC_CGROUP=${rc_cgroup:-$RC_SVCNAME}
76 - # reattach to root cgroup
77 - echo $$ > /sys/fs/cgroup/tasks
78 - # remove cgroup if empty, will fail if any task attached
79 - rmdir /sys/fs/cgroup/${SVC_CGROUP} 2>/dev/null
80 -fi
81 -
82 exit 0