Skip to content

Conversation

jerboaa
Copy link
Contributor

@jerboaa jerboaa commented Oct 10, 2025

Please review this revised version of getting rid of jlong and julong in internal HotSpot code. The single remaining usage is using os::elapsed_counter() which I think is still ok. This refactoring is for the container detection code to (mostly) do away with negative return values.

It gets rid of the trifold-use of return value: 1.) error, 2) unlimited values 3) actual numbers/values/limits. Instead, all container related values are now being read from the interface files as uint64_t and afterwards interpreted in the way that make sense for the API implementations. For example, cpu values will essentially be treated as ints as before, potentially returning a negative value -1 for unlimited. For memory sizes the type physical_memory_size_type has been chosen. When there is no limit for a specific memory size a value value_unlimited is being returned.

All error cases have been changed to returning false in the API functions (and no value is being set in the passed in reference for the value). The effect of this is that all container related functions now return a bool and require a reference to be passed in for the value that is being asked for.

All usages of the API have been changed to use the revised API. There is no more usages for OSCONTAINER_ERROR (`-2) in HotSpot code.

While working on this, I've noticed that there are still some calls deep in the cgroup subsystem code to query "machine" info (e.g. os::Linux::active_processor_count()). I've filed JDK-8369503 to get this cleaned-up as this patch was already getting large.

Testing (looking good):

  • GHA
  • All container tests (including problem listed ones) on Linux x86_64 with cg v1 and cg v2. See this comment below.
  • Some ad-hoc manual testing in containers using JFR (jdk.SwapSpace event) and VM.info diagnostic command.

Thoughts? Opinions?


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8365606: Container code should not be using jlong/julong (Enhancement - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27743/head:pull/27743
$ git checkout pull/27743

Update a local copy of the PR:
$ git checkout pull/27743
$ git pull https://git.openjdk.org/jdk.git pull/27743/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27743

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27743.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 10, 2025

👋 Welcome back sgehwolf! 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 10, 2025

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

@openjdk
Copy link

openjdk bot commented Oct 10, 2025

@jerboaa The following label will be automatically applied to this pull request:

  • hotspot

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@jerboaa
Copy link
Contributor Author

jerboaa commented Oct 10, 2025

Testing details:

cgroup v2 F42 (docker):

Passed: containers/cgroup/CgroupSubsystemFactory.java
Passed: containers/cgroup/TestContainerized.java
Passed: containers/docker/DockerBasicTest.java
Passed: containers/docker/ShareTmpDir.java
Passed: containers/docker/TestContainerInfo.java
Passed: containers/docker/TestCPUAwareness.java
Passed: containers/docker/TestCPUSets.java
Passed: containers/docker/TestJcmd.java
Passed: containers/docker/TestJcmdWithSideCar.java
Passed: containers/docker/TestJFREvents.java
Passed: containers/docker/TestJFRNetworkEvents.java
Passed: containers/docker/TestJFRWithJMX.java
Passed: containers/docker/TestLimitsUpdating.java
Passed: containers/docker/TestMemoryAwareness.java
Passed: containers/docker/TestMemoryWithCgroupV1.java
Passed: containers/docker/TestMemoryWithSubgroups.java
Passed: containers/docker/TestMisc.java
Passed: containers/docker/TestPids.java
Passed: containers/systemd/SystemdMemoryAwarenessTest.java
Passed: jdk/internal/platform/cgroup/CgroupV1SubsystemControllerTest.java
Passed: jdk/internal/platform/cgroup/CgroupV2SubsystemControllerTest.java
Passed: jdk/internal/platform/cgroup/TestCgroupMetrics.java
Passed: jdk/internal/platform/cgroup/TestCgroupSubsystemController.java
Passed: jdk/internal/platform/cgroup/TestCgroupSubsystemFactory.java
Passed: jdk/internal/platform/cgroup/TestSystemSettings.java
Passed: jdk/internal/platform/docker/TestDockerBasic.java
Passed: jdk/internal/platform/docker/TestDockerCpuMetrics.java
Passed: jdk/internal/platform/docker/TestDockerMemoryMetrics.java
Passed: jdk/internal/platform/docker/TestDockerMemoryMetricsSubgroup.java
Passed: jdk/internal/platform/docker/TestGetFreeSwapSpaceSize.java
Passed: jdk/internal/platform/docker/TestLimitsUpdating.java
Passed: jdk/internal/platform/docker/TestPidsLimit.java
Passed: jdk/internal/platform/docker/TestSystemMetrics.java
Passed: jdk/internal/platform/docker/TestUseContainerSupport.java
Test results: passed: 34

cgroup v2 F39 (docker):

Passed: containers/cgroup/CgroupSubsystemFactory.java
Passed: containers/cgroup/TestContainerized.java
Passed: containers/docker/DockerBasicTest.java
Passed: containers/docker/ShareTmpDir.java
Passed: containers/docker/TestContainerInfo.java
Passed: containers/docker/TestCPUAwareness.java
Passed: containers/docker/TestCPUSets.java
Passed: containers/docker/TestJcmd.java
Passed: containers/docker/TestJcmdWithSideCar.java
Passed: containers/docker/TestJFREvents.java
Passed: containers/docker/TestJFRNetworkEvents.java
Passed: containers/docker/TestJFRWithJMX.java
Passed: containers/docker/TestLimitsUpdating.java
Passed: containers/docker/TestMemoryAwareness.java
Passed: containers/docker/TestMemoryWithCgroupV1.java
Passed: containers/docker/TestMemoryWithSubgroups.java
Passed: containers/docker/TestMisc.java
Passed: containers/docker/TestPids.java
Passed: containers/systemd/SystemdMemoryAwarenessTest.java
Test results: passed: 19

cgroup v1 RHEL 8 (podman):

Passed: containers/cgroup/CgroupSubsystemFactory.java
Passed: containers/cgroup/TestContainerized.java
Passed: containers/docker/DockerBasicTest.java
Passed: containers/docker/ShareTmpDir.java
Passed: containers/docker/TestContainerInfo.java
Passed: containers/docker/TestCPUAwareness.java
Passed: containers/docker/TestCPUSets.java
Passed: containers/docker/TestJcmd.java
Passed: containers/docker/TestJcmdWithSideCar.java
Passed: containers/docker/TestJFREvents.java
Passed: containers/docker/TestJFRNetworkEvents.java
Passed: containers/docker/TestJFRWithJMX.java
Passed: containers/docker/TestLimitsUpdating.java
Passed: containers/docker/TestMemoryAwareness.java
Passed: containers/docker/TestMemoryWithCgroupV1.java
Passed: containers/docker/TestMemoryWithSubgroups.java
Passed: containers/docker/TestMisc.java
Passed: containers/docker/TestPids.java
Passed: containers/systemd/SystemdMemoryAwarenessTest.java
Test results: passed: 19; skipped: 1

Note: The skipped test on RHEL 8 is TestContainerInfo which checks cgv2 functionality only.

@jerboaa
Copy link
Contributor Author

jerboaa commented Oct 10, 2025

/label add hotspot-jfr

@openjdk
Copy link

openjdk bot commented Oct 10, 2025

@jerboaa
The hotspot-jfr label was successfully added.

@jerboaa jerboaa marked this pull request as ready for review October 10, 2025 13:33
@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 10, 2025
@mlbridge
Copy link

mlbridge bot commented Oct 10, 2025

Webrevs

@jerboaa
Copy link
Contributor Author

jerboaa commented Oct 10, 2025

GHA test failure on Windows x64 is unrelated (this is a Linux only patch):
gc/shenandoah/oom/TestThreadFailure

@dholmes-ora
Copy link
Member

There seems to be some collision here with JDK-8367319

@jerboaa
Copy link
Contributor Author

jerboaa commented Oct 13, 2025

There seems to be some collision here with JDK-8367319

Thanks, yes, I'm aware. We'll resolve conflicts once we know which one goes in first.

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

Development

Successfully merging this pull request may close these issues.

2 participants