提交 a9030ccc 编写于 作者: C cjplummer

8020829: JT_HS: 2 runtime NMT tests fail on platforms if NMT detail is not supported

Summary: Make tests query a new WhiteBox API to see if NMT detail is supported, and behave properly if it is not supported.
Reviewed-by: dholmes, coleenp
上级 3f09a38a
...@@ -128,7 +128,7 @@ WB_ENTRY(jint, WB_G1RegionSize(JNIEnv* env, jobject o)) ...@@ -128,7 +128,7 @@ WB_ENTRY(jint, WB_G1RegionSize(JNIEnv* env, jobject o))
WB_END WB_END
#endif // INCLUDE_ALL_GCS #endif // INCLUDE_ALL_GCS
#ifdef INCLUDE_NMT #if INCLUDE_NMT
// Alloc memory using the test memory type so that we can use that to see if // Alloc memory using the test memory type so that we can use that to see if
// NMT picks it up correctly // NMT picks it up correctly
WB_ENTRY(jlong, WB_NMTMalloc(JNIEnv* env, jobject o, jlong size)) WB_ENTRY(jlong, WB_NMTMalloc(JNIEnv* env, jobject o, jlong size))
...@@ -181,6 +181,10 @@ WB_ENTRY(jboolean, WB_NMTWaitForDataMerge(JNIEnv* env)) ...@@ -181,6 +181,10 @@ WB_ENTRY(jboolean, WB_NMTWaitForDataMerge(JNIEnv* env))
return MemTracker::wbtest_wait_for_data_merge(); return MemTracker::wbtest_wait_for_data_merge();
WB_END WB_END
WB_ENTRY(jboolean, WB_NMTIsDetailSupported(JNIEnv* env))
return MemTracker::tracking_level() == MemTracker::NMT_detail;
WB_END
#endif // INCLUDE_NMT #endif // INCLUDE_NMT
static jmethodID reflected_method_to_jmid(JavaThread* thread, JNIEnv* env, jobject method) { static jmethodID reflected_method_to_jmid(JavaThread* thread, JNIEnv* env, jobject method) {
...@@ -439,7 +443,7 @@ static JNINativeMethod methods[] = { ...@@ -439,7 +443,7 @@ static JNINativeMethod methods[] = {
{CC"g1NumFreeRegions", CC"()J", (void*)&WB_G1NumFreeRegions }, {CC"g1NumFreeRegions", CC"()J", (void*)&WB_G1NumFreeRegions },
{CC"g1RegionSize", CC"()I", (void*)&WB_G1RegionSize }, {CC"g1RegionSize", CC"()I", (void*)&WB_G1RegionSize },
#endif // INCLUDE_ALL_GCS #endif // INCLUDE_ALL_GCS
#ifdef INCLUDE_NMT #if INCLUDE_NMT
{CC"NMTMalloc", CC"(J)J", (void*)&WB_NMTMalloc }, {CC"NMTMalloc", CC"(J)J", (void*)&WB_NMTMalloc },
{CC"NMTFree", CC"(J)V", (void*)&WB_NMTFree }, {CC"NMTFree", CC"(J)V", (void*)&WB_NMTFree },
{CC"NMTReserveMemory", CC"(J)J", (void*)&WB_NMTReserveMemory }, {CC"NMTReserveMemory", CC"(J)J", (void*)&WB_NMTReserveMemory },
...@@ -447,6 +451,7 @@ static JNINativeMethod methods[] = { ...@@ -447,6 +451,7 @@ static JNINativeMethod methods[] = {
{CC"NMTUncommitMemory", CC"(JJ)V", (void*)&WB_NMTUncommitMemory }, {CC"NMTUncommitMemory", CC"(JJ)V", (void*)&WB_NMTUncommitMemory },
{CC"NMTReleaseMemory", CC"(JJ)V", (void*)&WB_NMTReleaseMemory }, {CC"NMTReleaseMemory", CC"(JJ)V", (void*)&WB_NMTReleaseMemory },
{CC"NMTWaitForDataMerge", CC"()Z", (void*)&WB_NMTWaitForDataMerge}, {CC"NMTWaitForDataMerge", CC"()Z", (void*)&WB_NMTWaitForDataMerge},
{CC"NMTIsDetailSupported",CC"()Z", (void*)&WB_NMTIsDetailSupported},
#endif // INCLUDE_NMT #endif // INCLUDE_NMT
{CC"deoptimizeAll", CC"()V", (void*)&WB_DeoptimizeAll }, {CC"deoptimizeAll", CC"()V", (void*)&WB_DeoptimizeAll },
{CC"deoptimizeMethod", CC"(Ljava/lang/reflect/Executable;Z)I", {CC"deoptimizeMethod", CC"(Ljava/lang/reflect/Executable;Z)I",
......
...@@ -45,6 +45,13 @@ public class ThreadedVirtualAllocTestType { ...@@ -45,6 +45,13 @@ public class ThreadedVirtualAllocTestType {
String pid = Integer.toString(ProcessTools.getProcessId()); String pid = Integer.toString(ProcessTools.getProcessId());
ProcessBuilder pb = new ProcessBuilder(); ProcessBuilder pb = new ProcessBuilder();
boolean has_nmt_detail = wb.NMTIsDetailSupported();
if (has_nmt_detail) {
System.out.println("NMT detail support detected.");
} else {
System.out.println("NMT detail support not detected.");
}
Thread reserveThread = new Thread() { Thread reserveThread = new Thread() {
public void run() { public void run() {
addr = wb.NMTReserveMemory(reserveSize); addr = wb.NMTReserveMemory(reserveSize);
...@@ -58,7 +65,9 @@ public class ThreadedVirtualAllocTestType { ...@@ -58,7 +65,9 @@ public class ThreadedVirtualAllocTestType {
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)");
output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + reserveSize) + "\\] reserved 512KB for Test"); if (has_nmt_detail) {
output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + reserveSize) + "\\] reserved 512KB for Test");
}
Thread commitThread = new Thread() { Thread commitThread = new Thread() {
public void run() { public void run() {
...@@ -72,7 +81,9 @@ public class ThreadedVirtualAllocTestType { ...@@ -72,7 +81,9 @@ public class ThreadedVirtualAllocTestType {
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
output.shouldContain("Test (reserved=512KB, committed=128KB)"); output.shouldContain("Test (reserved=512KB, committed=128KB)");
output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + commitSize) + "\\] committed 128KB"); if (has_nmt_detail) {
output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + commitSize) + "\\] committed 128KB");
}
Thread uncommitThread = new Thread() { Thread uncommitThread = new Thread() {
public void run() { public void run() {
......
...@@ -46,13 +46,22 @@ public class VirtualAllocTestType { ...@@ -46,13 +46,22 @@ public class VirtualAllocTestType {
String pid = Integer.toString(ProcessTools.getProcessId()); String pid = Integer.toString(ProcessTools.getProcessId());
ProcessBuilder pb = new ProcessBuilder(); ProcessBuilder pb = new ProcessBuilder();
boolean has_nmt_detail = wb.NMTIsDetailSupported();
if (has_nmt_detail) {
System.out.println("NMT detail support detected.");
} else {
System.out.println("NMT detail support not detected.");
}
addr = wb.NMTReserveMemory(reserveSize); addr = wb.NMTReserveMemory(reserveSize);
mergeData(); 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=256KB, committed=0KB)"); output.shouldContain("Test (reserved=256KB, committed=0KB)");
output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + reserveSize) + "\\] reserved 256KB for Test"); if (has_nmt_detail) {
output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + reserveSize) + "\\] reserved 256KB for Test");
}
wb.NMTCommitMemory(addr, commitSize); wb.NMTCommitMemory(addr, commitSize);
...@@ -60,7 +69,9 @@ public class VirtualAllocTestType { ...@@ -60,7 +69,9 @@ public class VirtualAllocTestType {
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
output.shouldContain("Test (reserved=256KB, committed=128KB)"); output.shouldContain("Test (reserved=256KB, committed=128KB)");
output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + commitSize) + "\\] committed 128KB"); if (has_nmt_detail) {
output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + commitSize) + "\\] committed 128KB");
}
wb.NMTUncommitMemory(addr, commitSize); wb.NMTUncommitMemory(addr, commitSize);
...@@ -71,7 +82,6 @@ public class VirtualAllocTestType { ...@@ -71,7 +82,6 @@ public class VirtualAllocTestType {
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(); mergeData();
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
......
...@@ -90,6 +90,7 @@ public class WhiteBox { ...@@ -90,6 +90,7 @@ public class WhiteBox {
public native void NMTUncommitMemory(long addr, long size); public native void NMTUncommitMemory(long addr, long size);
public native void NMTReleaseMemory(long addr, long size); public native void NMTReleaseMemory(long addr, long size);
public native boolean NMTWaitForDataMerge(); public native boolean NMTWaitForDataMerge();
public native boolean NMTIsDetailSupported();
// Compiler // Compiler
public native void deoptimizeAll(); public native void deoptimizeAll();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册