Mercurial > hg > truffle
comparison test/runtime/NMT/MallocSiteHashOverflow.java @ 20628:80260967f994
8061969: [TESTBUG] MallocSiteHashOverflow.java should be enabled for 32-bit platforms
Reviewed-by: ctornqvi, coleenp
author | gtriantafill |
---|---|
date | Wed, 05 Nov 2014 08:22:17 -0800 |
parents | 3f9ff5e261c6 |
children | ec2c6fdd1ce6 |
comparison
equal
deleted
inserted
replaced
20627:e7b3d177adda | 20628:80260967f994 |
---|---|
22 */ | 22 */ |
23 | 23 |
24 /* | 24 /* |
25 * @test | 25 * @test |
26 * @summary Test corner case that overflows malloc site hashtable bucket | 26 * @summary Test corner case that overflows malloc site hashtable bucket |
27 * @requires sun.arch.data.model == "32" | |
27 * @key nmt jcmd stress | 28 * @key nmt jcmd stress |
28 * @library /testlibrary /testlibrary/whitebox | 29 * @library /testlibrary /testlibrary/whitebox |
29 * @ignore - This test is disabled since it will stress NMT and timeout during normal testing | 30 * @ignore 8062870 |
30 * @build MallocSiteHashOverflow | 31 * @build MallocSiteHashOverflow |
31 * @run main ClassFileInstaller sun.hotspot.WhiteBox | 32 * @run main ClassFileInstaller sun.hotspot.WhiteBox |
32 * @run main/othervm/timeout=480 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail MallocSiteHashOverflow | 33 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail MallocSiteHashOverflow |
33 */ | 34 */ |
34 | 35 |
35 import com.oracle.java.testlibrary.*; | 36 import com.oracle.java.testlibrary.*; |
36 import sun.hotspot.WhiteBox; | 37 import sun.hotspot.WhiteBox; |
37 | 38 |
38 public class MallocSiteHashOverflow { | 39 public class MallocSiteHashOverflow { |
39 private static long K = 1024; | 40 |
40 public static void main(String args[]) throws Exception { | 41 public static void main(String args[]) throws Exception { |
41 String vm_name = System.getProperty("java.vm.name"); | |
42 | 42 |
43 // Size of entries based on malloc tracking header defined in mallocTracker.hpp | |
43 // For 32-bit systems, create 257 malloc sites with the same hash bucket to overflow a hash bucket | 44 // For 32-bit systems, create 257 malloc sites with the same hash bucket to overflow a hash bucket |
44 // For 64-bit systems, create 64K + 1 malloc sites with the same hash bucket to overflow a hash bucket | |
45 long entries = 257; | 45 long entries = 257; |
46 if (Platform.is64bit()) { | |
47 entries = 64 * K + 1; | |
48 } | |
49 | 46 |
50 OutputAnalyzer output; | 47 OutputAnalyzer output; |
51 WhiteBox wb = WhiteBox.getWhiteBox(); | 48 WhiteBox wb = WhiteBox.getWhiteBox(); |
49 int MAX_HASH_SIZE = wb.NMTGetHashSize(); | |
52 | 50 |
53 // Grab my own PID | 51 // Grab my own PID |
54 String pid = Integer.toString(ProcessTools.getProcessId()); | 52 String pid = Integer.toString(ProcessTools.getProcessId()); |
55 ProcessBuilder pb = new ProcessBuilder(); | 53 ProcessBuilder pb = new ProcessBuilder(); |
56 | 54 |
57 wb.NMTOverflowHashBucket(entries); | 55 // Verify that current tracking level is "detail" |
58 | |
59 // Run 'jcmd <pid> VM.native_memory summary' | |
60 pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "statistics"}); | 56 pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "statistics"}); |
61 output = new OutputAnalyzer(pb.start()); | 57 output = new OutputAnalyzer(pb.start()); |
62 output.shouldContain("Tracking level has been downgraded due to lack of resources"); | 58 output.shouldContain("Native Memory Tracking Statistics"); |
59 | |
60 // Attempt to cause NMT to downgrade tracking level by allocating small amounts | |
61 // of memory with random pseudo call stack | |
62 int pc = 1; | |
63 for (int i = 0; i < entries; i++) { | |
64 long addr = wb.NMTMallocWithPseudoStack(1, pc); | |
65 if (addr == 0) { | |
66 throw new RuntimeException("NMTMallocWithPseudoStack: out of memory"); | |
67 } | |
68 // We free memory here since it doesn't affect pseudo malloc alloc site hash table entries | |
69 wb.NMTFree(addr); | |
70 pc += MAX_HASH_SIZE; | |
71 if (i == entries) { | |
72 // Verify that tracking has been downgraded | |
73 pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "statistics"}); | |
74 output = new OutputAnalyzer(pb.start()); | |
75 output.shouldContain("Tracking level has been downgraded due to lack of resources"); | |
76 } | |
77 } | |
63 } | 78 } |
64 } | 79 } |