JDK-8263236 : runtime/os/TestTracePageSizes.java fails on old kernels
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 17
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-03-09
  • Updated: 2021-05-14
  • Resolved: 2021-05-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17
17 b22Fixed
Related Reports
Relates :  
Relates :  
Description
After JDK-8262188 added the new test, I am seeing the failures on some (older) kernels like these:

Added range: [ffffffffff600000, ffffffffff601000) pageSize=4KB isTHP=false isHUGETLB=false, vmFlags = rd ex 
From logfile: [0.003s][info][pagesize] CodeHeap 'non-nmethods':  min=4M max=8M base=0x00007f1b57c00000 page_size=2M size=8M
From smaps: [7f1b57c00000, 7f1b58000000) pageSize=4KB isTHP=false isHUGETLB=false, vmFlags = rd wr ex mr mw me ac 
Failure: 4 != 2048
STDERR:
java.lang.AssertionError: Page sizes mismatch: 4 != 2048
	at TestTracePageSizes.main(TestTracePageSizes.java:149)

...while on other (newer?) kernels it passes with:

Added range: [ffffffffff600000, ffffffffff601000) pageSize=4KB isTHP=false isHUGETLB=false, vmFlags=ex 
From logfile: [0.002s][info][pagesize] CodeHeap 'non-nmethods':  min=4M max=10M base=0x00007f7b50000000 page_size=2M size=10M
From smaps: [7f7b50000000, 7f7b50400000) pageSize=4KB isTHP=true isHUGETLB=false, vmFlags=rd wr ex mr mw me ac sd hg 
Success: 2048 > 4 and THP enabled

It seems as if "hg" flag that is supposed to show that VMA block was madvised for THP is missing on some kernels. Both machines above have THP on:

$ cat /sys/kernel/mm/transparent_hugepage/{enabled,defrag}
always [madvise] never
always defer [madvise] never

Every test configuration with -XX:+UseTransparentHugePages seems to fail.

Test passes on machine with:
Linux ... 5.4.0-65-generic #73-Ubuntu SMP Mon Jan 18 17:25:17 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

...and fails on machine with:
Linux ... 4.9.0-14-amd64 #1 SMP Debian 4.9.246-2 (2020-12-17) x86_64 GNU/Linux
Comments
Pattern matching may be a bit too expensive for this test: https://bugs.openjdk.java.net/browse/JDK-8267155
14-05-2021

Changeset: 36e5ad61 Author: Aleksey Shipilev <shade@openjdk.org> Date: 2021-05-06 20:34:49 +0000 URL: https://git.openjdk.java.net/jdk/commit/36e5ad61e63e2f1da9cf565c607db28f23622ea9
06-05-2021

I suspect this kernel fix is in newer kernels, while old kernels still miss the VmFlag the test wants. Reading https://www.kernel.org/doc/Documentation/vm/transhuge.txt, I think we can try an look at AnonHugePages as additional hint: "The number of anonymous transparent huge pages currently used by the system is available by reading the AnonHugePages field in /proc/meminfo. To identify what applications are using anonymous transparent huge pages, it is necessary to read /proc/PID/smaps and count the AnonHugePages fields for each mapping."
22-04-2021

I have a candidate fix for it, please see linked PR.
09-04-2021

I also see this failure appears on 64K page systems. TEST RESULT: Failed. Execution failed: `main' threw exception: java.lang.AssertionError: Page sizes mismatch: 64 != 524288
24-03-2021