+# Set up cgroup CPU accounting (cpuacct)
+accounting() {
+ # 1-- once, system wide
+ grep -q "/sys/fs/cgroup cgroup" /proc/mounts || \
+ mount -t cgroup -ocpuacct none /sys/fs/cgroup
+ if [ -d /sys/fs/cgroup/$NAME ] ; then
+ : # reset?
+ else
+ mkdir /sys/fs/cgroup/$NAME
+ # the following fixes things that sometimes are broken?
+ for f in cpuset.mems cpuset.cpus ; do
+ [ -z "$(cat /sys/fs/cgroups/$NAME/$F)" ] && \
+ echo 0 > /sys/fs/cgroups/$NAME/$F
+ done
+
+ fi
+ # Register this task for subhost accounting
+ echo $$ > /sys/fs/cgroup/$NAME/tasks
+}
+