author | ctornqvi |
Fri, 19 Aug 2016 10:06:30 -0400 | |
changeset 40631 | ed82623d7831 |
parent 38089 | 9e58203ef0e2 |
permissions | -rw-r--r-- |
25952 | 1 |
/* |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
38089
diff
changeset
|
2 |
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. |
25952 | 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 |
/* |
|
25 |
* @test |
|
26 |
* @summary Test reserve/commit/uncommit/release of virtual memory and that we track it correctly |
|
27 |
* @key nmt jcmd |
|
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
38089
diff
changeset
|
28 |
* @library /test/lib |
36851 | 29 |
* @modules java.base/jdk.internal.misc |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
29574
diff
changeset
|
30 |
* java.management |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
38089
diff
changeset
|
31 |
* @build sun.hotspot.WhiteBox |
25952 | 32 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox |
33 |
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail VirtualAllocCommitUncommitRecommit |
|
34 |
* |
|
35 |
*/ |
|
36 |
||
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
38089
diff
changeset
|
37 |
import jdk.test.lib.process.ProcessTools; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
38089
diff
changeset
|
38 |
import jdk.test.lib.process.OutputAnalyzer; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
38089
diff
changeset
|
39 |
import jdk.test.lib.JDKToolFinder; |
25952 | 40 |
|
41 |
import sun.hotspot.WhiteBox; |
|
42 |
||
43 |
public class VirtualAllocCommitUncommitRecommit { |
|
44 |
||
45 |
public static WhiteBox wb = WhiteBox.getWhiteBox(); |
|
46 |
||
47 |
public static void main(String args[]) throws Exception { |
|
48 |
OutputAnalyzer output; |
|
26303
ef9b4c475c1d
8055844: [TESTBUG] test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java fails on Solaris Sparc due to incorrect page size being used
ctornqvi
parents:
26300
diff
changeset
|
49 |
long commitSize = 128 * 1024; // 128KB |
ef9b4c475c1d
8055844: [TESTBUG] test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java fails on Solaris Sparc due to incorrect page size being used
ctornqvi
parents:
26300
diff
changeset
|
50 |
long reserveSize = 4 * 1024 * 1024; // 4096KB |
25952 | 51 |
long addr; |
52 |
||
38089
9e58203ef0e2
8153992: Some hotspot tests fail on compact2 due to an unnecessary test library dependency
akulyakh
parents:
36851
diff
changeset
|
53 |
String pid = Long.toString(ProcessTools.getProcessId()); |
25952 | 54 |
ProcessBuilder pb = new ProcessBuilder(); |
55 |
||
56 |
// reserve |
|
57 |
addr = wb.NMTReserveMemory(reserveSize); |
|
58 |
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, |
|
59 |
"VM.native_memory", "detail" }); |
|
60 |
||
61 |
output = new OutputAnalyzer(pb.start()); |
|
26303
ef9b4c475c1d
8055844: [TESTBUG] test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java fails on Solaris Sparc due to incorrect page size being used
ctornqvi
parents:
26300
diff
changeset
|
62 |
output.shouldContain("Test (reserved=4096KB, committed=0KB)"); |
29574
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
63 |
output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
64 |
+ Long.toHexString(addr + reserveSize) |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
65 |
+ "\\] reserved 4096KB for Test"); |
25952 | 66 |
|
67 |
long addrA = addr; |
|
68 |
long addrB = addr + commitSize; |
|
69 |
long addrC = addr + (2 * commitSize); |
|
70 |
long addrD = addr + (3 * commitSize); |
|
71 |
long addrE = addr + (4 * commitSize); |
|
72 |
long addrF = addr + (5 * commitSize); |
|
73 |
||
74 |
// commit ABCD |
|
75 |
wb.NMTCommitMemory(addrA, commitSize); |
|
76 |
wb.NMTCommitMemory(addrB, commitSize); |
|
77 |
wb.NMTCommitMemory(addrC, commitSize); |
|
78 |
wb.NMTCommitMemory(addrD, commitSize); |
|
79 |
||
80 |
output = new OutputAnalyzer(pb.start()); |
|
26303
ef9b4c475c1d
8055844: [TESTBUG] test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java fails on Solaris Sparc due to incorrect page size being used
ctornqvi
parents:
26300
diff
changeset
|
81 |
output.shouldContain("Test (reserved=4096KB, committed=512KB)"); |
25952 | 82 |
|
29574
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
83 |
output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
84 |
+ Long.toHexString(addr + reserveSize) |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
85 |
+ "\\] reserved 4096KB for Test"); |
25952 | 86 |
// uncommit BC |
87 |
wb.NMTUncommitMemory(addrB, commitSize); |
|
88 |
wb.NMTUncommitMemory(addrC, commitSize); |
|
89 |
||
90 |
output = new OutputAnalyzer(pb.start()); |
|
26303
ef9b4c475c1d
8055844: [TESTBUG] test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java fails on Solaris Sparc due to incorrect page size being used
ctornqvi
parents:
26300
diff
changeset
|
91 |
output.shouldContain("Test (reserved=4096KB, committed=256KB)"); |
25952 | 92 |
|
29574
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
93 |
output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
94 |
+ Long.toHexString(addr + reserveSize) |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
95 |
+ "\\] reserved 4096KB for Test"); |
25952 | 96 |
|
97 |
// commit EF |
|
98 |
wb.NMTCommitMemory(addrE, commitSize); |
|
99 |
wb.NMTCommitMemory(addrF, commitSize); |
|
100 |
||
101 |
output = new OutputAnalyzer(pb.start()); |
|
26303
ef9b4c475c1d
8055844: [TESTBUG] test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java fails on Solaris Sparc due to incorrect page size being used
ctornqvi
parents:
26300
diff
changeset
|
102 |
output.shouldContain("Test (reserved=4096KB, committed=512KB)"); |
29574
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
103 |
output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
104 |
+ Long.toHexString(addr + reserveSize) |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
105 |
+ "\\] reserved 4096KB for Test"); |
25952 | 106 |
|
107 |
// uncommit A |
|
108 |
wb.NMTUncommitMemory(addrA, commitSize); |
|
109 |
||
110 |
output = new OutputAnalyzer(pb.start()); |
|
26303
ef9b4c475c1d
8055844: [TESTBUG] test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java fails on Solaris Sparc due to incorrect page size being used
ctornqvi
parents:
26300
diff
changeset
|
111 |
output.shouldContain("Test (reserved=4096KB, committed=384KB)"); |
29574
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
112 |
output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
113 |
+ Long.toHexString(addr + reserveSize) |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
114 |
+ "\\] reserved 4096KB for Test"); |
25952 | 115 |
|
116 |
// commit ABC |
|
117 |
wb.NMTCommitMemory(addrA, commitSize); |
|
118 |
wb.NMTCommitMemory(addrB, commitSize); |
|
119 |
wb.NMTCommitMemory(addrC, commitSize); |
|
120 |
||
121 |
output = new OutputAnalyzer(pb.start()); |
|
26303
ef9b4c475c1d
8055844: [TESTBUG] test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java fails on Solaris Sparc due to incorrect page size being used
ctornqvi
parents:
26300
diff
changeset
|
122 |
output.shouldContain("Test (reserved=4096KB, committed=768KB)"); |
29574
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
123 |
output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
124 |
+ Long.toHexString(addr + reserveSize) |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
125 |
+ "\\] reserved 4096KB for Test"); |
25952 | 126 |
|
127 |
// uncommit ABCDEF |
|
128 |
wb.NMTUncommitMemory(addrA, commitSize); |
|
129 |
wb.NMTUncommitMemory(addrB, commitSize); |
|
130 |
wb.NMTUncommitMemory(addrC, commitSize); |
|
131 |
wb.NMTUncommitMemory(addrD, commitSize); |
|
132 |
wb.NMTUncommitMemory(addrE, commitSize); |
|
133 |
wb.NMTUncommitMemory(addrF, commitSize); |
|
134 |
||
135 |
output = new OutputAnalyzer(pb.start()); |
|
26303
ef9b4c475c1d
8055844: [TESTBUG] test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java fails on Solaris Sparc due to incorrect page size being used
ctornqvi
parents:
26300
diff
changeset
|
136 |
output.shouldContain("Test (reserved=4096KB, committed=0KB)"); |
29574
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
137 |
output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
138 |
+ Long.toHexString(addr + reserveSize) |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
139 |
+ "\\] reserved 4096KB for Test"); |
25952 | 140 |
|
141 |
// release |
|
142 |
wb.NMTReleaseMemory(addr, reserveSize); |
|
143 |
output = new OutputAnalyzer(pb.start()); |
|
144 |
output.shouldNotContain("Test (reserved="); |
|
145 |
output.shouldNotMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" |
|
26303
ef9b4c475c1d
8055844: [TESTBUG] test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java fails on Solaris Sparc due to incorrect page size being used
ctornqvi
parents:
26300
diff
changeset
|
146 |
+ Long.toHexString(addr + reserveSize) + "\\] reserved 4096KB for Test"); |
25952 | 147 |
} |
148 |
} |