hi,
i’m currently playing around with cgroups for limiting some applications memory and cpu usage. however i’m having problems with the permissions.
for example, i want to limit firefox to 512mb ram and 50% cpu shares. so i’ve put the following in my /etc/cgropups.conf
group firefox {
perm {
admin {
uid = neo;
gid = users;
}
task {
uid = neo;
gid = users;
}
}
}
group firefox/run {
cpu {
cpu.shares = 500;
}
memory {
memory.limit_in_bytes = 536870912;
memory.swappiness = 90;
}
}
mount {
cpu = /mnt/cgroup/cpu,cpua
cpuacct = /mnt/cgroup/cpu,
memory = /mnt/cgroup/memor
blkio = /mnt/cgroup/blkio;
}
everything gets mounted, however the “tasks” file is still owned by root, so i can’t put any tasks in it.
cgexec -g cpu,memory:firefox la
cgroup change of group failed
linux-pxkd:/mnt/cgroup/cpu,cpuacct/firefox # la
total 0
drwxr-xr-x 3 root root 0 Jun 16 19:35 .
drwxr-xr-x 8 root root 0 Jun 16 07:51 ..
-rw-r--r-- 1 root root 0 Jun 16 19:35 cgroup.clone_children
--w--w--w- 1 root root 0 Jun 16 19:35 cgroup.event_control
-rw-r--r-- 1 root root 0 Jun 16 19:35 cgroup.procs
-rw-r--r-- 1 root root 0 Jun 16 19:35 cpu.cfs_period_us
-rw-r--r-- 1 root root 0 Jun 16 19:35 cpu.cfs_quota_us
-rw-r--r-- 1 root root 0 Jun 16 19:35 cpu.rt_period_us
-rw-r--r-- 1 root root 0 Jun 16 19:35 cpu.rt_runtime_us
-rw-r--r-- 1 root root 0 Jun 16 19:35 cpu.shares
-r--r--r-- 1 root root 0 Jun 16 19:35 cpu.stat
-r--r--r-- 1 root root 0 Jun 16 19:35 cpuacct.stat
-rw-r--r-- 1 root root 0 Jun 16 19:35 cpuacct.usage
-r--r--r-- 1 root root 0 Jun 16 19:35 cpuacct.usage_percpu
-rw-r--r-- 1 root root 0 Jun 16 19:35 notify_on_release
drwxr-xr-x 2 root root 0 Jun 16 19:35 run
-rw-r--r-- 1 root root 0 Jun 16 19:35 tasks
what am i doing wrong?
also, what exactly does cpu.shares do? i thought setting it to something like 500 would behave something like this:
a) if it’s the only task it would still get 100% cpu
b) if there are two tasks and the other one is sleeping it would get 100% cpu
c) if there are two tasks and both are running, both would get 50% cpu
however, when i set cpu.shares for a group to 300 and put a java application in it (JDownloader) it’s UI becomes sooooo slow until i raise cpu.shares to at least 800.
also, what are the systemd cgroups for and how do they interact with my cgroups?
thanks in advance!
i’ve followed this help: https://wiki.archlinux.org/index.php/Cgroups