-
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
base: master
Are you sure you want to change the base?
Conversation
Reviewed-by: aboldtch, eosterlund
|
👋 Welcome back schernyshev! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
|
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 |
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