Skip to content

Conversation

@sercher
Copy link
Contributor

@sercher sercher commented Oct 24, 2025

Hi all,

This is a clean backport of JDK-8349988 to JDK 21. The only minor context conflict is in src/hotspot/share/prims/whitebox.hpp.

The change improves container detection with newer kernels such as 6.14 HWE (bug).

podman run -v $TEST_JDK:/opt/jdk --rm -ti --memory 200m --memory-swap 200m ubuntu:24.04 /opt/jdk/bin/java -XshowSettings:system --version
--- before	2025-10-24 16:33:52.000000000 +0200
+++ after	2025-10-24 16:34:19.000000000 +0200
@@ -1,6 +1,18 @@
 Operating System Metrics:
     Provider: cgroupv2
-    System not containerized.
+    Effective CPU Count: 12
+    CPU Period: 100000us
+    CPU Quota: -1
+    CPU Shares: -1
+    List of Processors: N/A
+    List of Effective Processors: N/A
+    List of Memory Nodes: N/A
+    List of Available Memory Nodes: N/A
+    Memory Limit: 200.00M
+    Memory Soft Limit: 0.00K
+    Memory & Swap Limit: 200.00M
+    Maximum Processes Limit: 2048
+
 openjdk 21.0.10-internal 2026-01-20
 OpenJDK Runtime Environment (build 21.0.10-internal-adhoc.user.jdk21u)
 OpenJDK 64-Bit Server VM (build 21.0.10-internal-adhoc.user.jdk21u, mixed mode, sharing)

Tests:

No regressions observed in test/hotspot/jtreg/containers/, test/jdk/jdk/internal/platform

Details:

kernel 6.14 HWE Cgroup v2

--- test_results/summaryHotspotOrigCgv2.txt	2025-10-23 18:52:12.000000000 +0200
+++ test_results/summaryHotspotUpdatedCgv2.txt	2025-10-23 18:52:12.000000000 +0200
@@ -2,18 +2,18 @@
 containers/cgroup/TestContainerized.java            Passed. Execution successful
 containers/docker/DockerBasicTest.java              Passed. Execution successful
 containers/docker/ShareTmpDir.java                  Passed. Execution successful
-containers/docker/TestCPUAwareness.java             Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: 'active_processor_count.*1' missing from stdout/stderr
-containers/docker/TestCPUSets.java                  Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: assertTrue: expected true, was false
-containers/docker/TestContainerInfo.java            Passed. Skipped: jtreg.SkippedException: This test is cgroups v2 specific, skipped on cgroups v1
-containers/docker/TestJFREvents.java                Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: 'totalSize = 209715200' missing from stdout/stderr
+containers/docker/TestCPUAwareness.java             Passed. Execution successful
+containers/docker/TestCPUSets.java                  Passed. Execution successful
+containers/docker/TestContainerInfo.java            Passed. Execution successful
+containers/docker/TestJFREvents.java                Passed. Execution successful
 containers/docker/TestJFRNetworkEvents.java         Passed. Execution successful
 containers/docker/TestJFRWithJMX.java               Passed. Execution successful
 containers/docker/TestJcmd.java                     Passed. Execution successful
 containers/docker/TestJcmdWithSideCar.java          Passed. Execution successful
-containers/docker/TestLimitsUpdating.java           Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: 'active_processor_count: 2' missing from stdout/stderr
-containers/docker/TestMemoryAwareness.java          Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: 'Memory Limit is:.*104857600' missing from stdout/stderr
+containers/docker/TestLimitsUpdating.java           Passed. Execution successful
+containers/docker/TestMemoryAwareness.java          Passed. Execution successful
 containers/docker/TestMemoryWithCgroupV1.java       Passed. Execution successful
-containers/docker/TestMemoryWithSubgroups.java      Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: 'Lowest limit was:.*104857600' missing from stdout/stderr
-containers/docker/TestMisc.java                     Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: 'CheckContainerized: Running inside a container' missing from stdout/stderr
-containers/docker/TestPids.java                     Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: assertTrue: expected true, was false
-containers/systemd/SystemdMemoryAwarenessTest.java  Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: 'Memory Limit is: 536870912' missing from stdout/stderr
+containers/docker/TestMemoryWithSubgroups.java      Passed. Execution successful
+containers/docker/TestMisc.java                     Passed. Execution successful
+containers/docker/TestPids.java                     Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Limit value 9430 is not accepted as unlimited, log line was [0.051s][trace][os,container] Maximum number of tasks is: 9430
+containers/systemd/SystemdMemoryAwarenessTest.java  Passed. Execution successful
--- test_results/summaryJdkOrigCgv2.txt	2025-10-23 18:52:12.000000000 +0200
+++ test_results/summaryJdkUpdatedCgv2.txt	2025-10-23 18:52:12.000000000 +0200
@@ -4,12 +4,12 @@
 jdk/internal/platform/cgroup/TestCgroupSubsystemController.java    Passed. Execution successful
 jdk/internal/platform/cgroup/TestCgroupSubsystemFactory.java       Passed. Execution successful
 jdk/internal/platform/cgroup/TestSystemSettings.java               Passed. Execution successful
-jdk/internal/platform/docker/TestDockerBasic.java                  Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: 'Memory Limit: 300.00M' missing from stdout/stderr
+jdk/internal/platform/docker/TestDockerBasic.java                  Passed. Execution successful
 jdk/internal/platform/docker/TestDockerCpuMetrics.java             Passed. Execution successful
-jdk/internal/platform/docker/TestDockerMemoryMetrics.java          Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Expected to get exit value of [0], exit value is: [1]
+jdk/internal/platform/docker/TestDockerMemoryMetrics.java          Passed. Execution successful
 jdk/internal/platform/docker/TestDockerMemoryMetricsSubgroup.java  Passed. Execution successful
 jdk/internal/platform/docker/TestGetFreeSwapSpaceSize.java         Passed. Execution successful
-jdk/internal/platform/docker/TestLimitsUpdating.java               Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: 'Runtime.availableProcessors: 2' missing from stdout/stderr
-jdk/internal/platform/docker/TestPidsLimit.java                    Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: assertTrue: expected true, was false
-jdk/internal/platform/docker/TestSystemMetrics.java                Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Expected to get exit value of [0], exit value is: [1]
+jdk/internal/platform/docker/TestLimitsUpdating.java               Passed. Execution successful
+jdk/internal/platform/docker/TestPidsLimit.java                    Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Limit value 9430 is not accepted as unlimited, log line was Maximum Processes Limit: 9430
+jdk/internal/platform/docker/TestSystemMetrics.java                Passed. Execution successful
 jdk/internal/platform/docker/TestUseContainerSupport.java          Passed. Execution successful

kernel 6.14 HWE Cgroup v1

no differences

kernel 6.11 Cgroup v2

One test failed below: jdk/internal/platform/docker/TestDockerMemoryMetrics.java
The test fails intermittently, it is unrelated to this backport: the failcount test gets OOM-killed, likely because the total process allocation is bigger than -Xmx size and the swapping isn't enabled. The test will be skipped when/if JDK-8343340 gets integrated. I noted that the test passes sometimes without JDK-8343340 though.

--- test_results_no_hwe/noHweHotspotOrigCgv2.txt	2025-10-24 01:21:16.000000000 +0200
+++ test_results_no_hwe/noHweHotspotUpdatedCgv2.txt	2025-10-24 01:21:16.000000000 +0200
@@ -3,17 +3,17 @@
 containers/docker/DockerBasicTest.java              Passed. Execution successful
 containers/docker/ShareTmpDir.java                  Passed. Execution successful
 containers/docker/TestCPUAwareness.java             Passed. Execution successful
 containers/docker/TestCPUSets.java                  Passed. Execution successful
 containers/docker/TestContainerInfo.java            Passed. Execution successful
 containers/docker/TestJFREvents.java                Passed. Execution successful
 containers/docker/TestJFRNetworkEvents.java         Passed. Execution successful
 containers/docker/TestJFRWithJMX.java               Passed. Execution successful
 containers/docker/TestJcmd.java                     Passed. Execution successful
 containers/docker/TestJcmdWithSideCar.java          Passed. Execution successful
 containers/docker/TestLimitsUpdating.java           Passed. Execution successful
 containers/docker/TestMemoryAwareness.java          Passed. Execution successful
 containers/docker/TestMemoryWithCgroupV1.java       Passed. Execution successful
 containers/docker/TestMemoryWithSubgroups.java      Passed. Execution successful
 containers/docker/TestMisc.java                     Passed. Execution successful
-containers/docker/TestPids.java                     Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Limit value 9431 is not accepted as unlimited, log line was [0.064s][trace][os,container] Maximum number of tasks is: 9431
+containers/docker/TestPids.java                     Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Limit value 9431 is not accepted as unlimited, log line was [0.051s][trace][os,container] Maximum number of tasks is: 9431
 containers/systemd/SystemdMemoryAwarenessTest.java  Passed. Execution successful
--- test_results_no_hwe/noHweJdkOrigCgv2.txt	2025-10-24 01:21:16.000000000 +0200
+++ test_results_no_hwe/noHweJdkUpdatedCgv2.txt	2025-10-24 01:21:16.000000000 +0200
@@ -1,15 +1,15 @@
 jdk/internal/platform/cgroup/CgroupV1SubsystemControllerTest.java  Passed. Execution successful
 jdk/internal/platform/cgroup/CgroupV2SubsystemControllerTest.java  Passed. Execution successful
 jdk/internal/platform/cgroup/TestCgroupMetrics.java                Passed. Execution successful
 jdk/internal/platform/cgroup/TestCgroupSubsystemController.java    Passed. Execution successful
 jdk/internal/platform/cgroup/TestCgroupSubsystemFactory.java       Passed. Execution successful
 jdk/internal/platform/cgroup/TestSystemSettings.java               Passed. Execution successful
 jdk/internal/platform/docker/TestDockerBasic.java                  Passed. Execution successful
 jdk/internal/platform/docker/TestDockerCpuMetrics.java             Passed. Execution successful
-jdk/internal/platform/docker/TestDockerMemoryMetrics.java          Passed. Execution successful
+jdk/internal/platform/docker/TestDockerMemoryMetrics.java          Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Expected to get exit value of [0], exit value is: [137]
 jdk/internal/platform/docker/TestDockerMemoryMetricsSubgroup.java  Passed. Execution successful
 jdk/internal/platform/docker/TestGetFreeSwapSpaceSize.java         Passed. Execution successful
 jdk/internal/platform/docker/TestLimitsUpdating.java               Passed. Execution successful
 jdk/internal/platform/docker/TestPidsLimit.java                    Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Limit value 9431 is not accepted as unlimited, log line was Maximum Processes Limit: 9431
 jdk/internal/platform/docker/TestSystemMetrics.java                Passed. Execution successful
 jdk/internal/platform/docker/TestUseContainerSupport.java          Passed. Execution successful

kernel 6.11 Cgroup v1

--- test_results_no_hwe/noHweHotspotOrigCgv1.txt	2025-10-24 14:24:27.000000000 +0200
+++ test_results_no_hwe/noHweHotspotUpdatedCgv1.txt	2025-10-24 14:24:27.000000000 +0200
@@ -1,19 +1,19 @@
 containers/cgroup/CgroupSubsystemFactory.java       Passed. Execution successful
 containers/cgroup/TestContainerized.java            Passed. Execution successful
 containers/docker/DockerBasicTest.java              Passed. Execution successful
 containers/docker/ShareTmpDir.java                  Passed. Execution successful
 containers/docker/TestCPUAwareness.java             Passed. Execution successful
 containers/docker/TestCPUSets.java                  Passed. Execution successful
 containers/docker/TestContainerInfo.java            Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Expected to get exit value of [0], exit value is: [127]
 containers/docker/TestJFREvents.java                Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Expected to get exit value of [0], exit value is: [127]
 containers/docker/TestJFRNetworkEvents.java         Passed. Execution successful
 containers/docker/TestJFRWithJMX.java               Passed. Execution successful
 containers/docker/TestJcmd.java                     Passed. Execution successful
 containers/docker/TestJcmdWithSideCar.java          Passed. Execution successful
-containers/docker/TestLimitsUpdating.java           Error. Program `/home/user/work/repos/jdk21u/build/linux-x86_64-server-release/images/jdk/bin/java' timed out (timeout set to 600000ms, elapsed time including timeout handling was 600273ms).
+containers/docker/TestLimitsUpdating.java           Error. Program `/home/user/work/repos/jdk21u/build/linux-x86_64-server-release/images/jdk-updated/bin/java' timed out (timeout set to 600000ms, elapsed time including timeout handling was 600281ms).
 containers/docker/TestMemoryAwareness.java          Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Expected to get exit value of [0], exit value is: [127]
 containers/docker/TestMemoryWithCgroupV1.java       Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Expected to get exit value of [0], exit value is: [127]
 containers/docker/TestMemoryWithSubgroups.java      Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Expected to get exit value of [0], exit value is: [127]
 containers/docker/TestMisc.java                     Passed. Execution successful
 containers/docker/TestPids.java                     Passed. Execution successful
 containers/systemd/SystemdMemoryAwarenessTest.java  Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: 'Memory Limit is: 536870912' missing from stdout/stderr
--- test_results_no_hwe/noHweJdkOrigCgv1.txt	2025-10-24 14:24:27.000000000 +0200
+++ test_results_no_hwe/noHweJdkUpdatedCgv1.txt	2025-10-24 14:24:27.000000000 +0200
@@ -1,15 +1,15 @@
 jdk/internal/platform/cgroup/CgroupV1SubsystemControllerTest.java  Passed. Execution successful
 jdk/internal/platform/cgroup/CgroupV2SubsystemControllerTest.java  Passed. Execution successful
 jdk/internal/platform/cgroup/TestCgroupMetrics.java                Passed. Execution successful
 jdk/internal/platform/cgroup/TestCgroupSubsystemController.java    Passed. Execution successful
 jdk/internal/platform/cgroup/TestCgroupSubsystemFactory.java       Passed. Execution successful
 jdk/internal/platform/cgroup/TestSystemSettings.java               Passed. Execution successful
 jdk/internal/platform/docker/TestDockerBasic.java                  Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Expected to get exit value of [0], exit value is: [127]
 jdk/internal/platform/docker/TestDockerCpuMetrics.java             Passed. Execution successful
 jdk/internal/platform/docker/TestDockerMemoryMetrics.java          Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Expected to get exit value of [0], exit value is: [127]
 jdk/internal/platform/docker/TestDockerMemoryMetricsSubgroup.java  Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Expected to get exit value of [0], exit value is: [127]
 jdk/internal/platform/docker/TestGetFreeSwapSpaceSize.java         Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Expected to get exit value of [0], exit value is: [127]
-jdk/internal/platform/docker/TestLimitsUpdating.java               Error. Program `/home/user/work/repos/jdk21u/build/linux-x86_64-server-release/images/jdk/bin/java' timed out (timeout set to 600000ms, elapsed time including timeout handling was 600296ms).
+jdk/internal/platform/docker/TestLimitsUpdating.java               Error. Program `/home/user/work/repos/jdk21u/build/linux-x86_64-server-release/images/jdk-updated/bin/java' timed out (timeout set to 600000ms, elapsed time including timeout handling was 600254ms).
 jdk/internal/platform/docker/TestPidsLimit.java                    Passed. Execution successful
 jdk/internal/platform/docker/TestSystemMetrics.java                Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Expected to get exit value of [0], exit value is: [127]
 jdk/internal/platform/docker/TestUseContainerSupport.java          Passed. Execution successful


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • JDK-8347811 needs maintainer approval
  • JDK-8349988 needs maintainer approval

Issues

  • JDK-8349988: Change cgroup version detection logic to not depend on /proc/cgroups (Sub-task - P3 - Requested)
  • JDK-8347811: Container detection code for cgroups v2 should use cgroup.controllers (Enhancement - P3 - Requested)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk21u-dev.git pull/2390/head:pull/2390
$ git checkout pull/2390

Update a local copy of the PR:
$ git checkout pull/2390
$ git pull https://git.openjdk.org/jdk21u-dev.git pull/2390/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 2390

View PR using the GUI difftool:
$ git pr show -t 2390

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk21u-dev/pull/2390.diff

Using Webrev

Link to Webrev Comment

…/cgroups

8347811: Container detection code for cgroups v2 should use cgroup.controllers

Backport-of: 9c5ed23eac7470f56d498e9c4d3c51c2f80fd571
@bridgekeeper
Copy link

bridgekeeper bot commented Oct 24, 2025

👋 Welcome back schernyshev! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Oct 24, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot changed the title Backport 9c5ed23eac7470f56d498e9c4d3c51c2f80fd571 8349988: Change cgroup version detection logic to not depend on /proc/cgroups Oct 24, 2025
@openjdk
Copy link

openjdk bot commented Oct 24, 2025

This backport pull request has now been updated with issues from the original commit.

@openjdk openjdk bot added backport Port of a pull request already in a different code base clean Identical backport; no merge resolution required labels Oct 24, 2025
@openjdk
Copy link

openjdk bot commented Oct 24, 2025

⚠️ @sercher This change is now ready for you to apply for maintainer approval. This can be done directly in each associated issue or by using the /approval command.

@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 24, 2025
@mlbridge
Copy link

mlbridge bot commented Oct 24, 2025

Webrevs

@sercher
Copy link
Contributor Author

sercher commented Oct 24, 2025

/approval request This improves container detection in newer kernels such as 6.14 HWE

@openjdk
Copy link

openjdk bot commented Oct 24, 2025

@sercher
8349988: The approval request has been created successfully.
8347811: The approval request has been created successfully.

@openjdk openjdk bot added the approval Requires approval; will be removed when approval is received label Oct 24, 2025
Copy link
Contributor

@fitzsim fitzsim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a reviewer. This looks good to me.

@fitzsim
Copy link
Contributor

fitzsim commented Oct 28, 2025

Is the new result for containers/docker/TestPids.java:

Execution failed: `main' threw exception: java.lang.RuntimeException: Limit value 9430 is not accepted as unlimited, log line was [0.051s][trace][os,container] Maximum number of tasks is: 9430

expected? If so, is there a bug filed for fixing that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval Requires approval; will be removed when approval is received backport Port of a pull request already in a different code base clean Identical backport; no merge resolution required rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

2 participants