RFR: JDK-8256155: os::Linux Populate all large_page_sizes, select smallest page size in reserve_memory_special_huge_tlbfs* [v23]
Stefan Johansson
sjohanss at openjdk.java.net
Tue Mar 16 10:02:13 UTC 2021
On Mon, 15 Mar 2021 18:40:23 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 incrementally with one additional commit since the last revision:
>
> Use SIZE_FORMAT in logging
>
> Signed-off-by: Marcus G K Williams <marcus.williams at intel.com>
I agree that this change should not include to much refactoring. We should do that as separate changes. Some possibly have to be done before this one.
Regarding your problems:
1. This is a somewhat known problem and we have [JDK-8261527](https://bugs.openjdk.java.net/browse/JDK-8261527) for tracking this. I hope to get this in for JDK 17. Up until your change we have always known that only one large page size can be used, so if a ReservedSpace is "special" that page size was used. With your change this has to change somehow and I think it will be hard to achieve without some other refactoring first.
2. Correct, this test does not yet handle mixed-mappings since none of the mappings traced has used mixed mappings before. The problem you run into is that your new code doesn't honor the request in Parallel to used 2M pages:
https://github.com/openjdk/jdk/blob/a31a23d5e72c4618b5b67e854ef4909110a1b5b4/src/hotspot/share/gc/parallel/parallelArguments.cpp#L120
When deciding on a new page size we should honor the passed in alignment if it is larger than the allocation granularity. Because in such case the upper layer has made a decision that the lower layer should honor.
One other way forward (not waiting for refactoring) would be to see this change as just enabling use of multiple page sizes and then actually using them will be added later when needed refactoring has been done.
src/hotspot/os/linux/os_linux.cpp line 3760:
> 3758: void os::large_page_init() {
> 3759: size_t default_large_page_size = scan_default_large_page_size();
> 3760: os::Linux::_default_large_page_size = default_large_page_size;
I would move this below the checking if large pages are enabled. I'm also not sure if this refactoring made the setup easier to follow. I would have preferred the old way, but if you and Thomas prefer this I'm ok with it.
src/hotspot/os/linux/os_linux.cpp line 3809:
> 3807: ls.print("\n");
> 3808: ls.print("Available large page sizes: ");
> 3809: all_large_pages.print_on(&ls);
Use `ls.cr()` instead of `print("\n")` and I'm also not sure there is any value to print the large page sizes separately as they are part of the first set.
-------------
Changes requested by sjohanss (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/1153
More information about the hotspot-dev
mailing list