Hi,
If I got that right, it's ok for the maintainer of ulatencyd, if the subsystems were mounted into it's own subdirectories?

If so, I like to propose an intitv script which does it.

When reading the introduction to cgroup in the kernel documentation, it is best pratice to mount tmpfs under /sys/fs/cgroup and create a subdirectory for every subsystem.

Please see attachement for the script. CGROUPSUBSYSTEMS must be set to yes in /etc/default/tmpfs. So cgroup subsystems are not mounted by default, which does not break existent configurations done via /etc/fstab and one can switch it on/off easily. The script was tested on Squeeze with 2.6.39-bpo60-2. Activated with "update-rc.d mountcgroupsubsys.sh defaults".

Problem: It is very cgroup specific and is possibily misplaced in initscripts?

Regards,
Marcus
#! /bin/sh
### BEGIN INIT INFO
# Provides:          mountcgroupsubsys
# Required-Start:    mountkernfs
# Required-Stop:
# Should-Start:      
# Default-Start:     S
# Default-Stop:
# Short-Description: Mount cgroup subsystems
# Description:       Mounts every cgroup subsystem
#                    in it's own directory under /sys/fs/cgroup
### END INIT INFO

PATH=/sbin:/bin
. /lib/init/vars.sh

. /lib/lsb/init-functions
. /lib/init/mount-functions.sh

[ -f /etc/default/tmpfs ] && . /etc/default/tmpfs

do_start () {

        #
        # Mount cgroup on /sys/fs/cgroup
        #
        # Only mount cgroup if it is supported and enabled in /etc/default/tmpfs
        if grep -E -qs "cgroup\$" /proc/filesystems && [ -d /sys/fs/cgroup ] && 
[ yes = "$CGROUPSUBSYSTEMS" ]
        then
                RW_OPT=
                [ "${RW_SIZE:=$TMPFS_SIZE}" ] && RW_OPT=",size=$RW_SIZE"
                domount tmpfs "" /sys/fs/cgroup tmpfs -omode=0755,nosuid$RW_OPT
                CGROUP_EXCL_SUBSYS=${CGROUP_EXCL_SUBSYS:-"#"}
                grep -i -o '^[a-z_-]*' /proc/cgroups | grep -v 
${CGROUP_EXCL_SUBSYS} | while read subsys; do
                        if [ ! -d /sys/fs/cgroup/${subsys} ]
                        then
                                mkdir /sys/fs/cgroup/${subsys}
                                domount cgroup "" /sys/fs/cgroup/${subsys} 
cgroup -o${subsys}
                                [ $? -eq 0 ] && log_success_msg "Successfully 
mounted /sys/fs/cgroup/${subsys}."
                        else
                                log_warning_msg "Directory 
/sys/fs/cgroup/${subsys} does already exists. Do not try to mount cgroup 
subsystem."
                        fi
                done
        else
                log_warning_msg "Cgroups not supported by kernel or 
CGROUPSUBSYSTEMS not set to 'yes' in /etc/default/tmpfs."
        fi


}

do_stop () {
        if [ -d /sys/fs/cgroup ]
        then
                for subsys in $(grep -i -o '^[a-z_-]*' /proc/cgroups); do
                        if [ -d /sys/fs/cgroup/${subsys} ]
                        then
                                umount /sys/fs/cgroup/${subsys}
                                [ $? -ne 0 ] && log_warning_msg "Could not 
unmount /sys/fs/cgroup/${subsys}."
                                rmdir /sys/fs/cgroup/${subsys}
                                [ $? -eq 0] && log_success_msg "Successfully 
removed /sys/fs/cgroup/${subsys}."
                        fi
                done
                grep "/sys/fs/cgroup" /etc/mtab > /dev/null 
                if [ $? -eq 0 ]
                then
                        umount /sys/fs/cgroup
                        [ $? -eq 0 ] && log_success_msg "Successfully unmounted 
/sys/fs/cgroup."
                fi
        else
                log_warning_msg "Directory /sys/fs/cgroup not found. Do not try 
to unmount cgroup subsystems."
        fi
}

case "$1" in
  "")
        echo "Warning: mountcgroupsubsys should be called with the 'start' 
argument." >&2
        do_start
        ;;
  start)
        do_start
        ;;
  restart|reload|force-reload)
        echo "Error: argument '$1' not supported" >&2
        exit 3
        ;;
  stop)
        do_stop
        ;;
  *)
        echo "Usage: mountcgroupsubsys [start|stop]" >&2
        exit 3
        ;;
esac

Reply via email to