author | kkharbas |
Wed, 29 Nov 2017 17:03:10 -0800 | |
changeset 48153 | cfa2c43e58c2 |
parent 47216 | 71c04702a3d5 |
child 53523 | 4c5184c56dc2 |
permissions | -rw-r--r-- |
19991
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
1 |
/* |
39692
57f307f875e0
8024945: Remove check on minimum size of MetaspaceSize
jmasa
parents:
36851
diff
changeset
|
2 |
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. |
19991
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
4 |
* |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
8 |
* |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
13 |
* accompanied this code). |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
14 |
* |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
18 |
* |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
21 |
* questions. |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
22 |
*/ |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
23 |
|
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
29678
diff
changeset
|
24 |
import jdk.test.lib.Asserts; |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
39960
diff
changeset
|
25 |
import jdk.test.lib.process.ProcessTools; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
39960
diff
changeset
|
26 |
import jdk.test.lib.process.OutputAnalyzer; |
19991
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
27 |
|
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
28 |
/* |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
29 |
* @test TestMetaspaceSizeFlags |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
30 |
* @key gc |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
31 |
* @bug 8024650 |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
32 |
* @summary Test that metaspace size flags can be set correctly |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
39960
diff
changeset
|
33 |
* @library /test/lib |
36851 | 34 |
* @modules java.base/jdk.internal.misc |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
19991
diff
changeset
|
35 |
* java.management |
19991
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
36 |
*/ |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
37 |
public class TestMetaspaceSizeFlags { |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
38 |
public static final long K = 1024L; |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
39 |
public static final long M = 1024L * K; |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
40 |
|
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
41 |
// HotSpot uses a number of different values to align memory size flags. |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
42 |
// This is currently the largest alignment (unless huge large pages are used). |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
43 |
public static final long MAX_ALIGNMENT = 32 * M; |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
44 |
|
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
45 |
public static void main(String [] args) throws Exception { |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
46 |
testMaxMetaspaceSizeEQMetaspaceSize(MAX_ALIGNMENT, MAX_ALIGNMENT); |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
47 |
// 8024650: MaxMetaspaceSize was adjusted instead of MetaspaceSize. |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
48 |
testMaxMetaspaceSizeLTMetaspaceSize(MAX_ALIGNMENT, MAX_ALIGNMENT * 2); |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
49 |
testMaxMetaspaceSizeGTMetaspaceSize(MAX_ALIGNMENT * 2, MAX_ALIGNMENT); |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
50 |
} |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
51 |
|
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
52 |
private static void testMaxMetaspaceSizeEQMetaspaceSize(long maxMetaspaceSize, long metaspaceSize) throws Exception { |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
53 |
MetaspaceFlags mf = runAndGetValue(maxMetaspaceSize, metaspaceSize); |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
54 |
Asserts.assertEQ(maxMetaspaceSize, metaspaceSize); |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
55 |
Asserts.assertEQ(mf.maxMetaspaceSize, maxMetaspaceSize); |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
56 |
Asserts.assertEQ(mf.metaspaceSize, metaspaceSize); |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
57 |
} |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
58 |
|
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
59 |
private static void testMaxMetaspaceSizeLTMetaspaceSize(long maxMetaspaceSize, long metaspaceSize) throws Exception { |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
60 |
MetaspaceFlags mf = runAndGetValue(maxMetaspaceSize, metaspaceSize); |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
61 |
Asserts.assertEQ(mf.maxMetaspaceSize, maxMetaspaceSize); |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
62 |
Asserts.assertEQ(mf.metaspaceSize, maxMetaspaceSize); |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
63 |
} |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
64 |
|
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
65 |
private static void testMaxMetaspaceSizeGTMetaspaceSize(long maxMetaspaceSize, long metaspaceSize) throws Exception { |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
66 |
MetaspaceFlags mf = runAndGetValue(maxMetaspaceSize, metaspaceSize); |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
67 |
Asserts.assertGT(maxMetaspaceSize, metaspaceSize); |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
68 |
Asserts.assertGT(mf.maxMetaspaceSize, mf.metaspaceSize); |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
69 |
Asserts.assertEQ(mf.maxMetaspaceSize, maxMetaspaceSize); |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
70 |
Asserts.assertEQ(mf.metaspaceSize, metaspaceSize); |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
71 |
} |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
72 |
|
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
73 |
private static MetaspaceFlags runAndGetValue(long maxMetaspaceSize, long metaspaceSize) throws Exception { |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
74 |
OutputAnalyzer output = run(maxMetaspaceSize, metaspaceSize); |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
75 |
output.shouldNotMatch("Error occurred during initialization of VM\n.*"); |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
76 |
|
39960
ec06b2cf8575
8048093: Explicitly setting := vs = in the -XX:+PrintFlagsFinal output
jwilhelm
parents:
39692
diff
changeset
|
77 |
String stringMaxMetaspaceSize = output.firstMatch(".* MaxMetaspaceSize .* = (\\d+).*", 1); |
ec06b2cf8575
8048093: Explicitly setting := vs = in the -XX:+PrintFlagsFinal output
jwilhelm
parents:
39692
diff
changeset
|
78 |
String stringMetaspaceSize = output.firstMatch(".* MetaspaceSize .* = (\\d+).*", 1); |
19991
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
79 |
|
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
80 |
return new MetaspaceFlags(Long.parseLong(stringMaxMetaspaceSize), |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
81 |
Long.parseLong(stringMetaspaceSize)); |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
82 |
} |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
83 |
|
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
84 |
private static OutputAnalyzer run(long maxMetaspaceSize, long metaspaceSize) throws Exception { |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
85 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
86 |
"-XX:MaxMetaspaceSize=" + maxMetaspaceSize, |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
87 |
"-XX:MetaspaceSize=" + metaspaceSize, |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
88 |
"-XX:-UseLargePages", // Prevent us from using 2GB large pages on solaris + sparc. |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
89 |
"-XX:+PrintFlagsFinal", |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
90 |
"-version"); |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
91 |
return new OutputAnalyzer(pb.start()); |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
92 |
} |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
93 |
|
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
94 |
private static class MetaspaceFlags { |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
95 |
public long maxMetaspaceSize; |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
96 |
public long metaspaceSize; |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
97 |
public MetaspaceFlags(long maxMetaspaceSize, long metaspaceSize) { |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
98 |
this.maxMetaspaceSize = maxMetaspaceSize; |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
99 |
this.metaspaceSize = metaspaceSize; |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
100 |
} |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
101 |
} |
d0d0186a8cd6
8024650: Don't adjust MaxMetaspaceSize up to MetaspaceSize
stefank
parents:
diff
changeset
|
102 |
} |