RFR: 8343153: compiler/codecache/CheckLargePages.java fails on linux with huge pages configured but its number set to 0

Evgeny Astigeevich eastigeevich at openjdk.org
Thu Oct 31 13:18:28 UTC 2024


On Thu, 31 Oct 2024 11:53:45 GMT, Evgeny Astigeevich <eastigeevich at openjdk.org> wrote:

>> # Issue
>> 
>> The third test of `compiler/codecache/CheckLargePages.java` checks that non-segmented 1GB code cache can be allocated with 1GB large pages.
>> 
>> On linux (the only supported platform) in order to allocate them, 1GB huge pages have to be enabled (checkable from `/proc/meminfo` and `/sys/kernel/mm/hugepages/hugepages-xxxx`) and their number has to be set to >0 (checkable from `/sys/kernel/mm/hugepages/hugepages-xxxx/nr_hugepages`).
>> 
>> If 1GB huge pages are enabled but their number is 0, the test fails because it looks for a string that matches `CodeCache: min=1[gG] max=1[gG] base=[^ ]+ size=1[gG] page_size=1[gG]` but the actual output is `CodeCache: min=1G max=1G base=0x00007f4040000000 size=1G page_size=2M`. This happens because the VM tries to allocate 1GB huge pages but it fails beause the number of allocatable ones is 0 and the VM reverts to smaller large page sizes (2MB).
>> 
>> # Solution
>> 
>> The problem might be attributed to the VM only checking for 1GB huge pages to be supported, not how many there currently are. Nevertheless, this seems to be the correct behaviour, not least because their number can be changed dynamically.
>> So, the correct thing to do seems to be to "relax" the check made by the test to include both cases:
>> * when 1GB huge pages are supported and can be allocated correctly
>> * when 1GB huge pages are supported but cannot be allocated correctly (because there are none available) and the VM reverts to 2MB huge pages (if there are no 2MB pages available the test doesn't run at all).
>
>> The problem might be attributed to the VM only checking for 1GB huge pages to be supported, not how many there currently are.
> 
> https://bugs.openjdk.org/browse/JDK-8321526

> @eastig I noticed that you are the author of the original `testNonSegmented1GbCodeCacheWith1GbLargePages` test. Could I ask you to have a look at this change? Thanks a lot!

`testDefaultCodeCacheWith1GbLargePages` and `testNonSegmented1GbCodeCacheWith1GbLargePages` should only be run if a system provides 1Gb pages. This is mentioned in their names: `...With1GbLargePages`. If there are no 1Gb pages available, the test should not be run.

I suggest to check `/sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages >= 1`. If not, output "Skipping testDefaultCodeCacheWith1GbLargePages and testDefaultCodeCacheWith1GbLargePages, no 1Gb pages available"

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

PR Comment: https://git.openjdk.org/jdk/pull/21757#issuecomment-2449819859


More information about the hotspot-compiler-dev mailing list