Linux 6.6 Enables Tracking Per-CPU Cgroup CPU Usage Stats

Written by Michael Larabel in Linux Kernel on 11 September 2023 at 09:03 AM EDT. 1 Comment
LINUX KERNEL
With the Linux 6.6 merge window the cgroup changes brought one change worth mentioning.

With the new cgroup code in Linux 6.6, the per-CPU CPU usage stats are now being tracked.

As noted in last week's cgroup merge to Linux 6.6 Git, the per-CPU CPU usage stats are being tracked now and can be exposed such as via eBPF but not currently exposed via the cgroupfs interface. In a future kernel release the per-CPU usage stats will hopefully be exposed via cgroupfs once an adequate interface has been agreed upon.

Intel Xeon Max CPUs


The patch during the summer provided more insight into this per-CPU CPU usage stats tracking:
"Now the member variable bstat of the structure cgroup_rstat_cpu records the per-cpu time of the cgroup itself, but does not include the per-cpu time of its descendants. The per-cpu time including descendants is very useful for calculating the per-cpu usage of cgroups.

Although we can indirectly obtain the total per-cpu time of the cgroup and its descendants by accumulating the per-cpu bstat of each descendant of the cgroup. But after a child cgroup is removed, we will lose its bstat information. This will cause the cumulative value to be non-monotonic, thus affecting the accuracy of cgroup per-cpu usage.

So we add the cumul_bstat variable to record the total per-cpu time of this cgroup and its descendants, which is similar to "cpuacct.usage*" in cgroup v1. And this is also helpful for the migration from cgroup v1 to cgroup v2. After adding this variable, we can obtain the per-cpu time of cgroup and its descendants in user mode through eBPF, etc."

This cgroup contribution to the upstream kernel was carried out by Bytedance engineers.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week