Atoptool / atop

System and process monitor for Linux
GNU General Public License v2.0
792 stars 109 forks source link

cgroups: Handle cgroups2 support more granularly #284

Closed ton31337 closed 7 months ago

ton31337 commented 9 months ago

If you have a system mounted with both cgroupsv1, and cgroupsv2, you have something like:

% cat /proc/1/cgroup
13:perf_event:/
12:memory:/init.scope
11:rdma:/
10:pids:/init.scope
9:misc:/
8:cpu,cpuacct:/init.scope
7:cpuset:/
6:freezer:/
5:net_cls,net_prio:/
4:hugetlb:/
3:blkio:/init.scope
2:devices:/init.scope
1:name=systemd:/init.scope
0::/init.scope

With some systems you might have like this:

% cat /proc/1/cgroup
1:name=systemd:/
0::/init.scope

In both cases cgroupsv2 is activated and working fine.

Let's relax a bit the check and parse the whole file for "0::" pattern instead of just relying on the first line (which is wrong at some cases).

With patched version running ./atop -X:

    PID          CPUWGT          CPUMAX          CPUMAXR          MEMMAX          MMMAXR          SWPMAX          SWMAXR            CPU          CMD                     CGROUP (horizontal scroll: <- and ->)  1/11
 481069             100             max             400%               -             max               -             max             7%          php-fpm8.2              /u00000000d
 481042             100             max             400%               -             max               -             max             6%          php-fpm8.2              /u00000000f
 481159             100             max             400%               -             max               -             max             6%          php-fpm8.2              /u00000000c