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 20:16:12 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

Did some more testing with the code. I'm using Parallel for testing becuase G1 does a better job aligning sizes and avoiding some problems.

I found that this change has a problem with mapping using both small and large pages (`reserve_memory_special_huge_tlbfs_mixed()`). I'm currently investigating if we can remove these type of mixed-mappings, and instead make sure we only use large pages when properly aligned, so in the future we might be able get rid of some code in this area. For know see my comments below.

src/hotspot/os/linux/os_linux.cpp line 4134:

> 4132:   // Select large_page_size from _page_sizes
> 4133:   // that is smaller than size_t bytes
> 4134:   size_t large_page_size = os::page_size_for_region_aligned(bytes, 1);

This is partly what I'm looking at from a slightly different direction. And my current thinking is that we should get rid of all mappings that are not properly aligned when using large pages. But that is something for a different PR.

I need to look more at this next week, but for this to work as before this call needs to use the unaligned version: `os::page_size_for_region_unaligned(...)` otherwise we will here get a small page size in many cases and that can not be used with the code doing the reservations below.

src/hotspot/os/linux/os_linux.cpp line 4046:

> 4044:   // Select large_page_size from _page_sizes
> 4045:   // that is smaller than size_t bytes
> 4046:   size_t large_page_size = os::page_size_for_region_aligned(bytes, 1);

This one also needs to use `os::page_size_for_region_unaligned(...)` since we know we have a size that needs both small and large pages.

-------------

Changes requested by sjohanss (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/1153



More information about the hotspot-gc-dev mailing list