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