RFR: 8271195: Use largest available large page size smaller than LargePageSizeInBytes when available [v8]

Stefan Johansson sjohanss at openjdk.java.net
Mon Feb 21 15:07:55 UTC 2022


On Mon, 21 Feb 2022 13:11:39 GMT, Swati Sharma <duke at openjdk.java.net> wrote:

>> Hi Team,
>> 
>> In this patch I have fixed two issues related to large pages, following is the summary of changes :-
>> 
>> 1. Patch fixes existing large page allocation functionality where if a commit over 1GB pages fails allocation should happen over next small page size i.e. 2M where as currently its happening over 4kb pages resulting into significant TLB miss penalty.
>> Patch includes new JTREG Test case covering various scenarios for checking the correct explicit page allocation according ​to the 1G, 2M, 4K priority.
>> 2. While attempting commit over larger pages we first try to reserve requested bytes over the virtual address space, in case commit to large page fails we should be un reserving entire reservation to avoid leaving any leaks in virtual address space.
>> 
>>>> Please find below the performance data with and without patch for the JMH benchmark included with the patch.
>> 
>> ![image](https://user-images.githubusercontent.com/96874289/152189587-4822a4ca-f5e2-4621-b405-0da941485143.png)
>> 
>> 
>> Please review and provide your valuable comments.
>> 
>> 
>> 
>> Thanks,
>> Swati Sharma
>> Runtime Software Development Engineer 
>> Intel
>
> Swati Sharma has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8271195: Review comments resolved.

Spent some more time on the test-failure and the below overflows are the reasons. 

I think this really shows that we should go with a simpler approach and avoiding the unnecessary bit-fiddling.

test/hotspot/jtreg/runtime/os/TestExplicitPageAllocation.java line 101:

> 99:         int m = 1024 * 1024;
> 100:         int g = 1024 * 1024 * 1024;
> 101:         int sizeInBytes = 1 << index;

The reason for the failing test is that this shift overflow when the page size is 16G. Because of the other overflow the passed in index here was also incorrect (32), but still to large to work properly.

test/hotspot/jtreg/runtime/os/TestExplicitPageAllocation.java line 149:

> 147:                 System.out.println("No Pages configured for " + pageSize + "kB");
> 148:             }
> 149:             int index = Integer.numberOfTrailingZeros(Integer.parseInt(pageSize) * 1024);

The calculation inside the call to `numberOfTrailingZeros()` will overflow when the page-size is 16G (above 1G).

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

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


More information about the hotspot-runtime-dev mailing list