Skip to content

Conversation

@jerboaa
Copy link
Contributor

@jerboaa jerboaa commented Jan 10, 2025

Please review this small change to make the cpuset cgroups controller optional as far as the JDK is concerned. The rationale is that:

  • Some distributions now don't have it enabled by default (e.g. Fedora 41), which breaks automatic container detection logic.
  • CPU limits enforced with --cpuset-cpus is reflected with the sched_getaffinity system call and, thus, the controller doesn't need to be mandatory. The current failure to detect the controller results in no container limits being detected with is bad.

The fix is rather simple. Make cpuset controller look-up from /proc/cgroups optional (like the pids controller) and continue. OSContainer::active_processor_count() still behaves as before (should there be a cpuset limit) as it's covered by os::Linux::active_processor_count() which serves as the upper bound of other container cpu limits.

While at it, I've also fixed the logging bug by re-arranging the const char* values. cpuset is index 0, cpu is index 1.

Testing:

  • GHA
  • Linux container tests in test/hotspot/jtreg/containers on Linux cgroups v1 and cgroups v2 as well as on an affected system (F41 on cg v2). All pass.

Thoughts?


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

Warning

 ⚠️ Found leading lowercase letter in issue title for 8347129: cpuset cgroups controller is required for no good reason

Issue

  • JDK-8347129: cpuset cgroups controller is required for no good reason (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 23037

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 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 Jan 10, 2025

@jerboaa 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:

8347129: cpuset cgroups controller is required for no good reason

Reviewed-by: stuefe, asmehra

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 65 new commits pushed to the master branch:

  • 06ff4c1: 8347146: Convert IncludeLocalesPluginTest to use JUnit
  • db76f47: 8347720: [BACKOUT] Portable implementation of FORBID_C_FUNCTION and ALLOW_C_FUNCTION
  • e6902cf: 8323740: java.lang.ExceptionInInitializerError when trying to load XML classes in wrong order
  • a01e92c: 8347724: Replace SIZE_FORMAT in jfr directory
  • d002933: 8347286: (fs) Remove some extensions from java/nio/file/Files/probeContentType/Basic.java
  • d532019: 8347143: [aix] Fix strdup use in os::dll_load
  • dfd215b: 8347376: tools/jlink/runtimeImage/JavaSEReproducibleTest.java and PackagedModulesVsRuntimeImageLinkTest.java failed after JDK-8321413
  • a49f833: 8346045: Cleanup of security library tests calling Security Manager APIs
  • 56c7800: 8347381: Upgrade jQuery UI to version 1.14.1
  • 1c64a45: 8347501: Make static-launcher fails after JDK-8346669
  • ... and 55 more: https://git.openjdk.org/jdk/compare/1f457977f062e4ed219c6fa0fe26cb42acaf4bf2...master

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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 10, 2025
@openjdk
Copy link

openjdk bot commented Jan 10, 2025

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

  • hotspot-runtime

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.

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Jan 10, 2025
@mlbridge
Copy link

mlbridge bot commented Jan 10, 2025

Webrevs

@zapster
Copy link
Contributor

zapster commented Jan 14, 2025

Not a reviewer, but I've tested your change in the context of https://github.com/oracle/graal native image and it fixes the problems that we were seeing. Thanks!

@jerboaa
Copy link
Contributor Author

jerboaa commented Jan 14, 2025

@dholmes-ora @tstuefe Could you please help review this simple change? Thanks in advance!

Copy link
Member

@tstuefe tstuefe left a comment

Choose a reason for hiding this comment

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

Sorry, just saw that now. Okay.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 14, 2025
@jerboaa
Copy link
Contributor Author

jerboaa commented Jan 14, 2025

Thanks for the review!

@ashu-mehra
Copy link
Contributor

@jerboaa Should this block be updated to not return false as the cpuset is now an optional subsystem.

if (!cg_infos[CPUSET_IDX]._data_complete) {
log_debug(os, container)("Required cgroup v1 cpuset subsystem not found");
cleanup(cg_infos);
*flags = INVALID_CGROUPS_V1;
return false;
}

@jerboaa
Copy link
Contributor Author

jerboaa commented Jan 14, 2025

@jerboaa Should this block be updated to not return false as the cpuset is now an optional subsystem.

if (!cg_infos[CPUSET_IDX]._data_complete) {
log_debug(os, container)("Required cgroup v1 cpuset subsystem not found");
cleanup(cg_infos);
*flags = INVALID_CGROUPS_V1;
return false;
}

@ashu-mehra Thanks for looking at it!

I'm in two minds about this. Why? a) cgroups v1 is becoming increasingly legacy b) the chance that an old v1 system would no longer enable cpusets controller seems unlikely. So while it seems consistent to remove this for cg v1 too, it's unlikely that such a system exists. For example Fedora 41 where this has been observed no longer supports cg v1. I'd expect for other distros to follow. New distros will likely only support cg v2.

For those reasons I'd be inclined to keep the patch as-is as it would be less risky for the cg v1 version.

Thoughts?

@ashu-mehra
Copy link
Contributor

@jerboaa Thanks for the explanation. I agree with you. I think its fine to keep cg v1 as is.

Copy link
Contributor

@ashu-mehra ashu-mehra left a comment

Choose a reason for hiding this comment

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

looks good.

@jerboaa
Copy link
Contributor Author

jerboaa commented Jan 14, 2025

/integrate

@openjdk
Copy link

openjdk bot commented Jan 14, 2025

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

  • 4c30933: 8346971: [ubsan] psCardTable.cpp:131:24: runtime error: large index is out of bounds
  • 06ff4c1: 8347146: Convert IncludeLocalesPluginTest to use JUnit
  • db76f47: 8347720: [BACKOUT] Portable implementation of FORBID_C_FUNCTION and ALLOW_C_FUNCTION
  • e6902cf: 8323740: java.lang.ExceptionInInitializerError when trying to load XML classes in wrong order
  • a01e92c: 8347724: Replace SIZE_FORMAT in jfr directory
  • d002933: 8347286: (fs) Remove some extensions from java/nio/file/Files/probeContentType/Basic.java
  • d532019: 8347143: [aix] Fix strdup use in os::dll_load
  • dfd215b: 8347376: tools/jlink/runtimeImage/JavaSEReproducibleTest.java and PackagedModulesVsRuntimeImageLinkTest.java failed after JDK-8321413
  • a49f833: 8346045: Cleanup of security library tests calling Security Manager APIs
  • 56c7800: 8347381: Upgrade jQuery UI to version 1.14.1
  • ... and 56 more: https://git.openjdk.org/jdk/compare/1f457977f062e4ed219c6fa0fe26cb42acaf4bf2...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jan 14, 2025

@jerboaa Pushed as commit 2de71d0.

💡 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

hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

4 participants