Cgroups /sys/fs/cgroup is empty on ubuntu

tamlok picture tamlok · Dec 13, 2014 · Viewed 13.9k times · Source

I am new to cgroup. I want to use cgroup to bind Qemu to some CPUs. I am working on Ubuntu 12.04.3 with my own compiled kernel 3.11.0+.
Below is some output of my commands.

root@xiao-laptop:~/tamlok# service cgconfig start
start: Job failed to start
root@xiao-laptop:~/tamlok# ls /sys/fs/cgroup/
root@xiao-laptop:~/tamlok# cat /proc/mounts | grep cgroup
root@xiao-laptop:~/tamlok# lssubsys --al
cpuset
cpu
cpuacct
devices
freezer
blkio
perf_event

/sys/fs/cgroup/ being empty really confused me. I don't know what should I do next to achieve my target. It seems that the cgroup is not mounted? So what's wrong with this? If you need any info about my platform to solve it, please let me know.

Actually I didn't know the whole process to config and use the cgroup. Or you could help me out with this step by step. I am afraid that lacking some necessary configuration before resulted in this problem. Thanks very much!

Answer

tamlok picture tamlok · Dec 15, 2014

Finally, I read the kernel documentation about cgroups and cpusets, and there is a detail description about how to create and use cgroups step by step.
The problem here was that I didn't mount the cgroups. The solution is given below.

mount -t tmpfs cgroup_root /sys/fs/cgroup
mkdir /sys/fs/cgroup/cpuset
mount -t cgroup cpuset -o cpuset /sys/fs/cgroup/cpuset/

Then we can see a cpuset directory and there are files inside to modify the properties of the cpuset.
Thanks very much! Hope this will help someone!