RFR: 8349988: Change cgroup version detection logic to not depend on /proc/cgroups

Severin Gehwolf sgehwolf at openjdk.org
Fri Feb 28 09:39:53 UTC 2025


On Thu, 27 Feb 2025 14:47:23 GMT, Severin Gehwolf <sgehwolf at openjdk.org> wrote:

>> This pull request fixes https://bugs.openjdk.org/browse/JDK-8349988 and https://bugs.openjdk.org/browse/JDK-8347811.
>> 
>> I tested it with:
>> 
>> 
>> java -Xlog:os+container=trace -version
>> 
>> on:
>> 
>> `Red Hat Enterprise Linux 8 (cgroups v1 only)`:
>> _No change in behaviour_
>> 
>> `Fedora 41 (cgroups v2)`:
>> _More verbose output due to `/sys/fs/cgroup/cgroup.controllers` parsing:_
>> 
>> --- tt-old-f41.txt	2025-02-26 15:37:56.310738515 -0500
>> +++ tt-new-f41.txt	2025-02-26 15:37:56.601739407 -0500
>> @@ -1,7 +1,12 @@
>>  [trace][os,container] OSContainer::init: Initializing Container Support
>> -[debug][os,container] Detected optional pids controller entry in /proc/cgroups
>> -[debug][os,container] controller cpuset is not enabled
>> -                    ] 
>> +[debug][os,container] v2 controller cpuset is enabled and relevant
>> +[debug][os,container] v2 controller cpu is enabled and required
>> +[debug][os,container] v2 controller io is enabled but not relevant
>> +[debug][os,container] v2 controller memory is enabled and required
>> +[debug][os,container] v2 controller hugetlb is enabled but not relevant
>> +[debug][os,container] v2 controller pids is enabled and relevant
>> +[debug][os,container] v2 controller rdma is enabled but not relevant
>> +[debug][os,container] v2 controller misc is enabled but not relevant
>>  [debug][os,container] Detected cgroups v2 unified hierarchy
>>  [trace][os,container] Adjusting controller path for memory: /sys/fs/cgroup/user.slice/user-4215196.slice/user at 4215196.service/app.slice/app-org.gnome.Terminal.slice/vte-spawn-135086d6-2de4-4f2e-ad94-899b5eecaf83.scope
>>  [trace][os,container] Path to /memory.max is /sys/fs/cgroup/user.slice/user-4215196.slice/user at 4215196.service/app.slice/app-org.gnome.Terminal.slice/vte-spawn-135086d6-2de4-4f2e-ad94-899b5eecaf83.scope/memory.max
>> 
>> 
>> `Fedora 41 (custom kernel with cgroups v1 disabled)`:
>> _Fixes `cgroups v2` detection:_
>> 
>> --- tt-old-f41-custom-kernel.txt	2025-02-26 15:37:58.197744304 -0500
>> +++ tt-new-f41-custom-kernel.txt	2025-02-26 15:37:59.380747933 -0500
>> @@ -1,7 +1,63 @@
>>  [trace][os,container] OSContainer::init: Initializing Container Support
>> -[debug][os,container] Detected optional pids controller entry in /proc/cgroups
>> -[debug][os,container] controller cpuset is not enabled
>> -                    ] 
>> -[debug][os,container] controller memory is not enabled
>> -                    ] 
>> -[debug][os,container] One or more required controllers disabled at kernel level.
>> +[...
>
> src/hotspot/os/linux/cgroupSubsystem_linux.cpp line 339:
> 
>> 337:         cg_infos[MEMORY_IDX]._enabled = (enabled == 1);
>> 338:       } else if (strcmp(name, "cpuset") == 0) {
>> 339:         log_debug(os, container)("Detected optional cpuset controller entry in %s", controllers_file);
> 
> In https://bugs.openjdk.org/browse/JDK-8347129 we decided to keep the `cpuset` optionality alone for cg v1. I'd prefer if we kept it that way as it's becoming increasingly difficult to find those systems (or change them). Thus, hard to know if this would break something.

Update: Please remove the log line, since this is the cg v1 branch and there cpuset isn't optional.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/23811#discussion_r1975107752


More information about the hotspot-dev mailing list