Package: openjdk-21-jdk
Version: 21.0.8~5ea-1

openjdk is no longer "cgroup-aware" when running in a container with
cgroupv2 enabled. Apparently this is a regression triggered by kernel
6.12. AFAIU openjdk relies upon some deprecated features that were
dropped for the new kernel. See https://bugs.openjdk.org/browse/JDK-8347811.
Sample:

% docker run -it debian:sid
Unable to find image 'debian:sid' locally
sid: Pulling from library/debian
6b1598688dd5: Pull complete 
Digest: sha256:eb835ce18611a0b66cf4b9c6a239752d8498bb528585c01a7b7141aed1097ea7
Status: Downloaded newer image for debian:sid
root@b5a58a706393:/# apt update
Get:1 http://deb.debian.org/debian sid InRelease [208 kB]
Get:2 http://deb.debian.org/debian sid/main amd64 Packages [10.1 MB]
Fetched 10.3 MB in 1s (13.0 MB/s)  
All packages are up to date.    

root@b5a58a706393:/# apt -y install default-jdk
Installing:                     
  default-jdk
:
:

root@b5a58a706393:/# grep cgroup /proc/self/mounts
cgroup /sys/fs/cgroup cgroup2 ro,nosuid,nodev,noexec,relatime 0 0
root@b5a58a706393:/# uname -a
Linux b5a58a706393 6.12.32-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.32-1 
(2025-06-07) x86_64 GNU/Linux
root@b5a58a706393:/# java -version      
openjdk version "21.0.8-ea" 2025-07-15
OpenJDK Runtime Environment (build 21.0.8-ea+5-Debian-1)
OpenJDK 64-Bit Server VM (build 21.0.8-ea+5-Debian-1, mixed mode, sharing)

root@b5a58a706393:/# java -Xlog:os+container=trace --version
[0.001s][trace][os,container] OSContainer::init: Initializing Container Support
[0.001s][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 21.0.8-ea 2025-07-15
OpenJDK Runtime Environment (build 21.0.8-ea+5-Debian-1)
OpenJDK 64-Bit Server VM (build 21.0.8-ea+5-Debian-1, mixed mode, sharing)




This is not OK. In a sid container running on Bookworm (kernel 6.1.140)
you get the expected result:

root@6e5d48c668e9:/# grep cgroup /proc/self/mounts
cgroup /sys/fs/cgroup cgroup2 
ro,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot 0 0
root@6e5d48c668e9:/# uname -a
Linux 6e5d48c668e9 6.1.0-32-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.129-1 
(2025-03-06) x86_64 GNU/Linux
root@6e5d48c668e9:/# java -version
openjdk version "21.0.8-ea" 2025-07-15
OpenJDK Runtime Environment (build 21.0.8-ea+5-Debian-1)
OpenJDK 64-Bit Server VM (build 21.0.8-ea+5-Debian-1, mixed mode, sharing)

root@6e5d48c668e9:/# java -Xlog:os+container=trace --version
[0.001s][trace][os,container] OSContainer::init: Initializing Container Support
[0.001s][debug][os,container] Detected optional cpuset controller entry in 
/proc/cgroups
[0.001s][debug][os,container] Detected optional pids controller entry in 
/proc/cgroups
[0.001s][debug][os,container] Detected cgroups v2 unified hierarchy
[0.001s][trace][os,container] Path to /cpu.max is /sys/fs/cgroup/cpu.max
[0.001s][trace][os,container] Raw value for CPU quota is: max
[0.002s][trace][os,container] CPU Quota is: -1
[0.002s][trace][os,container] Path to /cpu.max is /sys/fs/cgroup/cpu.max
[0.002s][trace][os,container] CPU Period is: 100000
[0.002s][trace][os,container] OSContainer::active_processor_count: 8
[0.002s][trace][os,container] CgroupSubsystem::active_processor_count (cached): 
8
[0.002s][trace][os,container] total physical memory: 16669937664
[0.002s][trace][os,container] Path to /memory.max is /sys/fs/cgroup/memory.max
[0.002s][trace][os,container] Raw value for memory limit is: max
[0.002s][trace][os,container] Memory Limit is: Unlimited
[0.002s][debug][os,container] container memory limit unlimited: -1, using host 
value 16669937664
[0.003s][trace][os,container] CgroupSubsystem::active_processor_count (cached): 
8
[0.026s][trace][os,container] Path to /cpu.max is /sys/fs/cgroup/cpu.max
[0.026s][trace][os,container] Raw value for CPU quota is: max
[0.026s][trace][os,container] CPU Quota is: -1
[0.026s][trace][os,container] Path to /cpu.max is /sys/fs/cgroup/cpu.max
[0.026s][trace][os,container] CPU Period is: 100000
[0.026s][trace][os,container] OSContainer::active_processor_count: 8
openjdk 21.0.8-ea 2025-07-15
OpenJDK Runtime Environment (build 21.0.8-ea+5-Debian-1)
OpenJDK 64-Bit Server VM (build 21.0.8-ea+5-Debian-1, mixed mode, sharing)



Regards

Harri

Reply via email to