Skip to content

Commit e7f0bf1

Browse files
committed
8343153: compiler/codecache/CheckLargePages.java fails on linux with huge pages configured but its number set to 0
Reviewed-by: eastigeevich, thartmann
1 parent f9e1c62 commit e7f0bf1

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

test/hotspot/jtreg/ProblemList.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ compiler/c2/Test8004741.java 8235801 generic-all
5555
compiler/c2/irTests/TestDuplicateBackedge.java 8318904 generic-all
5656

5757
compiler/codecache/jmx/PoolsIndependenceTest.java 8264632 macosx-all
58-
compiler/codecache/CheckLargePages.java 8332654 linux-x64
5958

6059
compiler/vectorapi/reshape/TestVectorReinterpret.java 8320897 aix-ppc64,linux-ppc64le
6160
compiler/vectorapi/VectorLogicalOpIdentityTest.java 8302459 linux-x64,windows-x64

test/hotspot/jtreg/compiler/codecache/CheckLargePages.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -39,6 +39,9 @@
3939
import jdk.test.lib.process.OutputAnalyzer;
4040
import jdk.test.lib.process.ProcessTools;
4141
import jdk.test.whitebox.WhiteBox;
42+
import java.util.Scanner;
43+
import java.io.File;
44+
import java.io.FileNotFoundException;
4245

4346
import java.util.Arrays;
4447
import java.util.List;
@@ -47,6 +50,7 @@ public class CheckLargePages {
4750
private final static long LP_1G = 1024 * 1024 * 1024;
4851
private final static boolean LARGE_PAGES_ENABLED;
4952
private final static long LARGE_PAGE_SIZE;
53+
private final static String LARGE_PAGE_NUMBER_FILE_BASE = "/sys/kernel/mm/hugepages/hugepages-%skB/nr_hugepages";
5054

5155
static {
5256
WhiteBox whiteBox = WhiteBox.getWhiteBox();
@@ -58,6 +62,16 @@ private static boolean isLargePageSizeEqual(long size) {
5862
return LARGE_PAGE_SIZE == size;
5963
}
6064

65+
private static int numberOfLargePages(long size) {
66+
String largePageNumberFile = String.format(LARGE_PAGE_NUMBER_FILE_BASE, size / 1024);
67+
try (Scanner scanner = new Scanner(new File(largePageNumberFile))) {
68+
if (scanner.hasNextInt()) {
69+
return scanner.nextInt();
70+
}
71+
} catch (FileNotFoundException e) { };
72+
return 0;
73+
}
74+
6175
private static void testSegmented2GbCodeCacheWith1GbPage() throws Exception {
6276
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
6377
"-XX:+UseLargePages",
@@ -113,11 +127,17 @@ private static void testNonSegmented1GbCodeCacheWith1GbLargePages() throws Excep
113127
out.shouldContain("UseLargePages=1, UseTransparentHugePages=0");
114128
out.shouldMatch("CodeCache: min=1[gG] max=1[gG] base=[^ ]+ size=1[gG] page_size=1[gG]");
115129
}
130+
116131
public static void main(String[] args) throws Exception {
117132
if (isLargePageSizeEqual(LP_1G)) {
118133
testSegmented2GbCodeCacheWith1GbPage();
119-
testDefaultCodeCacheWith1GbLargePages();
120-
testNonSegmented1GbCodeCacheWith1GbLargePages();
134+
if (numberOfLargePages(LP_1G) >= 1) {
135+
testDefaultCodeCacheWith1GbLargePages();
136+
testNonSegmented1GbCodeCacheWith1GbLargePages();
137+
} else {
138+
System.out.println("Skipping testDefaultCodeCacheWith1GbLargePages and " +
139+
"testNonSegmented1GbCodeCacheWith1GbLargePages, no 1Gb pages available");
140+
}
121141
} else {
122142
System.out.println("1GB large pages not supported: UseLargePages=" + LARGE_PAGES_ENABLED +
123143
(LARGE_PAGES_ENABLED ? ", largePageSize=" + LARGE_PAGE_SIZE : "") + ". Skipping");

0 commit comments

Comments
 (0)