]> git.proxmox.com Git - mirror_lxcfs.git/commit
Per-container CPU usage in /proc/stat
authorJakub Skokan <jakub.skokan@havefun.cz>
Mon, 18 Jun 2018 08:50:02 +0000 (10:50 +0200)
committerJakub Skokan <jakub.skokan@havefun.cz>
Tue, 19 Jun 2018 16:42:54 +0000 (18:42 +0200)
commit8be92dd19ceecb0ab54f36cc69d5f3845ba29844
treec7571a36b684adb71f9bbae8a219ebee623e4889
parent1c9fc36f1a81f2142d5f641e83bb8146752936b5
Per-container CPU usage in /proc/stat

Containers can see utilization of all available CPUs, even if the CPU
is utilized by other containers or by the host. The contents
of `/proc/stat` is shared across the system, except for hiding CPUs
excluded by cpuset. This commit attempts to fix that, but at a cost.
CPU usage is read from cpuacct cgroup, but that accounts only for
`user` and `system` fields from `/proc/stat`. Idle time can be
calculated, but other fields cannot, thus are always set to 0.
Additionally, idle time is based on values from the host, so even
a freshly started container has large initial idle time.

If the cpuacct cgroup is not present, or reading from it fails, LXCFS
will return CPU usage stats from the host as before.

Signed-off-by: Jakub Skokan <jakub.skokan@havefun.cz>
bindings.c