-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8292984: Refactor internal container-related interfaces for clarity #27470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8292984: Refactor internal container-related interfaces for clarity #27470
Conversation
|
👋 Welcome back cnorrbin! A progress list of the required criteria for merging this PR into |
|
@caspernorrbin 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: 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 39 new commits pushed to the
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 |
|
@caspernorrbin The following label will be automatically applied to this pull request:
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
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, but should probably wait until JDK-8367485 is integrated.
|
/reviewers 2 |
Thank you for reviewing! I've now merged those changes in. |
| julong phys_mem = static_cast<julong>(os::Linux::physical_memory()); | ||
| log_trace(os, container)("total physical memory: " JULONG_FORMAT, phys_mem); | ||
| jlong mem_limit = contrl->controller()->read_memory_limit_in_bytes(phys_mem); | ||
| jlong mem_limit = contrl->controller()->read_memory_limit_in_bytes(upper_bound); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removes the logging at the trace level for the upper bound. Intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it was intentional. Both cgroup v1/v2 already log the upper bound in read_memory_limit_in_bytes() at debug level, along with more information. It felt unnecessary logging the same value twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK.
jerboaa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine.
fisk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
|
Thank you for the reviews! /integrate |
|
Going to push as commit 5252262.
Your commit was automatically rebased without conflicts. |
|
@caspernorrbin Pushed as commit 5252262. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Hi everyone,
The current memory-related code paths in Linux are unclear and convoluted, with responsibilities and data flow crossing between
os::Linuxand various container-related layers.For example, consider the call sequence for
os::available_memory():This structure is difficult to follow. Calls move between
os::Linuxand container subsystems in a confusing manner. Ideally, each component should be responsible only for its relevant functionality:os::Linuxshould focus solely on actual machine memory values.CgroupSubsystemshould focus exclusively on cgroup memory limits.oslayer, based on whether the environment is containerized.A revised structure separates these responsibilities:
With these changes:
os::Linuxonly retrieves machine values.CgroupSubsystemworks exclusively with cgroup limits.OSContainerfetches and passes bounds for the cgroup values.oslayer.The concrete code changes include:
os::Linux::{available/free}_memory()toos:{available/free}_memory(), soos::Linuxnow only deals with machine values (was already the case foros::physical_memory()).os::Linux::available_memory_in_container()toOSContainerinstead, removing container-specific logic fromos::Linux. Also refactored to use the new bool and reference interface introduced in JDK-8357086.CgroupSubsystemtoOSContainer, and abstractingCgroupSubsystemto use more generic limits (e.g.upper_mem_bound) instead of a direct system reference (e.g.host_mem).Note: I intentionally kept the
julongparameter types unchanged. I believe it's better to update all types simultaneously in JDK-8365606 instead to ensure the change is complete and consistent.Testing:
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27470/head:pull/27470$ git checkout pull/27470Update a local copy of the PR:
$ git checkout pull/27470$ git pull https://git.openjdk.org/jdk.git pull/27470/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 27470View PR using the GUI difftool:
$ git pr show -t 27470Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27470.diff
Using Webrev
Link to Webrev Comment