JDK-8257588: Make os::_page_sizes a bitmask#1522
JDK-8257588: Make os::_page_sizes a bitmask#1522tstuefe wants to merge 6 commits intoopenjdk:masterfrom
Conversation
|
👋 Welcome back stuefe! A progress list of the required criteria for merging this PR into |
|
@tstuefe |
Webrevs
|
src/hotspot/share/runtime/os.cpp
Outdated
| if (v2 == 0) { | ||
| return 0; | ||
| } | ||
| while ((v2 & 1) == 0) { |
There was a problem hiding this comment.
Maybe the count_trailing_zeros() method could be used here instead of doing the same manually.
tschatzl
left a comment
There was a problem hiding this comment.
To be really nitpicky: the subject of the PR should be made more specific to mention that the new set is a bitset not just a set. I.e. os::page_sizes has already previously been a set (of integers), so where's the change? :P
|
Hi Thomas, thanks again for the review. I hope I addressed all points. I completely removed the comments from the cpp file and corrected them in the hpp file, which removes the need to keep them in sync. And I rather have them in the hpp file, that makes my IDE happy. Cheers, Thomas |
|
+1 on the general thrust of this change. I'd be happy to incorporate into #1153 & JDK-8256155 [1] if they are approved. |
stefank
left a comment
There was a problem hiding this comment.
Just a few drive-by comment: Could PagesizeSet be named PageSizeSet. The rest of the code separates the word, so I think that name would be better. The same for some of the parameters that are named pagesize.
Also, I think you could have called the class PageSizes. I don't think the fact that this is a 'set' matters for the usages of the class. It also makes the variable name match the type name, which I guess is an indication that it wouldn't be such a bad name:
static PageSizes _page_sizes;`
vs
static PagesizeSet _page_sizes;
src/hotspot/share/runtime/os.cpp
Outdated
|
|
||
| bool os::PagesizeSet::is_set(size_t pagesize) const { | ||
| assert(is_power_of_2(pagesize), "pagesize must be a power of 2: " INTPTR_FORMAT, pagesize); | ||
| return (_v & pagesize) > 0; |
There was a problem hiding this comment.
Why is this > 0 and not simply != 0
There was a problem hiding this comment.
I'm not sure if you saw this comment, but is there a reason why > 0 is used here?
src/hotspot/share/runtime/os.cpp
Outdated
| if (v2 > 0) { | ||
| return round_down_power_of_2(v2); | ||
| } | ||
| return 0; |
There was a problem hiding this comment.
In next_larger you use the for:
if (v2 == 0) {
return 0;
}
return ...
I think it would be nice to be consistent between the two functions.
There was a problem hiding this comment.
Just a few drive-by comment: Could PagesizeSet be named PageSizeSet. The rest of the code separates the word, so I think that name would be better. The same for some of the parameters that are named pagesize.
Also, I think you could have called the class PageSizes. I don't think the fact that this is a 'set' matters for the usages of the class. It also makes the variable name match the type name, which I guess is an indication that it wouldn't be such a bad name:
static PageSizes _page_sizes;`vs
static PagesizeSet _page_sizes;
Hi Stefan,
thanks for your review! I adapted most of your suggestions.
Cheers, Thomas
stefank
left a comment
There was a problem hiding this comment.
I think this mostly looks good, but there are a number of cleanups that I'd like you to consider.
src/hotspot/share/runtime/os.cpp
Outdated
|
|
||
| bool os::PagesizeSet::is_set(size_t pagesize) const { | ||
| assert(is_power_of_2(pagesize), "pagesize must be a power of 2: " INTPTR_FORMAT, pagesize); | ||
| return (_v & pagesize) > 0; |
There was a problem hiding this comment.
I'm not sure if you saw this comment, but is there a reason why > 0 is used here?
|
Hi Stefan, I pushed a new commit with the changes you requested. Thanks, Thomas |
|
@tstuefe 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 123 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 |
Thank you Stefan. |
|
Thanks Thomas |
|
/integrate |
|
@tstuefe Since your change was applied there have been 127 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 8e8e584. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
| for (size_t s = os::page_sizes().largest(); s != 0; s = os::page_sizes().next_smaller(s)) { | ||
| const size_t expected = os::page_sizes().next_smaller(s); | ||
| if (expected != 0) { | ||
| size_t actual = os::page_size_for_region_unaligned(expected - 17, 1); |
There was a problem hiding this comment.
@tstuefe should expected here be s ?
It seems like we are trying to compare the next smaller page size of S, with a slightly smaller size of the size S.
os::page_size_for_region_unaligned(expected - 17, 1);
vs.
os::page_size_for_region_unaligned(s - 17, 1);
Running these tests with 2 largepage sizes (3 total sizes) fails, however default of 2 page_sizes passes (4k and 2m or 1g):
(./hotspot/variant-server/libjvm/gtest/gtestLauncher -jdk:./images/jdk -Xms2G -Xmx2G -XX:+UseLargePages -XX:LargePageSizeInBytes=2M)
[----------] 17 tests from os [ RUN ] os.page_size_for_region_vm [ OK ] os.page_size_for_region_vm (0 ms) [ RUN ] os.page_size_for_region_aligned_vm [ OK ] os.page_size_for_region_aligned_vm (0 ms) [ RUN ] os.page_size_for_region_alignment_vm [ OK ] os.page_size_for_region_alignment_vm (0 ms) [ RUN ] os.page_size_for_region_unaligned_vm test/hotspot/gtest/runtime/test_os.cpp:106: Failure Expected equality of these values: actual Which is: 4096 expected Which is: 2097152 [ FAILED ] os.page_size_for_region_unaligned_vm (0 ms)
This only happen when #1153 is present in code, because otherwise you will only have two page_sizes, but still this should return the correct results.
There was a problem hiding this comment.
Yes, you are right, it should. I filed JDK-8257989. Feel free to fix it.
Thanks, Thomas
There was a problem hiding this comment.
Oh, I see you already have a PR open, I reply there.
Hi,
may I please have reviews for the following very small improvement:
While discussing JDK-8243315 [1], and aiming to make planned changes like JDK-8256155 [2] easier:
is an array used to keep all page sizes the hotspot can use. It is sorted by size and filled in at initialization time.
Coding dealing with this can be simplified by making this a set (which is very easy since all page sizes are power-2-values so they lend themselves nicely to a bitmap).
That has the following advantages:
The patch adds a new class, os::PagesizeSet, which is a bitmap containing page sizes. It adds gtests for this class. It replaces the old os::_page_sizes with an object of that class. It also removes an unused function.
Testing:
Thank you,
Thomas
[1] https://bugs.openjdk.java.net/browse/JDK-8243315
[2] https://bugs.openjdk.java.net/browse/JDK-8256155
/label hotspot-dev
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/1522/head:pull/1522$ git checkout pull/1522