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