author | jdv |
Tue, 09 Aug 2016 13:45:17 +0530 | |
changeset 40432 | 6a878eae7459 |
parent 39221 | 4249544a9196 |
child 40631 | ed82623d7831 |
permissions | -rw-r--r-- |
38935 | 1 |
/* |
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
38935 | 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 commits of overlapping regions of memory. |
|
27 |
* @key nmt jcmd |
|
28 |
* @library /testlibrary /test/lib |
|
29 |
* @modules java.base/jdk.internal.misc |
|
30 |
* java.management |
|
31 |
* @build CommitOverlappingRegions |
|
32 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox |
|
33 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
|
34 |
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail CommitOverlappingRegions |
|
35 |
*/ |
|
36 |
||
37 |
import jdk.test.lib.*; |
|
38 |
import sun.hotspot.WhiteBox; |
|
39 |
||
40 |
public class CommitOverlappingRegions { |
|
41 |
public static WhiteBox wb = WhiteBox.getWhiteBox(); |
|
42 |
public static void main(String args[]) throws Exception { |
|
43 |
OutputAnalyzer output; |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
44 |
|
38935 | 45 |
long size = 32 * 1024; |
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
46 |
int pagesize = wb.getVMPageSize(); |
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
47 |
if (size < pagesize) { size = pagesize; } // Should be aligned. |
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
48 |
long sizek = size / 1024; |
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
49 |
|
38935 | 50 |
long addr = wb.NMTReserveMemory(8*size); |
51 |
||
52 |
String pid = Long.toString(ProcessTools.getProcessId()); |
|
53 |
ProcessBuilder pb = new ProcessBuilder(); |
|
54 |
||
55 |
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "detail"}); |
|
56 |
System.out.println("Address is " + Long.toHexString(addr)); |
|
57 |
||
58 |
// Start: . . . . . . . . |
|
59 |
output = new OutputAnalyzer(pb.start()); |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
60 |
output.shouldContain("Test (reserved=" + 8*sizek + "KB, committed=0KB)"); |
38935 | 61 |
|
62 |
// Committing: * * * . . . . . |
|
63 |
// Region: * * * . . . . . |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
64 |
// Expected Total: 3 x sizek KB |
38935 | 65 |
wb.NMTCommitMemory(addr + 0*size, 3*size); |
66 |
||
67 |
// Committing: . . . . * * * . |
|
68 |
// Region: * * * . * * * . |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
69 |
// Expected Total: 6 x sizek KB |
38935 | 70 |
wb.NMTCommitMemory(addr + 4*size, 3*size); |
71 |
||
72 |
// Check output after first 2 commits. |
|
73 |
output = new OutputAnalyzer(pb.start()); |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
74 |
output.shouldContain("Test (reserved=" + 8*sizek + "KB, committed=" + 6*sizek + "KB)"); |
38935 | 75 |
|
76 |
// Committing: . . * * * . . . |
|
77 |
// Region: * * * * * * * . |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
78 |
// Expected Total: 7 x sizek KB |
38935 | 79 |
wb.NMTCommitMemory(addr + 2*size, 3*size); |
80 |
||
81 |
// Check output after overlapping commit. |
|
82 |
output = new OutputAnalyzer(pb.start()); |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
83 |
output.shouldContain("Test (reserved=" + 8*sizek + "KB, committed=" + 7*sizek + "KB)"); |
38935 | 84 |
|
85 |
// Uncommitting: * * * * * * * * |
|
86 |
// Region: . . . . . . . . |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
87 |
// Expected Total: 0 x sizek KB |
38935 | 88 |
wb.NMTUncommitMemory(addr + 0*size, 8*size); |
89 |
output = new OutputAnalyzer(pb.start()); |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
90 |
output.shouldContain("Test (reserved=" + 8*sizek + "KB, committed=0KB)"); |
38935 | 91 |
|
92 |
// Committing: * * . . . . . . |
|
93 |
// Region: * * . . . . . . |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
94 |
// Expected Total: 2 x sizek KB |
38935 | 95 |
wb.NMTCommitMemory(addr + 0*size, 2*size); |
96 |
output = new OutputAnalyzer(pb.start()); |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
97 |
output.shouldContain("Test (reserved=" + 8*sizek + "KB, committed=" + 2*sizek + "KB)"); |
38935 | 98 |
|
99 |
// Committing: . * * * . . . . |
|
100 |
// Region: * * * * . . . . |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
101 |
// Expected Total: 4 x sizek KB |
38935 | 102 |
wb.NMTCommitMemory(addr + 1*size, 3*size); |
103 |
output = new OutputAnalyzer(pb.start()); |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
104 |
output.shouldContain("Test (reserved=" + 8*sizek + "KB, committed=" + 4*sizek + "KB)"); |
38935 | 105 |
|
106 |
// Uncommitting: * * * . . . . . |
|
107 |
// Region: . . . * . . . . |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
108 |
// Expected Total: 1 x sizek KB |
38935 | 109 |
wb.NMTUncommitMemory(addr + 0*size, 3*size); |
110 |
output = new OutputAnalyzer(pb.start()); |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
111 |
output.shouldContain("Test (reserved=" + 8*sizek + "KB, committed=" + 1*sizek + "KB)"); |
38935 | 112 |
|
113 |
// Committing: . . . * * . . . |
|
114 |
// Region: . . . * * . . . |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
115 |
// Expected Total: 2 x sizek KB |
38935 | 116 |
wb.NMTCommitMemory(addr + 3*size, 2*size); |
117 |
System.out.println("Address is " + Long.toHexString(addr + 3*size)); |
|
118 |
output = new OutputAnalyzer(pb.start()); |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
119 |
output.shouldContain("Test (reserved=" + 8*sizek + "KB, committed=" + 2*sizek + "KB)"); |
38935 | 120 |
|
121 |
// Committing: . . . . * * . . |
|
122 |
// Region: . . . * * * . . |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
123 |
// Expected Total: 3 x sizek KB |
38935 | 124 |
wb.NMTCommitMemory(addr + 4*size, 2*size); |
125 |
output = new OutputAnalyzer(pb.start()); |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
126 |
output.shouldContain("Test (reserved=" + 8*sizek + "KB, committed=" + 3*sizek + "KB)"); |
38935 | 127 |
|
128 |
// Committing: . . . . . * * . |
|
129 |
// Region: . . . * * * * . |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
130 |
// Expected Total: 4 x sizek KB |
38935 | 131 |
wb.NMTCommitMemory(addr + 5*size, 2*size); |
132 |
output = new OutputAnalyzer(pb.start()); |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
133 |
output.shouldContain("Test (reserved=" + 8*sizek + "KB, committed=" + 4*sizek + "KB)"); |
38935 | 134 |
|
135 |
// Committing: . . . . . . * * |
|
136 |
// Region: . . . * * * * * |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
137 |
// Expected Total: 5 x sizek KB |
38935 | 138 |
wb.NMTCommitMemory(addr + 6*size, 2*size); |
139 |
output = new OutputAnalyzer(pb.start()); |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
140 |
output.shouldContain("Test (reserved=" + 8*sizek + "KB, committed=" + 5*sizek + "KB)"); |
38935 | 141 |
|
142 |
// Uncommitting: * * * * * * * * |
|
143 |
// Region: . . . . . . . . |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
144 |
// Expected Total: 0 x sizek KB |
38935 | 145 |
wb.NMTUncommitMemory(addr + 0*size, 8*size); |
146 |
output = new OutputAnalyzer(pb.start()); |
|
39221
4249544a9196
8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K
goetz
parents:
38935
diff
changeset
|
147 |
output.shouldContain("Test (reserved=" + 8*sizek + "KB, committed=0KB)"); |
38935 | 148 |
} |
149 |
} |