Using openSUSE 12.2 64-bit. Though I am using a newer 3.7 kernel from obs. Should I perhaps try the stock openSUSE 3.4?
I want to create a few custom cgroups. So I installed the package libcgroup1 to gain the utilities. I used the configuration found in the package as an example to create the file /etc/cgconfig.conf. However when I try to start the service I get:
Jan 02 20:52:06 opensuse-sawako.site cgconfig[5488]: Starting service cgconfigLoading configuration file /etc/cgconfi...ailed
Jan 02 20:52:06 opensuse-sawako.site cgconfig[5488]: Cgroup mounting failed
Jan 02 20:52:06 opensuse-sawako.site cgconfig[5488]: Failed to parse /etc/cgconfig.conf..failed
Jan 02 20:52:06 opensuse-sawako.site cgconfig[5488]: ..done
For some reason the cgroups will not mount? I can only assume because systemd already is using cgroups at /sys/fs/cgroups. If I try to mount there instead it tells me I have no permission. Is there a correct way to setup cgroups? This is my /etc/cgconfig.conf so far:
group background {
perm {
task {
uid = root;
gid = root;
}
admin {
uid = root;
gid = root;
}
}
cpu {
cpu.shares = 512;
}
}
mount {
cpu = /mnt/cgroups/cpu;
cpuacct = /mnt/cgroups/cpuacct;
}
Are you using systemd or sysvinit? In case of systemd cgroup is already mounted by default because it relies heavily on using cgroups. Also it systemd allows you to configure cgroups for a service in unit file. May be it would be an option in your case?
I am using systemd. Though I did not yet find a solution to this, I opted to just use ulatencyd for now, which works.
Apparently, systemd mounts cpu and cpuacct together in one hierarchy and you need to do the same. It makes it impossible to mount each cpu or cpuacct separately.
bor@opensuse:~> LC_ALL=C ll -d /sys/fs/cgroup/cpu*
lrwxrwxrwx 1 root root 11 Dec 27 20:42 /sys/fs/cgroup/cpu -> cpu,cpuacct
drwxr-xr-x 3 root root 60 Jan 3 19:11 /sys/fs/cgroup/cpu,cpuacct
lrwxrwxrwx 1 root root 11 Dec 27 20:42 /sys/fs/cgroup/cpuacct -> cpu,cpuacct
drwxr-xr-x 3 root root 0 Dec 27 20:42 /sys/fs/cgroup/cpuset
bor@opensuse:~> cat /etc/cgconfig.conf
mount {
cpu = /mnt/cgroup/cpu,cpuacct;
cpuacct = /mnt/cgroup/cpu,cpuacct;
}
bor@opensuse:~> sudo systemctl start cgconfig.service
bor@opensuse:~> sudo systemctl status cgconfig.service
cgconfig.service - LSB: start and stop the WLM configuration
Loaded: loaded (/etc/init.d/cgconfig)
Active: active (running) since Thu, 03 Jan 2013 19:53:44 +0400; 4s ago
Process: 18346 ExecStop=/etc/init.d/cgconfig stop (code=exited, status=0/SUCCESS)
Process: 18419 ExecStart=/etc/init.d/cgconfig start (code=exited, status=0/SUCCESS)
CGroup: name=systemd:/system/cgconfig.service
Jan 03 19:53:44 opensuse.site cgconfig[18419]: Starting service cgconfig..done
bor@opensuse:~> tail -1 /proc/self/mounts
cgroup /mnt/cgroup/cpu,cpuacct cgroup rw,relatime,cpuacct,cpu 0 0
bor@opensuse:~>
Ok, thanks I will try that. I suppose omitting cpuacct would fail as well. So that is why I didn’t suspect that as the problem.
Thank you! Success! (For now). Note the softrealtime in the below is my custom cgroup.
cat /proc/1580/cgroup
10:hugetlb:/sysdefault
9:perf_event:/sysdefault
8:blkio:/sysdefault
7:net_cls:/sysdefault
6:freezer:/sysdefault
5:devices:/sysdefault
4:memory:/sysdefault
3:cpuacct,cpu:/softrealtime
2:cpuset:/sysdefault
1:name=systemd:/user/labyrinth/
Next up to figure out if I actually need a ‘default’ cgroup or does everything already use 1024, so if I make my soft real time cgroup use 2048 it will get 2x cpu time? And how to get blkio working. Though that is out of the scope of this thread, it works great thank you very much.
I am a bit ashamed to say I have absolutely no idea how or why, but this works. I am going to leave this here as future reference for myself and others.
I should note I keep losing X if I enable the cgconfig service while my user is logged in, so it would not save the runlevels. I have no idea if this is a bug, intentional, or something I tweaked… Either way easy to work around. What I did was init 3 to a console, and enable the services there using the ncurses version of yast2.
This config allows the use of multiple types of groups such as memory or blkio… For some reason no matter what I did I kept getting “failed to mount cgroups”. Though now it works… I changed nothing except adding a group/subgroup type of hierarchy.
Through great toil, trial and error I bring to you… An example working /etc/cgconfig.conf
mount {
cpu = /mnt/cgroup/cpu,cpuacct;
cpuacct = /mnt/cgroup/cpu,cpuacct;
memory = /mnt/cgroup/memory;
blkio = /mnt/cgroup/blkio;
}
group base {
perm {
task {
uid = root;
gid = root;
}
admin {
uid = root;
gid = root;
}
}
}
group base/realtime {
cpu {
cpu.shares = 3072;
}
memory {
memory.swappiness = 0;
}
blkio {
blkio.weight = 1000;
}
}
group base/idle {
cpu {
cpu.shares = 128;
}
memory {
memory.swappiness = 100;
}
blkio {
blkio.weight = 10;
}
}