CGroups: /sys/fs/cgroups should be a tmpfs

The kernel documentation states that a cgroup file system should not be
mounted here, but a tmpfs.

This also means that we should not create a group for each process, but
we should allow the user to specify which group a process should be
assigned to. The rc_cgroup variable will be used for this purpose.

For more information, see /usr/src/linux/Documentation/cgroups/cgroups.txt.
This commit is contained in:
William Hubbs 2011-11-18 15:54:18 -06:00
parent 9a3d6c7600
commit 0510c473d4
2 changed files with 8 additions and 23 deletions

View File

@ -65,7 +65,7 @@ mount_misc()
if [ -d /sys/fs/cgroup ] && ! mountinfo -q /sys/fs/cgroup; then if [ -d /sys/fs/cgroup ] && ! mountinfo -q /sys/fs/cgroup; then
if grep -qs cgroup /proc/filesystems; then if grep -qs cgroup /proc/filesystems; then
ebegin "Mounting cgroup filesystem" ebegin "Mounting cgroup filesystem"
mount -n -t cgroup -o nodev,noexec,nosuid \ mount -n -t tmpfs -o nodev,noexec,nosuid \
cgroup /sys/fs/cgroup cgroup /sys/fs/cgroup
eend $? eend $?
fi fi

View File

@ -190,18 +190,13 @@ fi
sourcex -e "@SYSCONFDIR@/rc.conf" sourcex -e "@SYSCONFDIR@/rc.conf"
# Attach to CGroup - dir existing is enough for us # Attach to CGroup - dir existing is enough for us
if [ -d /sys/fs/cgroup/ ]; then if [ -d /sys/fs/cgroup -a -n "${rc_cgroup}" ]; then
# use RC_SVCNAME unless overridden in conf.d if [ -d /sys/fs/cgroup/${rc_cgroup} ]; then
SVC_CGROUP=${rc_cgroup:-$RC_SVCNAME} # attach self to cgroup - any children of this process will inherit this
mkdir -p /sys/fs/cgroup/${SVC_CGROUP} echo $$ > /sys/fs/cgroup/${rc_cgroup}/tasks
for f in cpuset.cpus cpuset.mems; do else
if [ -f /sys/fs/cgroup/${f} ]; then eerror "Control group /sys/fs/cgroup/${rc_cgroup} does not exist."
cp /sys/fs/cgroup/${f} /sys/fs/cgroup/${SVC_CGROUP} fi
fi
done
# now attach self to cgroup - any children of this process will inherit this
echo $$ > /sys/fs/cgroup/${SVC_CGROUP}/tasks
# TODO: set res limits from conf.d
fi fi
# Apply any ulimit defined # Apply any ulimit defined
@ -307,14 +302,4 @@ while [ -n "$1" ]; do
exit 1 exit 1
done done
# CGroup cleanup
if [ -d /sys/fs/cgroup/ ]; then
# use RC_SVCNAME unless overridden in conf.d
SVC_CGROUP=${rc_cgroup:-$RC_SVCNAME}
# reattach to root cgroup
echo $$ > /sys/fs/cgroup/tasks
# remove cgroup if empty, will fail if any task attached
rmdir /sys/fs/cgroup/${SVC_CGROUP} 2>/dev/null
fi
exit 0 exit 0