Skip to content

8349988: Change cgroup version detection logic to not depend on /proc/cgroups#3177

Open
jmtd wants to merge 2 commits intoopenjdk:masterfrom
jmtd:8349988-11u
Open

8349988: Change cgroup version detection logic to not depend on /proc/cgroups#3177
jmtd wants to merge 2 commits intoopenjdk:masterfrom
jmtd:8349988-11u

Conversation

@jmtd
Copy link
Copy Markdown

@jmtd jmtd commented Mar 23, 2026

This is a backport of an improvement to cgroup detection logic. This fixes mis-detection on some systems e.g. Debian and Ubuntu systems, or systems running a recent enough mainline kernel which no longer propagates the older /proc/cgroups file with necessary controllers.

This wasn't clean: there are a few nullptr to NULL substitutions (in the second commit).

I worked from Severin's 17u backport of 8349988.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • JDK-8347811 needs maintainer approval
  • Change must be properly reviewed (2 reviews required, with at least 2 Reviewers)
  • 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/jdk11u-dev.git pull/3177/head:pull/3177
$ git checkout pull/3177

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3177

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

Using diff file

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

Using Webrev

Link to Webrev Comment

jerboaa and others added 2 commits March 23, 2026 08:29
@bridgekeeper
Copy link
Copy Markdown

bridgekeeper bot commented Mar 23, 2026

👋 Welcome back jdowland! 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
Copy Markdown

openjdk bot commented Mar 23, 2026

❗ 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 dd842c440e3f50028fc991b29ea096f0e64e967b 8349988: Change cgroup version detection logic to not depend on /proc/cgroups Mar 23, 2026
@openjdk
Copy link
Copy Markdown

openjdk bot commented Mar 23, 2026

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

@openjdk openjdk bot added the backport Port of a pull request already in a different code base label Mar 23, 2026
@jmtd jmtd marked this pull request as ready for review March 24, 2026 08:31
@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 24, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge bot commented Mar 24, 2026

Webrevs

Copy link
Copy Markdown
Member

@phohensee phohensee left a comment

Choose a reason for hiding this comment

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

Indeed clean except for nullptr -> NULL.

@openjdk
Copy link
Copy Markdown

openjdk bot commented Mar 24, 2026

⚠️ @jmtd 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.

@jmtd
Copy link
Copy Markdown
Author

jmtd commented Mar 25, 2026

/approval request backport of an improvement to cgroup detection logic. important for newer kernels which do not populate /proc/cgroups with the required information. not clean, small number of fixups in second commit.

@openjdk
Copy link
Copy Markdown

openjdk bot commented Mar 25, 2026

@jmtd
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 Mar 25, 2026
@gnu-andrew
Copy link
Copy Markdown
Member

/reviewers 2 reviewer

@openjdk
Copy link
Copy Markdown

openjdk bot commented Apr 3, 2026

@gnu-andrew
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 2 Reviewers).

Copy link
Copy Markdown
Member

@gnu-andrew gnu-andrew left a comment

Choose a reason for hiding this comment

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

This mostly looks ok. I spotted three minor issues:

  • In changing the section which reads /proc/cgroups, part of JDK-8238161: "use os::fopen in HS code where possible" is inadvertently introduced by changing cgroups = fopen(proc_cgroups, "r"); to os::fopen(controllers_file, "r"). As there are no cases of os::fopen in this file in 11u at present, I would stick with fopen here rather than introducing a single usage while the rest of the file is using fopen.
  • Around that same section, a double space in the comment after controllers and before If not is reduced to single. It would be good to keep this the same as 21u.
  • I was confused by the copyright header change to 2025 in cgroupSubsystem_linux.cpp for some time. We don't generally update copyright headers as part of backports to reduce future friction, but this isn't that either; it's 2026 and only that one file is updated, while all are pre-2025 in 11u. Then I saw the fclose that comes from JDK-8354878 along with this header change. That needs to be credited using the issue command.

The first two of these seem to stem from the 17u backport. I didn't realise at first that I was looking at the 25u version to compare, but I think it would still be good to fix these trivial issues here, even if we're now stuck with them in the 17u backport. Clearly I didn't look at that one closely enough at the time.

The third seems to come from the fact that you referenced the 25u commit in your 'Backport x' commit and so Skara hasn't picked up the other issue. That should be easily fixed with the appropriate issue command.

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 rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

4 participants