-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8346005: Parallel: Incorrect page size calculation with UseLargePages #26700
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
|
👋 Welcome back ayang! A progress list of the required criteria for merging this PR into |
|
@albertnetymk 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 97 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 |
|
@albertnetymk 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. |
|
/cc hotspot-gc |
|
@albertnetymk |
Webrevs
|
|
Minor updates after JDK-8366434, as the page-size of reserved-memory reflects the intended/actual OS page-size, when using transparent huge pages. |
|
/cc hotspot-gc |
|
/touch |
|
@albertnetymk |
|
@albertnetymk The pull request is being re-evaluated and the inactivity timeout has been reset. |
jsikstro
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.
Reviewing this is taking some time, so this is not a full review yet, but so far I have some comments:
Why do we need the dance with Parallel being able to set a specific desired_page_size in Universe::reserve_heap()? Maybe I'm wrong, but would it not work to disable UseLargePages early and not have specific logic for Parallel?
| // ReservedSpace passed to initialize() must be aligned to this value. | ||
| const size_t _alignment; | ||
|
|
||
| // OS page size used. If using transparent large pages, it's the desired large page-size. |
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.
I'd change this to say Transparent Huge Pages instead.
|
|
||
| public: | ||
| protected: | ||
| size_t page_size() const { return _page_size; } |
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.
We should vertically align this with the other blocks.
|
|
||
| if (page_sz == os::vm_page_size()) { | ||
| log_warning(gc, heap)("MinHeapSize (%zu) must be large enough for 4 * page-size; Disabling UseLargePages for heap", MinHeapSize); | ||
| return; |
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.
Wouldn't it make sense to do FLAG_SET_ERGO(UseLargepages, false) here since it is effectively disabled.
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.
There are non-heap uses of UseLargePages as well. Here we concluded heap can't use large-page, but other systems still can.
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.
I see, thank you.
| assert(is_power_of_2((intptr_t)page_sz), "must be a power of 2"); | ||
| size_t new_alignment = align_up(page_sz, SpaceAlignment); | ||
| // Space is largepage-aligned. | ||
| size_t new_alignment = page_sz; |
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.
To me it looks like new_alignment will always be different from SpaceAlignment here. We could simplify this to the following:
SpaceAlignment = page_sz;
// Redo everything from the start
initialize_heap_flags_and_sizes_one_pass();
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.
To me it looks like new_alignment will always be different from SpaceAlignment here.
Why so? (I know the default value of SpaceAlignment is 64K*8 bytes, which is not a common large-page-size, but that info is not directly accessible in this context.)
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.
We discussed this offline, but if default_space_alignment() ever coincided with a Large page size, say 2MB, and 2MB large pages are chosen, SpaceAlignment would still be equal to default_space_alignment() and we would end up reserving small pages in ParallelScavengeHeap::initialize().
albertnetymk
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.
Why do we need the dance with Parallel being able to set a specific desired_page_size in Universe::reserve_heap()?
Because heap contains subspaces (eden,from,to,old) which needs to be larger than a OS-page in Parallel. Maybe this doesn't have to be this way, but that's what Parallel NUMA relies on currently. It would be much more invasive to change that.
|
|
||
| if (page_sz == os::vm_page_size()) { | ||
| log_warning(gc, heap)("MinHeapSize (%zu) must be large enough for 4 * page-size; Disabling UseLargePages for heap", MinHeapSize); | ||
| return; |
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.
There are non-heap uses of UseLargePages as well. Here we concluded heap can't use large-page, but other systems still can.
| assert(is_power_of_2((intptr_t)page_sz), "must be a power of 2"); | ||
| size_t new_alignment = align_up(page_sz, SpaceAlignment); | ||
| // Space is largepage-aligned. | ||
| size_t new_alignment = page_sz; |
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.
To me it looks like new_alignment will always be different from SpaceAlignment here.
Why so? (I know the default value of SpaceAlignment is 64K*8 bytes, which is not a common large-page-size, but that info is not directly accessible in this context.)
|
/contributor add jsikstro |
|
@albertnetymk |
jsikstro
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.
I have a few small comments, but I think this looks pretty good now.
| void increment_samples_count() { ++_samples_count; } | ||
|
|
||
| size_t _base_space_size; | ||
| void set_base_space_size(size_t v) { _base_space_size = v; } |
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.
These are unused.
| } else { | ||
| if (i < lgrp_spaces()->length() - 1) { // Middle chunks | ||
| MutableSpace *ps = lgrp_spaces()->at(i - 1)->space(); | ||
| new_region = MemRegion(ps->end(), | ||
| ps->end() + (chunk_byte_size >> LogHeapWordSize)); | ||
| chunk_byte_size >> LogHeapWordSize); | ||
| } else { // Top chunk | ||
| MutableSpace *ps = lgrp_spaces()->at(i - 1)->space(); | ||
| new_region = MemRegion(ps->end(), end()); | ||
| } | ||
| } |
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 is technically fine, but maybe we can combine the else and the if to something like below to fit better with the comments?
if (i == 0) { // Bottom chunk
...
} else if (i < lgrp_spaces()->length() - 1) { // Middle chunks
...
} else { // Top chunk
...
}
|
Thanks for review. /integrate |
|
Going to push as commit 2be273f.
Your commit was automatically rebased without conflicts. |
|
@albertnetymk Pushed as commit 2be273f. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Refactor the heap-space and OS memory interface code to clearly separate two related but distinct concepts:
alignmentandos-page-size. These are now represented as two fields inPSVirtualSpace.The parallel heap consists of four spaces: old, eden, from, and to. The first belongs to the old generation, while the latter three belong to the young generation.
The size of any space is always aligned to
alignment, which also determines the unit for resizing. To keep the implementation simple while allowing flexible per-space commit and uncommit operations, each space must contain at least one OS page. As a result,alignmentis always greater than or equal toos-page-size.When using explicit large pages -- which require pre-allocating large pages before the VM starts -- the actual OS page size is not known until the heap has been reserved. The additional logic in
ParallelScavengeHeap::initializedetects the OS page size in use and adjustsalignmentif necessary.Test: tier1–8
Progress
Issue
Reviewers
Contributors
<jsikstro@openjdk.org>Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26700/head:pull/26700$ git checkout pull/26700Update a local copy of the PR:
$ git checkout pull/26700$ git pull https://git.openjdk.org/jdk.git pull/26700/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26700View PR using the GUI difftool:
$ git pr show -t 26700Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26700.diff
Using Webrev
Link to Webrev Comment