[jdk17u-dev] RFR: 8349988: Change cgroup version detection logic to not depend on /proc/cgroups
Severin Gehwolf
sgehwolf at openjdk.org
Tue Feb 17 13:28:24 UTC 2026
On Mon, 16 Feb 2026 20:27:31 GMT, Severin Gehwolf <sgehwolf at openjdk.org> wrote:
> Please review this backport of the cgroup version detection logic which affects JDK 17 as well. Newer systems which are affected, like Ubuntu 2025-XX, get more commonly used. Therefore, I propose to backport it there too. The JDK 21 backport got shipped with the 21.0.10 update in January. The patch is not clean due to `nullptr` vs `NULL` differences and more context changes (e.g. [JDK-8261242](https://bugs.openjdk.org/browse/JDK-8261242) not in JDK 17). Since the patch is not clean anyway, I've included the one-liner of [JDK-8354878](https://bugs.openjdk.org/browse/JDK-8354878) right away.
>
> Testing:
> - [x] GHA
> - [x] Container tests on cg v1 and cg v2 on Linux x86_64 (RHEL 8 and Fedora 42). Manual testing on an affected cg v2 system that container limits are detected.
I've included [JDK-8354878](https://bugs.openjdk.org/browse/JDK-8354878) - a one-liner - directly in here so as to not regress.
On an affected system (Ubuntu 2025-10) we have this before/after.
**Before**
$ podman run --rm -ti --cpus 2 --memory 200m --memory-swap=200m -v $(pwd)/jdk-17.0.18+8:/opt/jdk ubuntu:latest /opt/jdk/bin/java -Xlog:os+container=trace --version
[0.000s][trace][os,container] OSContainer::init: Initializing Container Support
[0.000s][debug][os,container] Detected optional pids controller entry in /proc/cgroups
[0.001s][debug][os,container] controller cpuset is not enabled
[0.001s][debug][os,container] controller memory is not enabled
[0.001s][debug][os,container] One or more required controllers disabled at kernel level.
openjdk 17.0.18 2026-01-20
OpenJDK Runtime Environment Temurin-17.0.18+8 (build 17.0.18+8)
OpenJDK 64-Bit Server VM Temurin-17.0.18+8 (build 17.0.18+8, mixed mode, sharing)
**After**
$ podman run --rm -ti --cpus 2 --memory 200m --memory-swap=200m -v $(pwd)/jdk17-jdk:/opt/jdk ubuntu:latest /opt/jdk/bin/java -Xlog:os+container=trace --version
[0.000s][trace][os,container] OSContainer::init: Initializing Container Support
[0.000s][debug][os,container] Detected optional pids controller entry in /sys/fs/cgroup/cgroup.controllers
[0.000s][debug][os,container] controller cpuset is not enabled
[0.000s][debug][os,container] Detected cgroups v2 unified hierarchy
[0.000s][trace][os,container] Path to /cpu.max is /sys/fs/cgroup/cpu.max
[0.000s][trace][os,container] Raw value for CPU quota is: 200000
[0.000s][trace][os,container] CPU Quota is: 200000
[0.000s][trace][os,container] Path to /cpu.max is /sys/fs/cgroup/cpu.max
[0.000s][trace][os,container] CPU Period is: 100000
[0.000s][trace][os,container] CPU Quota count based on quota/period: 2
[0.000s][trace][os,container] OSContainer::active_processor_count: 2
[0.001s][trace][os,container] CgroupSubsystem::active_processor_count (cached): 2
[0.001s][trace][os,container] total physical memory: 7687462912
[0.001s][trace][os,container] Path to /memory.max is /sys/fs/cgroup/memory.max
[0.001s][trace][os,container] Raw value for memory limit is: 209715200
[0.001s][trace][os,container] Memory Limit is: 209715200
[0.001s][trace][os,container] CgroupSubsystem::active_processor_count (cached): 2
[0.032s][trace][os,container] Path to /cpu.max is /sys/fs/cgroup/cpu.max
[0.032s][trace][os,container] Raw value for CPU quota is: 200000
[0.032s][trace][os,container] CPU Quota is: 200000
[0.032s][trace][os,container] Path to /cpu.max is /sys/fs/cgroup/cpu.max
[0.032s][trace][os,container] CPU Period is: 100000
[0.032s][trace][os,container] CPU Quota count based on quota/period: 2
[0.032s][trace][os,container] OSContainer::active_processor_count: 2
openjdk 17.0.19-internal 2026-04-21
OpenJDK Runtime Environment (fastdebug build 17.0.19-internal+0-adhoc.sgehwolf.jdk17u-dev)
OpenJDK 64-Bit Server VM (fastdebug build 17.0.19-internal+0-adhoc.sgehwolf.jdk17u-dev, mixed mode, sharing)
@fitzsim Could you please take a look? Thank you!
-------------
PR Comment: https://git.openjdk.org/jdk17u-dev/pull/4271#issuecomment-3910442789
PR Comment: https://git.openjdk.org/jdk17u-dev/pull/4271#issuecomment-3914650172
PR Comment: https://git.openjdk.org/jdk17u-dev/pull/4271#issuecomment-3914694378
More information about the jdk-updates-dev
mailing list