Flag | Usage |
---|---|
-g controller:/path | defines the control group(s) to be added :
|
cpu,cpuacct:/ cpu,cpuacct:/cpuGroup_Parent cpu,cpuacct:/cpuGroup_Parent/cpuGroup_childB cpu,cpuacct:/cpuGroup_Parent/cpuGroup_childA cpuset:/
cpu,cpuacct:/ cpu,cpuacct:/cpuGroup_Parent cpu,cpuacct:/cpuGroup_Parent/cpuGroup_childB cpu,cpuacct:/cpuGroup_Parent/cpuGroup_childA
cpu,cpuacct:/cpuGroup_Parent/ cpu,cpuacct:/cpuGroup_Parent/cpuGroup_childB cpu,cpuacct:/cpuGroup_Parent/cpuGroup_childA
cpu,cpuacct:/cpuGroup_Parent/cpuGroup_childA/
/
leading the path looks optionalcgdelete cpu:/cpuGroup_Parent/cpuGroup_childA cgdelete cpu:/cpuGroup_Parent/cpuGroup_childB cgdelete cpu:/cpuGroup_Parent lscgroup cpu:/
cpu,cpuacct:/ i.e. "empty resultset"
Scenario | CPU share given to the cgroup of the process we're trying to limit | CPU share given to any other cgroup | Total shares defined | Relative weight of shares given to the cgroup limiting the CPU usage |
---|---|---|---|---|
1 | x (x >0) | 0 (i.e. cpu.shares used only once) | x | 100% |
2 | x | x | 2x | 50% |
3 | x | 9x | 10x | 10% |
By default, all groups inherit 1,024 shares or 100% of CPU time., then show examples where 1024 stands for 100% CPU, 512 for 50% of CPU, 338 for 33% and so on... Either I've not understood this correctly, or this explanation is pretty misleading as well as partially wrong.
[1] 1030 [2] 1031You should already observe both processes eating 100% of the CPU (50% each)
1030 1031
So far, everything we did was configured on-the-fly and is not reboot-proof. We'll see now how to make persistent groups.
group cpuLimited { cpu { cpu.shares = 100; } } group cpuNotLimited { cpu { cpu.shares = 900; } }
Failed to enable unit: File cgconfig.service: No such file or directoryUse this command instead to load the configuration (source) :
group myGroup { cpu { cpu.cfs_period_us = 1000000; cpu.cfs_quota_us = 100000; } }
http://www.linuxembedded.fr/2011/03/bien-utiliser-les-cgroups/ https://www.cloudsigma.com/howto-cgroups/ https://www.linuxjournal.com/content/everything-you-need-know-about-linux-containers-part-i-linux-control-groups-and-process https://oakbytes.wordpress.com/2012/09/02/cgroup-cpu-allocation-cpu-shares-examples/ cgclear cpu (looks like this unmounts A LOT (?)) systemctl restart cgroupfs-mount.service grep cgroup /proc/filesystems ==> lists whether cgroup is supported