8044140: Create NMT (Native Memory Tracking) tests for NMT2

Create new/modify existing tests for NMT2, which is an internal redesign to address scalability issues in the first implementation.

Reviewed-by: ctornqvi, zgu
This commit is contained in:
George Triantafillou 2014-08-11 07:30:46 -07:00 committed by Zhengyu Gu
parent d595244c27
commit 69e7c05210
21 changed files with 49 additions and 113 deletions

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
@ -27,6 +27,6 @@
# It also contains test-suite configuration information. # It also contains test-suite configuration information.
# The list of keywords supported in this test suite # The list of keywords supported in this test suite
keys=cte_test jcmd nmt regression gc keys=cte_test jcmd nmt regression gc stress
groups=TEST.groups [closed/TEST.groups] groups=TEST.groups [closed/TEST.groups]

View File

@ -70,21 +70,29 @@ needs_jdk = \
runtime/7194254/Test7194254.java \ runtime/7194254/Test7194254.java \
runtime/Metaspace/FragmentMetaspace.java \ runtime/Metaspace/FragmentMetaspace.java \
runtime/NMT/BaselineWithParameter.java \ runtime/NMT/BaselineWithParameter.java \
runtime/NMT/JcmdBaselineDetail.java \
runtime/NMT/JcmdDetailDiff.java \
runtime/NMT/JcmdScaleDetail.java \
runtime/NMT/JcmdScale.java \ runtime/NMT/JcmdScale.java \
runtime/NMT/JcmdSummaryDiff.java \
runtime/NMT/JcmdWithNMTDisabled.java \ runtime/NMT/JcmdWithNMTDisabled.java \
runtime/NMT/MallocRoundingReportTest.java \
runtime/NMT/MallocSiteHashOverflow.java \
runtime/NMT/MallocStressTest.java \
runtime/NMT/MallocTestType.java \ runtime/NMT/MallocTestType.java \
runtime/NMT/ReleaseCommittedMemory.java \ runtime/NMT/ReleaseCommittedMemory.java \
runtime/NMT/ReleaseNoCommit.java \
runtime/NMT/ShutdownTwice.java \ runtime/NMT/ShutdownTwice.java \
runtime/NMT/SummaryAfterShutdown.java \ runtime/NMT/SummaryAfterShutdown.java \
runtime/NMT/SummarySanityCheck.java \ runtime/NMT/SummarySanityCheck.java \
runtime/NMT/ThreadedMallocTestType.java \ runtime/NMT/ThreadedMallocTestType.java \
runtime/NMT/ThreadedVirtualAllocTestType.java \ runtime/NMT/ThreadedVirtualAllocTestType.java \
runtime/NMT/VirtualAllocCommitUncommitRecommit.java \
runtime/NMT/VirtualAllocTestType.java \ runtime/NMT/VirtualAllocTestType.java \
runtime/RedefineObject/TestRedefineObject.java \ runtime/RedefineObject/TestRedefineObject.java \
runtime/Thread/TestThreadDumpMonitorContention.java \ runtime/Thread/TestThreadDumpMonitorContention.java \
runtime/XCheckJniJsig/XCheckJSig.java \ runtime/XCheckJniJsig/XCheckJSig.java \
serviceability/attach/AttachWithStalePidFile.java \ serviceability/attach/AttachWithStalePidFile.java \
serviceability/jvmti/8036666/GetObjectLockCount.java \
serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java \ serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java \
serviceability/dcmd/DynLibDcmdTest.java serviceability/dcmd/DynLibDcmdTest.java
@ -120,16 +128,12 @@ needs_compact3 = \
gc/6581734/Test6581734.java \ gc/6581734/Test6581734.java \
gc/7072527/TestFullGCCount.java \ gc/7072527/TestFullGCCount.java \
gc/g1/TestHumongousAllocInitialMark.java \ gc/g1/TestHumongousAllocInitialMark.java \
gc/g1/TestHumongousShrinkHeap.java \
gc/arguments/TestG1HeapRegionSize.java \ gc/arguments/TestG1HeapRegionSize.java \
gc/metaspace/TestMetaspaceMemoryPool.java \ gc/metaspace/TestMetaspaceMemoryPool.java \
gc/arguments/TestDynMinHeapFreeRatio.java \ gc/arguments/TestDynMinHeapFreeRatio.java \
gc/arguments/TestDynMaxHeapFreeRatio.java \ gc/arguments/TestDynMaxHeapFreeRatio.java \
gc/parallelScavenge/TestDynShrinkHeap.java \
runtime/InternalApi/ThreadCpuTimesDeadlock.java \ runtime/InternalApi/ThreadCpuTimesDeadlock.java \
serviceability/threads/TestFalseDeadLock.java \ serviceability/threads/TestFalseDeadLock.java \
serviceability/jvmti/GetObjectSizeOverflow.java \
serviceability/jvmti/TestRedefineWithUnresolvedClass.java
# Compact 2 adds full VM tests # Compact 2 adds full VM tests
compact2 = \ compact2 = \

View File

@ -27,6 +27,7 @@
* @key nmt jcmd regression * @key nmt jcmd regression
* @summary Regression test for invoking a jcmd with baseline=false, result was that the target VM crashed * @summary Regression test for invoking a jcmd with baseline=false, result was that the target VM crashed
* @library /testlibrary * @library /testlibrary
* @ignore
* @run main/othervm -XX:NativeMemoryTracking=detail BaselineWithParameter * @run main/othervm -XX:NativeMemoryTracking=detail BaselineWithParameter
*/ */

View File

@ -26,6 +26,7 @@
* @key nmt * @key nmt
* @summary Running with NMT detail should not result in an error * @summary Running with NMT detail should not result in an error
* @library /testlibrary * @library /testlibrary
* @ignore
*/ */
import com.oracle.java.testlibrary.*; import com.oracle.java.testlibrary.*;

View File

@ -26,6 +26,7 @@
* @key nmt * @key nmt
* @summary Empty argument to NMT should result in an informative error message * @summary Empty argument to NMT should result in an informative error message
* @library /testlibrary * @library /testlibrary
* @ignore
*/ */
import com.oracle.java.testlibrary.*; import com.oracle.java.testlibrary.*;

View File

@ -26,6 +26,7 @@
* @key nmt * @key nmt
* @summary Invalid argument to NMT should result in an informative error message * @summary Invalid argument to NMT should result in an informative error message
* @library /testlibrary * @library /testlibrary
* @ignore
*/ */
import com.oracle.java.testlibrary.*; import com.oracle.java.testlibrary.*;

View File

@ -26,6 +26,7 @@
* @key nmt * @key nmt
* @summary Running with NMT summary should not result in an error * @summary Running with NMT summary should not result in an error
* @library /testlibrary * @library /testlibrary
* @ignore
*/ */
import com.oracle.java.testlibrary.*; import com.oracle.java.testlibrary.*;

View File

@ -26,6 +26,7 @@
* @key nmt * @key nmt
* @summary Turning off NMT should not result in an error * @summary Turning off NMT should not result in an error
* @library /testlibrary * @library /testlibrary
* @ignore
*/ */
import com.oracle.java.testlibrary.*; import com.oracle.java.testlibrary.*;

View File

@ -26,6 +26,7 @@
* @key nmt jcmd * @key nmt jcmd
* @summary Test the NMT scale parameter * @summary Test the NMT scale parameter
* @library /testlibrary * @library /testlibrary
* @ignore
* @run main/othervm -XX:NativeMemoryTracking=summary JcmdScale * @run main/othervm -XX:NativeMemoryTracking=summary JcmdScale
*/ */
@ -41,15 +42,15 @@ public class JcmdScale {
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=KB"}); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=KB"});
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
output.shouldContain("KB, committed="); output.shouldContain("KB, committed=");
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=MB"}); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=MB"});
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
output.shouldContain("MB, committed="); output.shouldContain("MB, committed=");
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=GB"}); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=GB"});
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
output.shouldContain("GB, committed="); output.shouldContain("GB, committed=");
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=apa"}); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=apa"});
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
@ -57,7 +58,7 @@ public class JcmdScale {
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary", "scale=GB"}); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary", "scale=GB"});
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
output.shouldContain("GB, committed="); output.shouldContain("GB, committed=");
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary", "scale=apa"}); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary", "scale=apa"});
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());

View File

@ -26,6 +26,7 @@
* @key nmt jcmd * @key nmt jcmd
* @summary Verify that jcmd correctly reports that NMT is not enabled * @summary Verify that jcmd correctly reports that NMT is not enabled
* @library /testlibrary * @library /testlibrary
* @ignore
* @run main JcmdWithNMTDisabled 1 * @run main JcmdWithNMTDisabled 1
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -27,6 +27,7 @@
* @key nmt jcmd * @key nmt jcmd
* @library /testlibrary /testlibrary/whitebox * @library /testlibrary /testlibrary/whitebox
* @build MallocTestType * @build MallocTestType
* @ignore
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail MallocTestType * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail MallocTestType
*/ */
@ -51,11 +52,6 @@ public class MallocTestType {
long memAlloc1 = wb.NMTMalloc(512 * 1024); long memAlloc1 = wb.NMTMalloc(512 * 1024);
wb.NMTFree(memAlloc2); wb.NMTFree(memAlloc2);
// Use WB API to ensure that all data has been merged before we continue
if (!wb.NMTWaitForDataMerge()) {
throw new Exception("Call to WB API NMTWaitForDataMerge() failed");
}
// Run 'jcmd <pid> VM.native_memory summary' // Run 'jcmd <pid> VM.native_memory summary'
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"});
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
@ -64,10 +60,6 @@ public class MallocTestType {
// Free the memory allocated by NMTAllocTest // Free the memory allocated by NMTAllocTest
wb.NMTFree(memAlloc1); wb.NMTFree(memAlloc1);
// Use WB API to ensure that all data has been merged before we continue
if (!wb.NMTWaitForDataMerge()) {
throw new Exception("Call to WB API NMTWaitForDataMerge() failed");
}
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
output.shouldNotContain("Test (reserved="); output.shouldNotContain("Test (reserved=");
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -28,6 +28,7 @@
* @summary Make sure PrintNMTStatistics works on normal JVM exit * @summary Make sure PrintNMTStatistics works on normal JVM exit
* @library /testlibrary /testlibrary/whitebox * @library /testlibrary /testlibrary/whitebox
* @build PrintNMTStatistics * @build PrintNMTStatistics
* @ignore
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main PrintNMTStatistics * @run main PrintNMTStatistics
*/ */
@ -45,10 +46,6 @@ public class PrintNMTStatistics {
// We start a new java process running with an argument and use WB API to ensure // We start a new java process running with an argument and use WB API to ensure
// we have data for NMT on VM exit // we have data for NMT on VM exit
if (args.length > 0) { if (args.length > 0) {
// Use WB API to ensure that all data has been merged before we continue
if (!WhiteBox.getWhiteBox().NMTWaitForDataMerge()) {
throw new Exception("Call to WB API NMTWaitForDataMerge() failed");
}
return; return;
} }

View File

@ -26,6 +26,7 @@
* @key nmt * @key nmt
* @summary Trying to enable PrintNMTStatistics should result in a warning * @summary Trying to enable PrintNMTStatistics should result in a warning
* @library /testlibrary * @library /testlibrary
* @ignore
*/ */
import com.oracle.java.testlibrary.*; import com.oracle.java.testlibrary.*;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -28,6 +28,7 @@
* @key nmt regression * @key nmt regression
* @library /testlibrary /testlibrary/whitebox * @library /testlibrary /testlibrary/whitebox
* @build ReleaseCommittedMemory * @build ReleaseCommittedMemory
* @ignore
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail ReleaseCommittedMemory * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail ReleaseCommittedMemory
*/ */
@ -44,7 +45,6 @@ public class ReleaseCommittedMemory {
addr = wb.NMTReserveMemory(reserveSize); addr = wb.NMTReserveMemory(reserveSize);
wb.NMTCommitMemory(addr, 128*1024); wb.NMTCommitMemory(addr, 128*1024);
wb.NMTReleaseMemory(addr, reserveSize); wb.NMTReleaseMemory(addr, reserveSize);
wb.NMTWaitForDataMerge();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,6 +26,7 @@
* @key nmt jcmd * @key nmt jcmd
* @summary Run shutdown twice * @summary Run shutdown twice
* @library /testlibrary * @library /testlibrary
* @ignore
* @run main/othervm -XX:NativeMemoryTracking=detail ShutdownTwice * @run main/othervm -XX:NativeMemoryTracking=detail ShutdownTwice
*/ */
@ -45,12 +46,12 @@ public class ShutdownTwice {
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
// Verify that jcmd reports that NMT is shutting down // Verify that jcmd reports that NMT is shutting down
output.shouldContain("Shutdown is in progress, it will take a few moments to completely shutdown"); output.shouldContain("Native memory tracking has been turned off");
// Run shutdown again // Run shutdown again
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
// Verify that jcmd reports that NMT has been shutdown already // Verify that jcmd reports that NMT has been shutdown already
output.shouldContain("Native memory tracking has been shutdown by user"); output.shouldContain("Native memory tracking has been shutdown");
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,6 +26,7 @@
* @key nmt jcmd * @key nmt jcmd
* @summary Verify that jcmd correctly reports that NMT is not enabled after a shutdown * @summary Verify that jcmd correctly reports that NMT is not enabled after a shutdown
* @library /testlibrary * @library /testlibrary
* @ignore
* @run main/othervm -XX:NativeMemoryTracking=detail SummaryAfterShutdown * @run main/othervm -XX:NativeMemoryTracking=detail SummaryAfterShutdown
*/ */
@ -44,13 +45,13 @@ public class SummaryAfterShutdown {
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
// Verify that jcmd reports that NMT is shutting down // Verify that jcmd reports that NMT is shutting down
output.shouldContain("Shutdown is in progress, it will take a few moments to completely shutdown"); output.shouldContain("Native memory tracking has been turned off");
// Run 'jcmd <pid> VM.native_memory summary' // Run 'jcmd <pid> VM.native_memory summary'
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"});
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
// Verify that jcmd reports that NMT has been shutdown // Verify that jcmd reports that NMT has been shutdown
output.shouldContain("Native memory tracking has been shutdown by user"); output.shouldContain("Native memory tracking has been shutdown");
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -27,6 +27,7 @@
* @summary Sanity check the output of NMT * @summary Sanity check the output of NMT
* @library /testlibrary /testlibrary/whitebox * @library /testlibrary /testlibrary/whitebox
* @build SummarySanityCheck * @build SummarySanityCheck
* @ignore
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:NativeMemoryTracking=summary -XX:+WhiteBoxAPI SummarySanityCheck * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:NativeMemoryTracking=summary -XX:+WhiteBoxAPI SummarySanityCheck
*/ */
@ -44,11 +45,6 @@ public class SummarySanityCheck {
// Grab my own PID // Grab my own PID
String pid = Integer.toString(ProcessTools.getProcessId()); String pid = Integer.toString(ProcessTools.getProcessId());
// Use WB API to ensure that all data has been merged before we continue
if (!WhiteBox.getWhiteBox().NMTWaitForDataMerge()) {
throw new Exception("Call to WB API NMTWaitForDataMerge() failed");
}
ProcessBuilder pb = new ProcessBuilder(); ProcessBuilder pb = new ProcessBuilder();
// Run 'jcmd <pid> VM.native_memory summary scale=KB' // Run 'jcmd <pid> VM.native_memory summary scale=KB'
@ -69,13 +65,13 @@ public class SummarySanityCheck {
// Match '- <mtType> (reserved=<reserved>KB, committed=<committed>KB) // Match '- <mtType> (reserved=<reserved>KB, committed=<committed>KB)
Pattern mtTypePattern = Pattern.compile("-\\s+(?<typename>[\\w\\s]+)\\(reserved=(?<reserved>\\d+)KB,\\scommitted=(?<committed>\\d+)KB\\)"); Pattern mtTypePattern = Pattern.compile("-\\s+(?<typename>[\\w\\s]+)\\(reserved=(?<reserved>\\d+)KB,\\scommitted=(?<committed>\\d+)KB\\)");
// Match 'Total: reserved=<reserved>KB, committed=<committed>KB' // Match 'Total: reserved=<reserved>KB, committed=<committed>KB'
Pattern totalMemoryPattern = Pattern.compile("Total\\:\\s\\sreserved=(?<reserved>\\d+)KB,\\s\\scommitted=(?<committed>\\d+)KB"); Pattern totalMemoryPattern = Pattern.compile("Total\\:\\sreserved=(?<reserved>\\d+)KB,\\scommitted=(?<committed>\\d+)KB");
for (int i = 0; i < lines.length; i++) { for (int i = 0; i < lines.length; i++) {
if (lines[i].startsWith("Total")) { if (lines[i].startsWith("Total")) {
Matcher totalMemoryMatcher = totalMemoryPattern.matcher(lines[i]); Matcher totalMemoryMatcher = totalMemoryPattern.matcher(lines[i]);
if (totalMemoryMatcher.matches() && totalMemoryMatcher.groupCount() == 2) { if (totalMemoryMatcher.matches()) {
totalCommitted = Integer.parseInt(totalMemoryMatcher.group("committed")); totalCommitted = Integer.parseInt(totalMemoryMatcher.group("committed"));
totalReserved = Integer.parseInt(totalMemoryMatcher.group("reserved")); totalReserved = Integer.parseInt(totalMemoryMatcher.group("reserved"));
} else { } else {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,6 +26,7 @@
* @key nmt jcmd * @key nmt jcmd
* @library /testlibrary /testlibrary/whitebox * @library /testlibrary /testlibrary/whitebox
* @build ThreadedMallocTestType * @build ThreadedMallocTestType
* @ignore
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail ThreadedMallocTestType * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail ThreadedMallocTestType
*/ */
@ -58,11 +59,6 @@ public class ThreadedMallocTestType {
allocThread.start(); allocThread.start();
allocThread.join(); allocThread.join();
// Use WB API to ensure that all data has been merged before we continue
if (!wb.NMTWaitForDataMerge()) {
throw new Exception("Call to WB API NMTWaitForDataMerge() failed");
}
// Run 'jcmd <pid> VM.native_memory summary' // Run 'jcmd <pid> VM.native_memory summary'
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"});
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
@ -80,11 +76,6 @@ public class ThreadedMallocTestType {
freeThread.start(); freeThread.start();
freeThread.join(); freeThread.join();
// Use WB API to ensure that all data has been merged before we continue
if (!wb.NMTWaitForDataMerge()) {
throw new Exception("Call to WB API NMTWaitForDataMerge() failed");
}
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
output.shouldNotContain("Test (reserved="); output.shouldNotContain("Test (reserved=");
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,6 +26,7 @@
* @key nmt jcmd * @key nmt jcmd
* @library /testlibrary /testlibrary/whitebox * @library /testlibrary /testlibrary/whitebox
* @build ThreadedVirtualAllocTestType * @build ThreadedVirtualAllocTestType
* @ignore
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail ThreadedVirtualAllocTestType * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail ThreadedVirtualAllocTestType
*/ */
@ -60,8 +61,6 @@ public class ThreadedVirtualAllocTestType {
reserveThread.start(); reserveThread.start();
reserveThread.join(); reserveThread.join();
mergeData();
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "detail"}); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "detail"});
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
output.shouldContain("Test (reserved=512KB, committed=0KB)"); output.shouldContain("Test (reserved=512KB, committed=0KB)");
@ -77,8 +76,6 @@ public class ThreadedVirtualAllocTestType {
commitThread.start(); commitThread.start();
commitThread.join(); commitThread.join();
mergeData();
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
output.shouldContain("Test (reserved=512KB, committed=128KB)"); output.shouldContain("Test (reserved=512KB, committed=128KB)");
if (has_nmt_detail) { if (has_nmt_detail) {
@ -93,8 +90,6 @@ public class ThreadedVirtualAllocTestType {
uncommitThread.start(); uncommitThread.start();
uncommitThread.join(); uncommitThread.join();
mergeData();
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
output.shouldContain("Test (reserved=512KB, committed=0KB)"); output.shouldContain("Test (reserved=512KB, committed=0KB)");
output.shouldNotMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + commitSize) + "\\] committed"); output.shouldNotMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + commitSize) + "\\] committed");
@ -107,17 +102,9 @@ public class ThreadedVirtualAllocTestType {
releaseThread.start(); releaseThread.start();
releaseThread.join(); releaseThread.join();
mergeData();
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
output.shouldNotContain("Test (reserved="); output.shouldNotContain("Test (reserved=");
output.shouldNotContain("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + reserveSize) + "\\] reserved"); output.shouldNotContain("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + reserveSize) + "\\] reserved");
} }
public static void mergeData() throws Exception {
// Use WB API to ensure that all data has been merged before we continue
if (!wb.NMTWaitForDataMerge()) {
throw new Exception("Call to WB API NMTWaitForDataMerge() failed");
} }
}
}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,6 +26,7 @@
* @summary Test Reserve/Commit/Uncommit/Release of virtual memory and that we track it correctly * @summary Test Reserve/Commit/Uncommit/Release of virtual memory and that we track it correctly
* @key nmt jcmd * @key nmt jcmd
* @library /testlibrary /testlibrary/whitebox * @library /testlibrary /testlibrary/whitebox
* @ignore
* @build VirtualAllocTestType * @build VirtualAllocTestType
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail VirtualAllocTestType * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail VirtualAllocTestType
@ -54,7 +55,6 @@ public class VirtualAllocTestType {
} }
addr = wb.NMTReserveMemory(reserveSize); addr = wb.NMTReserveMemory(reserveSize);
mergeData();
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "detail"}); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "detail"});
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
@ -65,7 +65,6 @@ public class VirtualAllocTestType {
wb.NMTCommitMemory(addr, commitSize); wb.NMTCommitMemory(addr, commitSize);
mergeData();
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
output.shouldContain("Test (reserved=256KB, committed=128KB)"); output.shouldContain("Test (reserved=256KB, committed=128KB)");
@ -75,24 +74,15 @@ public class VirtualAllocTestType {
wb.NMTUncommitMemory(addr, commitSize); wb.NMTUncommitMemory(addr, commitSize);
mergeData();
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
output.shouldContain("Test (reserved=256KB, committed=0KB)"); output.shouldContain("Test (reserved=256KB, committed=0KB)");
output.shouldNotMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + commitSize) + "\\] committed"); output.shouldNotMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + commitSize) + "\\] committed");
wb.NMTReleaseMemory(addr, reserveSize); wb.NMTReleaseMemory(addr, reserveSize);
mergeData();
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
output.shouldNotContain("Test (reserved="); output.shouldNotContain("Test (reserved=");
output.shouldNotMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + reserveSize) + "\\] reserved"); output.shouldNotMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + reserveSize) + "\\] reserved");
} }
public static void mergeData() throws Exception {
// Use WB API to ensure that all data has been merged before we continue
if (!wb.NMTWaitForDataMerge()) {
throw new Exception("Call to WB API NMTWaitForDataMerge() failed");
} }
}
}

View File

@ -25,10 +25,6 @@
package sun.hotspot; package sun.hotspot;
import java.lang.reflect.Executable; import java.lang.reflect.Executable;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Stream;
import java.security.BasicPermission; import java.security.BasicPermission;
import sun.hotspot.parser.DiagnosticCommand; import sun.hotspot.parser.DiagnosticCommand;
@ -134,7 +130,7 @@ public class WhiteBox {
} }
public native int getCompileQueueSize(int compLevel); public native int getCompileQueueSize(int compLevel);
public native boolean testSetForceInlineMethod(Executable method, boolean value); public native boolean testSetForceInlineMethod(Executable method, boolean value);
public boolean enqueueMethodForCompilation(Executable method, int compLevel) { public boolean enqueueMethodForCompilation(Executable method, int compLevel) {
return enqueueMethodForCompilation(method, compLevel, -1 /*InvocationEntryBci*/); return enqueueMethodForCompilation(method, compLevel, -1 /*InvocationEntryBci*/);
} }
public native boolean enqueueMethodForCompilation(Executable method, int compLevel, int entry_bci); public native boolean enqueueMethodForCompilation(Executable method, int compLevel, int entry_bci);
@ -147,8 +143,6 @@ public class WhiteBox {
// Memory // Memory
public native void readReservedMemory(); public native void readReservedMemory();
public native long allocateMetaspace(ClassLoader classLoader, long size);
public native void freeMetaspace(ClassLoader classLoader, long addr, long size);
// force Full GC // force Full GC
public native void fullGC(); public native void fullGC();
@ -157,34 +151,8 @@ public class WhiteBox {
public native int stressVirtualSpaceResize(long reservedSpaceSize, long magnitude, long iterations); public native int stressVirtualSpaceResize(long reservedSpaceSize, long magnitude, long iterations);
public native void runMemoryUnitTests(); public native void runMemoryUnitTests();
public native void readFromNoaccessArea(); public native void readFromNoaccessArea();
public native long getThreadStackSize();
public native long getThreadRemainingStackSize();
// CPU features // CPU features
public native String getCPUFeatures(); public native String getCPUFeatures();
// VM flags
public native void setBooleanVMFlag(String name, boolean value);
public native void setIntxVMFlag(String name, long value);
public native void setUintxVMFlag(String name, long value);
public native void setUint64VMFlag(String name, long value);
public native void setStringVMFlag(String name, String value);
public native void setDoubleVMFlag(String name, double value);
public native Boolean getBooleanVMFlag(String name);
public native Long getIntxVMFlag(String name);
public native Long getUintxVMFlag(String name);
public native Long getUint64VMFlag(String name);
public native String getStringVMFlag(String name);
public native Double getDoubleVMFlag(String name);
private final List<Function<String,Object>> flagsGetters = Arrays.asList(
this::getBooleanVMFlag, this::getIntxVMFlag, this::getUintxVMFlag,
this::getUint64VMFlag, this::getStringVMFlag, this::getDoubleVMFlag);
public Object getVMFlag(String name) {
return flagsGetters.stream()
.map(f -> f.apply(name))
.filter(x -> x != null)
.findAny()
.orElse(null);
}
} }