-
Notifications
You must be signed in to change notification settings - Fork 148
8354922: ZGC: Use MAP_FIXED_NOREPLACE when reserving memory #2475
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
Conversation
Reviewed-by: aboldtch, eosterlund
|
👋 Welcome back schernyshev! A progress list of the required criteria for merging this PR into |
|
@sercher 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 36 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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@stefank) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
|
This backport pull request has now been updated with issue from the original commit. |
stefank
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.
This looks good to me.
|
|
|
Thanks @stefank |
|
/approval request This fixes ZGC on systems that do not honor the address hint when mmapping memory without MAP_FIXED |
|
@sercher This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a |
|
/integrate |
|
/sponsor |
|
Going to push as commit ab298c2.
Your commit was automatically rebased without conflicts. |
|
@phohensee @sercher Pushed as commit ab298c2. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Hi all,
Please review the backport of JDK-8354922 to JDK 21.
There are versions of the Linux kernel that do not honor the address hint when mmapping memory without MAP_FIXED, that clobbers the older mappings overlapped with the requested range. A safer MAP_FIXED_NOREPLACE flag is used with ZGC since Java 25.
JDK 21 crashes with -XX:+UseZGC with RANDMMAP [1] kernel patch enabled, while JDK 25 works as expected.
ZGC relies on kernel that respects address hints in mmap system call, which is not the case with RANDMMAP enabled kernels. ZVirtualMemoryManager::pd_reserve() always returns false at line 50 because the mmap returned value never matches the requested address.
jdk21u-dev/src/hotspot/os/posix/gc/z/zVirtualMemory_posix.cpp
Lines 40 to 51 in 634d3fa
Since Linux 4.17 there's MAP_FIXED_NOREPLACE flag in mmap, that satisfies the
addrrequests and reports failure when the requested range overlaps a pre-existing mapping.The backport isn't clean. JDK 21 doesn't have JDK-8350441 that renamed zVirtualMemory_posix.cpp to zVirtualMemoryManager_posix.cpp, and JDK-8341692 that removed non-generational mode in ZGC. In absense of JDK-8341692 the same approach was taken on gc/x/ version of pd_reserve().
It is also proposed to backport JDK-8313319 that prevents unnecessary mmap-munmap cycle, that will follow in a separate PR (#2476 ).
[1] https://pax.grsecurity.net/docs/randmmap.txt
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk21u-dev.git pull/2475/head:pull/2475$ git checkout pull/2475Update a local copy of the PR:
$ git checkout pull/2475$ git pull https://git.openjdk.org/jdk21u-dev.git pull/2475/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 2475View PR using the GUI difftool:
$ git pr show -t 2475Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk21u-dev/pull/2475.diff
Using Webrev
Link to Webrev Comment