RFR: JDK-8257588: Make os::_page_sizes a bitmask [v6]
Marcus G K Williams
github.com+168222+mgkwill at openjdk.java.net
Wed Dec 9 18:26:52 UTC 2020
On Mon, 7 Dec 2020 08:52:28 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
>> 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:
>>
>> size_t os::_page_sizes[os::page_sizes_max];
>>
>> 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:
>> - makes adding new sizes simple since we do not have to re-sort the array. Coding is easier to read too.
>> - it makes it possible to encode a set of page sizes in one number, so we can hand a set-of-page-sizes around as a value.
>>
>> -----
>>
>> 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:
>> - nightlies at SAP
>> - manual tests with UseLargePages
>> - the new gtests
>> - gh actions (with x86 still failing because of unrelated issues)
>>
>> Thank you,
>>
>> Thomas
>>
>> [1] https://bugs.openjdk.java.net/browse/JDK-8243315
>> [2] https://bugs.openjdk.java.net/browse/JDK-8256155
>
> Thomas Stuefe has updated the pull request incrementally with one additional commit since the last revision:
>
> Add missing include (ppc,s390 builds failed)
test/hotspot/gtest/runtime/test_os.cpp line 104:
> 102: const size_t expected = os::page_sizes().next_smaller(s);
> 103: if (expected != 0) {
> 104: size_t actual = os::page_size_for_region_unaligned(expected - 17, 1);
@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: a
ctual Which is: 4096 expected Which is: 2097152 [ FAILED ] os.page_size_for_region_unaligned_vm (0 ms)
This only happen when https://github.com/openjdk/jdk/pull/1153 is present in code, because otherwise you will only have two page_sizes, but still this should return the correct results.
-------------
PR: https://git.openjdk.java.net/jdk/pull/1522
More information about the hotspot-dev
mailing list