RFR: 8369503: [Linux] Move machine-specific queries to the OSContainer layer
Casper Norrbin
cnorrbin at openjdk.org
Tue Jan 13 11:03:26 UTC 2026
Hi everyone,
In #27470, we removed most calls up to `os::Linux` from the container/cgroup layer. This PR finishes that work by removing the last few tricky ones. We had one call in `CgroupSubsystem::active_processor_count` and two calls in `CgroupUtil::adjust_controller`. These were harder to untangle because the call in `active_processor_count` was guarded by a cache, and `adjust_controller` was called in the v1/v2 controller constructors.
`CgroupSubsystem::active_processor_count` now takes a supplier function for the host CPU count, provided from `OSContainer`. The cache still decides if we call the supplied function, so we keep existing caching functionality.
For hierarchy adjustments, I moved the calls out of the cgroup constructors and into `OSContainer`'s initialization, with a new used helper function `CgroupSubsystem::adjust_controllers` that adjusts all controllers. After creating the cgroup subsystem, we adjust the controllers once from `OSContainer`, instead of doing it as the last step of the creation.
As a result from these changes, cgroup code no longer needs to include or call `os::Linux` functions.
Testing:
- Oracle tiers 1-5
- Local container tests on cgroup v1 and v2 on both Podman and Docker
-------------
Commit messages:
- move os::linux calls out of cgroups
Changes: https://git.openjdk.org/jdk/pull/29188/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29188&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8369503
Stats: 45 lines in 8 files changed: 12 ins; 8 del; 25 mod
Patch: https://git.openjdk.org/jdk/pull/29188.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/29188/head:pull/29188
PR: https://git.openjdk.org/jdk/pull/29188
More information about the hotspot-runtime-dev
mailing list