Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgroups: Handle cgroups2 support more granularly #284

Merged
merged 1 commit into from
Dec 30, 2023

Conversation

ton31337
Copy link
Contributor

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

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
```

Signed-off-by: Donatas Abraitis <[email protected]>
@Atoptool Atoptool merged commit 9f68140 into Atoptool:master Dec 30, 2023
@ton31337 ton31337 deleted the fix/cgroup2_handling branch December 30, 2023 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants