RFR: JDK-8256155: os::Linux Populate all large_page_sizes, select smallest page size in reserve_memory_special_huge_tlbfs* [v15]
Stefan Johansson
sjohanss at openjdk.java.net
Fri Jan 15 11:24:09 UTC 2021
On Tue, 15 Dec 2020 18:48:05 GMT, Marcus G K Williams <github.com+168222+mgkwill at openjdk.org> wrote:
>> When using LargePageSizeInBytes=1G, os::Linux::reserve_memory_special_huge_tlbfs* cannot select large pages smaller than 1G. Code heap usually uses less than 1G, so currently the code precludes code heap from using
>> Large pages in this circumstance and when os::Linux::reserve_memory_special_huge_tlbfs* is called page sizes fall back to Linux::page_size() (usually 4k).
>>
>> This change allows the above use case by populating all large_page_sizes present in /sys/kernel/mm/hugepages in _page_sizes upon calling os::Linux::setup_large_page_size().
>>
>> In os::Linux::reserve_memory_special_huge_tlbfs* we then select the largest large page size available in _page_sizes that is smaller than bytes being reserved.
>
> Marcus G K Williams has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 23 commits:
>
> - Merge branch 'master' into update_hlp
> - Merge branch 'master' into update_hlp
> - Remove extraneous ' from warning
>
> Signed-off-by: Marcus G K Williams <marcus.williams at intel.com>
> - Merge branch 'master' into update_hlp
> - Merge branch 'master' into update_hlp
> - Merge branch 'master' into update_hlp
> - Fix os::large_page_size() in last update
>
> Signed-off-by: Marcus G K Williams <marcus.williams at intel.com>
> - Ivan W. Requested Changes
>
> Removed os::Linux::select_large_page_size and
> use os::page_size_for_region instead
>
> Removed Linux::find_large_page_size and use
> register_large_page_sizes. Streamlined
> Linux::setup_large_page_size
>
> Signed-off-by: Marcus G K Williams <marcus.williams at intel.com>
> - Fix space format, use Linux:: for local func.
>
> Signed-off-by: Marcus G K Williams <marcus.williams at intel.com>
> - Merge branch 'update_hlp' of github.com:mgkwill/jdk into update_hlp
> - ... and 13 more: https://git.openjdk.java.net/jdk/compare/da2415fe...d73e7a4c
Back from the holidays and actually looking at our use of large pages from a other perspecive as well. I think the approach here has been simplified a lot from the first suggestion and I like it. Just a few small additional comments.
src/hotspot/os/linux/os_linux.cpp line 3750:
> 3748: }
> 3749: }
> 3750: closedir(dir);
It would be nice to add some logging here using the `pagesize` tag. The new PageSizes class has a `print_on()` that we could use. I'm thinking something like:
LogTarget(Info, pagesize) lt;
if (lt.is_enabled()) {
LogStream ls(lt);
ls.print("Available page sizes: ");
_page_sizes.print_on(&ls);
}
src/hotspot/os/linux/os_linux.cpp line 4013:
> 4011: assert(UseLargePages && UseHugeTLBFS, "only for Huge TLBFS large pages");
> 4012: assert(is_aligned(bytes, large_page_size), "Unaligned size");
> 4013: assert(is_aligned(req_addr, large_page_size), "Unaligned address");
Adding an assert here that `large_page_size` is larger than os::vm_page_size (small page size) to ensure we actually get a large page size from `page_size_for_region_aligned()`. Otherwise the passed in a size wasn't correctly aligned.
src/hotspot/os/linux/os_linux.cpp line 4047:
> 4045: // that is smaller than size_t bytes
> 4046: size_t large_page_size = os::page_size_for_region_aligned(bytes, 1);
> 4047:
Adding the same assert as suggested above here.
-------------
Changes requested by sjohanss (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/1153
More information about the hotspot-gc-dev
mailing list