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.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 - Approved)
  • JDK-8347811: Container detection code for cgroups v2 should use cgroup.controllers (Enhancement - P3 - Approved)

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

@sercher This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8349988: Change cgroup version detection logic to not depend on /proc/cgroups
8347811: Container detection code for cgroups v2 should use cgroup.controllers

Reviewed-by: fitzsim

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 53 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@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?

@sercher
Copy link
Contributor Author

sercher 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

No it's not new. If failed with kernel 6.11 cgroup v2 before the patch too. The limit was simply undetected in 6.14 HWE.

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

Looks like it's tracked under JDK-8356277

@sercher
Copy link
Contributor Author

sercher commented Oct 28, 2025

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

Thanks!

@jerboaa
Copy link
Contributor

jerboaa commented Oct 30, 2025

Looks like it's tracked under JDK-8356277

I suggest to configure your system to increase the max pids so the test passes.

@jerboaa
Copy link
Contributor

jerboaa commented Oct 30, 2025

/approve yes

@openjdk
Copy link

openjdk bot commented Oct 30, 2025

@jerboaa
8349988: The approval request has been approved.
8347811: The approval request has been approved.

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed approval Requires approval; will be removed when approval is received labels Oct 30, 2025
@sercher
Copy link
Contributor Author

sercher commented Oct 30, 2025

Thank you Severin. The test passes with the increased max pids.

@sercher
Copy link
Contributor Author

sercher commented Oct 30, 2025

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Oct 30, 2025
@openjdk
Copy link

openjdk bot commented Oct 30, 2025

@sercher
Your change (at version 0275d34) is now ready to be sponsored by a Committer.

@phohensee
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Oct 31, 2025

Going to push as commit dd842c4.
Since your change was applied there have been 55 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Oct 31, 2025
@openjdk openjdk bot closed this Oct 31, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Oct 31, 2025
@openjdk
Copy link

openjdk bot commented Oct 31, 2025

@phohensee @sercher Pushed as commit dd842c4.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

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

Labels

backport Port of a pull request already in a different code base clean Identical backport; no merge resolution required integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

4 participants