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
Tue Mar 16 10:02:14 UTC 2021


On Sat, 13 Mar 2021 07:18:05 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

>> 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.
>
> @kstefanj 
> Hmm.
> 
> `os::page_size_for_region_xxx` can return any page size, including the base page size. Caller may reasonably pass in any reserve size; we may run on a system where the only large page available is > caller size, or we specified LargePageSizeInBytes=1G.
> 
> I actually would prefer this function to graciously handle the case of too small input size and just allocate whatever fits the caller size best; if its only 4K pages so be it. But this also could be done in a future RFE.

As you both know I've been playing around in this area quite a bit lately and I think the final version will differ from what this PR will produce. The problem I see is that it will be quite hard to achieve what this PR wants without doing quite significant refactoring.

The code above should work if all other layers setup the mapping correctly, we should only end up in this function if the size is a multiple of a large page size. 

I think this part of the code would be significantly easier if I first pushed a change that I have lined up to fix the strange strange condition in `reserve_memory_special_huge_tlbfs()`. The fix merges the `*_only` and `*_mixed` helpers into the main function to simplify the logic:
https://github.com/openjdk/jdk/compare/master...kstefanj:8262291-one-special-alloc

If we had this function we could use the alignment parameter to figure out the largest possible page size to use.

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

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



More information about the hotspot-gc-dev mailing list