RFR: 8343153: compiler/codecache/CheckLargePages.java fails on linux with huge pages configured but its number set to 0
Tobias Hartmann
thartmann at openjdk.org
Thu Oct 31 07:43:31 UTC 2024
On Thu, 31 Oct 2024 07:39:03 GMT, Tobias Hartmann <thartmann 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).
>
> test/hotspot/jtreg/compiler/codecache/CheckLargePages.java line 120:
>
>> 118: // 1GB large pages configured but none available
>> 119: "Failed to reserve and commit memory with given page size\\. " +
>> 120: "req_addr: [^ ]+ size: 1[gG], page size: 1[gG], \\(errno = 12\\)");
>
> Took me a while to figure that these are `OR` matches due to the `|` hiding at the end of the first line. Would it make sense to update the comment to something like this?
>
> // 1GB large pages configured and available
> "CodeCache:\\s+min=1[gG] max=1[gG] base=[^ ]+ size=1[gG] page_size=1[gG]|" +
> // or 1GB large pages configured but none available
Also, isn't there a `CodeCache:\` line in the output in the failing case as well that should be added here in the OR part?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21757#discussion_r1823999523
More information about the hotspot-compiler-dev
mailing list