Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/gc/arguments/TestSmallInitialHeapWithLargePageAndNUMA.java
40948 views
1
/*
2
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
package gc.arguments;
25
26
/*
27
* @test TestSmallInitialHeapWithLargePageAndNUMA
28
* @bug 8023905
29
* @requires os.family == "linux"
30
* @requires vm.gc.Parallel
31
* @summary Check large pages and NUMA are working together via the output message.
32
* @library /test/lib
33
* @library /
34
* @modules java.base/jdk.internal.misc
35
* @modules java.management/sun.management
36
* @build TestSmallInitialHeapWithLargePageAndNUMA
37
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
38
* @run main/othervm -Xbootclasspath/a:. -XX:+UseHugeTLBFS -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI gc.arguments.TestSmallInitialHeapWithLargePageAndNUMA
39
*/
40
41
import jdk.test.lib.process.ProcessTools;
42
import jdk.test.lib.process.OutputAnalyzer;
43
import sun.hotspot.WhiteBox;
44
import jtreg.SkippedException;
45
46
public class TestSmallInitialHeapWithLargePageAndNUMA {
47
48
private static final String MSG_EXIT_TOO_SMALL_HEAP = "Failed initializing NUMA with large pages. Too small heap size";
49
private static final String MSG_GC_TRIGGERED_BEFORE_INIT = "GC triggered before VM initialization completed.";
50
51
public static void main(String[] args) throws Exception {
52
53
WhiteBox wb = WhiteBox.getWhiteBox();
54
long heapAlignment = wb.getHeapAlignment();
55
56
// When using large pages, Linux does not support freeing parts of reserved and committed memory.
57
// And current Linux implementation uses page size as a condition to actually freeing memory.
58
// If we allocate pages less than NUMA node, NUMA will try to use default page size and
59
// this will free the memory which Linux does not support.
60
// Assume the minimum NUMA node as 2.
61
long initHeap = heapAlignment;
62
long maxHeap = heapAlignment * 2;
63
64
ProcessBuilder pb_enabled = GCArguments.createJavaProcessBuilder(
65
"-XX:+UseParallelGC",
66
"-Xms" + String.valueOf(initHeap),
67
"-Xmx" + String.valueOf(maxHeap),
68
"-XX:+UseNUMA",
69
"-XX:+UseHugeTLBFS",
70
"-XX:+PrintFlagsFinal",
71
"-version");
72
OutputAnalyzer analyzer = new OutputAnalyzer(pb_enabled.start());
73
74
if (largePageOrNumaEnabled(analyzer)) {
75
// We reach here, if both NUMA and HugeTLB are supported.
76
// However final flags will not be printed as NUMA initialization will be failed.
77
checkAnalyzerValues(analyzer, 1, MSG_EXIT_TOO_SMALL_HEAP);
78
} else {
79
throw new SkippedException("either NUMA or HugeTLB is not supported");
80
}
81
}
82
83
// If both NUMA and large pages are enabled, VM will exit during NUMA initialization
84
// under the small heap configuration. So final flags will not be printed.
85
private static boolean largePageOrNumaEnabled(OutputAnalyzer analyzer) {
86
String output = analyzer.getOutput();
87
88
return !output.contains("[Global flags]");
89
}
90
91
// We need to test with small heap but fastdebug binary fails to initialize because of the small heap.
92
// So skip that case.
93
private static void checkAnalyzerValues(OutputAnalyzer analyzer, int expectedExitValue, String expectedMessage) {
94
String output = analyzer.getOutput();
95
96
// If the VM exits because of the small heap, skip checking the exit value.
97
if (!output.contains(MSG_GC_TRIGGERED_BEFORE_INIT)) {
98
analyzer.shouldHaveExitValue(expectedExitValue);
99
}
100
if (expectedMessage != null) {
101
analyzer.shouldContain(expectedMessage);
102
}
103
}
104
}
105
106