[21u] Backport intention of 8322420: [Linux] cgroup v2: Limits in parent nested control groups are not detected

Jan Kratochvil jkratochvil at azul.com
Fri Feb 7 13:13:53 UTC 2025


On Mon, 20 Jan 2025 17:58:01 +0800, Severin Gehwolf wrote:
> You didn't say *why* you'd like to backport it

https://bugs.openjdk.org/browse/JDK-8322420
The following text is based on:
	https://mail.openjdk.org/pipermail/jdk-updates-dev/2022-February/012398.html

cgroups v2 support hierarchical groups. Limits from outer groups apply also
for the inner groups. To calculate an effective limit for the current nested
group one needs to calculate a minimum of all the limits in the current group
and its parent groups up to the root one.

The risk of NOT backporting those patches is that the JVM would wrongly detect
resource limits. Container detection code would just give up early and would
use the host systems' resource limits instead. Random OOM kills and other
strange behaviour can happen.

As the code is the same in 21u as in 24u and all the backports are clean I do
not expect regressions.

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

I would like to backport:
	https://bugs.openjdk.org/browse/JDK-8322420
	[Linux] cgroup v2: Limits in parent nested control groups are not detected

The whole patchset in a chronological order (the reverse of `git log`):

- <https://github.com/openjdk/jdk/commit/c96cbe481c86800b76e220374b24b6671984adb7>
  <https://bugs.openjdk.org/browse/JDK-8313083> Print 'rss' and 'cache' as part of the container information
  9 files changed, 46 insertions(+), 1 deletion(-)

- <https://github.com/openjdk/jdk/commit/cab74b075e4572529a21bf8ac652ec2f1ab4fcaf>
  <https://bugs.openjdk.org/browse/JDK-8324287> Record total and free swap space in JFR
  11 files changed, 178 insertions(+), 1 deletion(-)

- <https://github.com/openjdk/jdk/commit/3d106cb091de6b6ef2a9bf483fb0f5c98c28263c>
  <https://bugs.openjdk.org/browse/JDK-8325139> JFR SwapSpace event - add free swap space information on Linux when running in a container environment
  9 files changed, 101 insertions(+), 10 deletions(-)

- <https://github.com/openjdk/jdk/commit/c1281e6b45ed167df69d29a6039d81854c145ae6>
  <https://bugs.openjdk.org/browse/JDK-8324678> Replace NULL with nullptr in HotSpot gtests
  patch reduced only to files:
   - test/hotspot/gtest/runtime/test_os_linux_cgroups.cpp
  1 file changed, 2 insertions(+), 2 deletions(-)

- <https://github.com/openjdk/jdk/commit/09d4936657a0bdc122a4ab80735bd9c8c109839c>
    <https://bugs.openjdk.org/browse/JDK-8252136> Several methods in hotspot are missing "static"
  patch reduced only to files:
   - test/hotspot/gtest/os/linux/test_cgroupSubsystem_linux.cpp
  1 file changed, 5 insertions(+), 5 deletions(-)

- <https://github.com/openjdk/jdk/commit/e889b460c03b3887ec5477fa734c430d3c3a41c8>
  <https://bugs.openjdk.org/browse/JDK-8327071> [Testbug] g-tests for cgroup leave files in /tmp on linux
  1 file changed, 10 insertions(+), 1 deletion(-)

- <https://github.com/openjdk/jdk/commit/3d4eb159e6d597f37081faf21b7e3f0f1af299e5>
  <https://bugs.openjdk.org/browse/JDK-8302744> Refactor Hotspot container detection code
  10 files changed, 862 insertions(+), 590 deletions(-)

- <https://github.com/openjdk/jdk/commit/d0052c032cc1927e7e92f04cfedab20e0c4e0293>
  <https://bugs.openjdk.org/browse/JDK-8333326> Linux Alpine build fails after 8302744
  1 file changed, 9 insertions(+), 5 deletions(-)

- <https://github.com/openjdk/jdk/commit/0a6ffa57954ddf4f92205205a5a1bada813d127a>
  <https://bugs.openjdk.org/browse/JDK-8261242> [Linux] OSContainer::is_containerized() returns true when run outside a container
  18 files changed, 290 insertions(+), 63 deletions(-)

- <https://github.com/openjdk/jdk21u-dev/pull/1330/commits/1ceeb18e6fbf9a7851499b89cba34544ddbcd6dc>
  src/java.base/linux/native/libjava/CgroupMetrics.c:42:(.text+0x11): undefined reference to `JVM_IsContainerized'
  a patch by Yuri Nesterenko, it is not needed in recent JDKs due to <https://bugs.openjdk.org/browse/JDK-8017234>
  1 file changed, 1 insertion(+)

- <https://github.com/openjdk/jdk/commit/153b12b9df87fdf8122cae3bf7f13078f55f7101>
  <https://bugs.openjdk.org/browse/JDK-8331560> Refactor Hotspot container detection code so that subsystem delegates to controllers
  8 files changed, 511 insertions(+), 264 deletions(-)

- <https://github.com/openjdk/jdk/commit/38bd8a36704a962f0ad1052fd2ec150a61663256>
  <https://bugs.openjdk.org/browse/JDK-8338236> Compile error in cgroup code on Linux when using clang
  2 files changed, 5 insertions(+), 5 deletions(-)

- <https://github.com/openjdk/jdk/commit/12d060a255b9b783488714c6c2cb73a899d3f708>
  <https://bugs.openjdk.org/browse/JDK-8339148> Make os::Linux::active_processor_count() public
  unclean but obvious
  1 file changed, 1 insertion(+), 3 deletions(-)

- <https://github.com/openjdk/jdk/commit/55a7cf14453b6cd1de91362927b2fa63cba400a1>
  <https://bugs.openjdk.org/browse/JDK-8322420> [Linux] cgroup v2: Limits in parent nested control groups are not detected
  9 files changed, 362 insertions(+), 111 deletions(-)

- <https://github.com/openjdk/jdk/commit/de55db2352f84c101f8197ee7aca80d72807fbc5>
  <https://bugs.openjdk.org/browse/JDK-8333522> JFR SwapSpace event might read wrong free swap space size
  1 file changed, 4 insertions(+), 1 deletion(-)

Whether they are all needed? They are 3 kinds of pre-requisite patches:
 * non-trivial functionality required by later patches
 * trivial fix-ups which make the later applied patches clean
 * trivial fix-ups of previously applied patch

For easier checking of the backport it is also available at:
	https://github.com/jankratochvil/jdk21u-dev/tree/devmaster-cgroup2

If pre-approved I need to submit those patches as separate backports.

I find the April release as the suitable one.


Thanks,
Jan Kratochvil


More information about the jdk-updates-dev mailing list