author | cjplummer |
Thu, 29 Oct 2015 12:04:04 -0700 | |
changeset 33730 | 30e064828045 |
parent 30604 | b8d532cb6420 |
child 36851 | 03e2f4d0a421 |
permissions | -rw-r--r-- |
25952 | 1 |
/* |
29574
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
2 |
* Copyright (c) 2014, 2015, 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 |
|
33730
30e064828045
8140189: [TESTBUG] Get rid of "@library /../../test/lib" in jtreg tests
cjplummer
parents:
30604
diff
changeset
|
28 |
* @library /testlibrary /test/lib |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
29574
diff
changeset
|
29 |
* @modules java.base/sun.misc |
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
29574
diff
changeset
|
30 |
* java.management |
25952 | 31 |
* @build VirtualAllocCommitUncommitRecommit |
32 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox |
|
33 |
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail VirtualAllocCommitUncommitRecommit |
|
34 |
* |
|
35 |
*/ |
|
36 |
||
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
29678
diff
changeset
|
37 |
import jdk.test.lib.*; |
25952 | 38 |
|
39 |
import sun.hotspot.WhiteBox; |
|
40 |
||
41 |
public class VirtualAllocCommitUncommitRecommit { |
|
42 |
||
43 |
public static WhiteBox wb = WhiteBox.getWhiteBox(); |
|
44 |
||
45 |
public static void main(String args[]) throws Exception { |
|
46 |
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
|
47 |
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
|
48 |
long reserveSize = 4 * 1024 * 1024; // 4096KB |
25952 | 49 |
long addr; |
50 |
||
51 |
String pid = Integer.toString(ProcessTools.getProcessId()); |
|
52 |
ProcessBuilder pb = new ProcessBuilder(); |
|
53 |
||
54 |
// reserve |
|
55 |
addr = wb.NMTReserveMemory(reserveSize); |
|
56 |
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, |
|
57 |
"VM.native_memory", "detail" }); |
|
58 |
||
59 |
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
|
60 |
output.shouldContain("Test (reserved=4096KB, committed=0KB)"); |
29574
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
61 |
output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
62 |
+ Long.toHexString(addr + reserveSize) |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
63 |
+ "\\] reserved 4096KB for Test"); |
25952 | 64 |
|
65 |
long addrA = addr; |
|
66 |
long addrB = addr + commitSize; |
|
67 |
long addrC = addr + (2 * commitSize); |
|
68 |
long addrD = addr + (3 * commitSize); |
|
69 |
long addrE = addr + (4 * commitSize); |
|
70 |
long addrF = addr + (5 * commitSize); |
|
71 |
||
72 |
// commit ABCD |
|
73 |
wb.NMTCommitMemory(addrA, commitSize); |
|
74 |
wb.NMTCommitMemory(addrB, commitSize); |
|
75 |
wb.NMTCommitMemory(addrC, commitSize); |
|
76 |
wb.NMTCommitMemory(addrD, commitSize); |
|
77 |
||
78 |
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
|
79 |
output.shouldContain("Test (reserved=4096KB, committed=512KB)"); |
25952 | 80 |
|
29574
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
81 |
output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
82 |
+ Long.toHexString(addr + reserveSize) |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
83 |
+ "\\] reserved 4096KB for Test"); |
25952 | 84 |
// uncommit BC |
85 |
wb.NMTUncommitMemory(addrB, commitSize); |
|
86 |
wb.NMTUncommitMemory(addrC, commitSize); |
|
87 |
||
88 |
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
|
89 |
output.shouldContain("Test (reserved=4096KB, committed=256KB)"); |
25952 | 90 |
|
29574
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
91 |
output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
92 |
+ Long.toHexString(addr + reserveSize) |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
93 |
+ "\\] reserved 4096KB for Test"); |
25952 | 94 |
|
95 |
// commit EF |
|
96 |
wb.NMTCommitMemory(addrE, commitSize); |
|
97 |
wb.NMTCommitMemory(addrF, commitSize); |
|
98 |
||
99 |
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
|
100 |
output.shouldContain("Test (reserved=4096KB, committed=512KB)"); |
29574
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
101 |
output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
102 |
+ Long.toHexString(addr + reserveSize) |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
103 |
+ "\\] reserved 4096KB for Test"); |
25952 | 104 |
|
105 |
// uncommit A |
|
106 |
wb.NMTUncommitMemory(addrA, commitSize); |
|
107 |
||
108 |
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
|
109 |
output.shouldContain("Test (reserved=4096KB, committed=384KB)"); |
29574
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
110 |
output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
111 |
+ Long.toHexString(addr + reserveSize) |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
112 |
+ "\\] reserved 4096KB for Test"); |
25952 | 113 |
|
114 |
// commit ABC |
|
115 |
wb.NMTCommitMemory(addrA, commitSize); |
|
116 |
wb.NMTCommitMemory(addrB, commitSize); |
|
117 |
wb.NMTCommitMemory(addrC, commitSize); |
|
118 |
||
119 |
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
|
120 |
output.shouldContain("Test (reserved=4096KB, committed=768KB)"); |
29574
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
121 |
output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
122 |
+ Long.toHexString(addr + reserveSize) |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
123 |
+ "\\] reserved 4096KB for Test"); |
25952 | 124 |
|
125 |
// uncommit ABCDEF |
|
126 |
wb.NMTUncommitMemory(addrA, commitSize); |
|
127 |
wb.NMTUncommitMemory(addrB, commitSize); |
|
128 |
wb.NMTUncommitMemory(addrC, commitSize); |
|
129 |
wb.NMTUncommitMemory(addrD, commitSize); |
|
130 |
wb.NMTUncommitMemory(addrE, commitSize); |
|
131 |
wb.NMTUncommitMemory(addrF, commitSize); |
|
132 |
||
133 |
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
|
134 |
output.shouldContain("Test (reserved=4096KB, committed=0KB)"); |
29574
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
135 |
output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
136 |
+ Long.toHexString(addr + reserveSize) |
ab0121071f54
8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents:
28190
diff
changeset
|
137 |
+ "\\] reserved 4096KB for Test"); |
25952 | 138 |
|
139 |
// release |
|
140 |
wb.NMTReleaseMemory(addr, reserveSize); |
|
141 |
output = new OutputAnalyzer(pb.start()); |
|
142 |
output.shouldNotContain("Test (reserved="); |
|
143 |
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
|
144 |
+ Long.toHexString(addr + reserveSize) + "\\] reserved 4096KB for Test"); |
25952 | 145 |
} |
146 |
} |