--- old/src/share/vm/prims/whitebox.cpp 2015-05-19 13:49:52.070525470 +0200 +++ new/src/share/vm/prims/whitebox.cpp 2015-05-19 13:49:52.001523456 +0200 @@ -89,6 +89,10 @@ return os::vm_page_size(); WB_END +WB_ENTRY(jlong, WB_GetVMAllocationGranularity(JNIEnv* env, jobject o)) + return os::vm_allocation_granularity(); +WB_END + WB_ENTRY(jlong, WB_GetVMLargePageSize(JNIEnv* env, jobject o)) return os::large_page_size(); WB_END @@ -1263,13 +1267,14 @@ #define CC (char*) static JNINativeMethod methods[] = { - {CC"getObjectAddress0", CC"(Ljava/lang/Object;)J", (void*)&WB_GetObjectAddress }, - {CC"getObjectSize0", CC"(Ljava/lang/Object;)J", (void*)&WB_GetObjectSize }, - {CC"isObjectInOldGen0", CC"(Ljava/lang/Object;)Z", (void*)&WB_isObjectInOldGen }, - {CC"getHeapOopSize", CC"()I", (void*)&WB_GetHeapOopSize }, - {CC"getVMPageSize", CC"()I", (void*)&WB_GetVMPageSize }, - {CC"getVMLargePageSize", CC"()J", (void*)&WB_GetVMLargePageSize}, - {CC"isClassAlive0", CC"(Ljava/lang/String;)Z", (void*)&WB_IsClassAlive }, + {CC"getObjectAddress0", CC"(Ljava/lang/Object;)J", (void*)&WB_GetObjectAddress }, + {CC"getObjectSize0", CC"(Ljava/lang/Object;)J", (void*)&WB_GetObjectSize }, + {CC"isObjectInOldGen0", CC"(Ljava/lang/Object;)Z", (void*)&WB_isObjectInOldGen }, + {CC"getHeapOopSize", CC"()I", (void*)&WB_GetHeapOopSize }, + {CC"getVMPageSize", CC"()I", (void*)&WB_GetVMPageSize }, + {CC"getVMAllocationGranularity", CC"()J", (void*)&WB_GetVMAllocationGranularity }, + {CC"getVMLargePageSize", CC"()J", (void*)&WB_GetVMLargePageSize}, + {CC"isClassAlive0", CC"(Ljava/lang/String;)Z", (void*)&WB_IsClassAlive }, {CC"parseCommandLine0", CC"(Ljava/lang/String;C[Lsun/hotspot/parser/DiagnosticCommand;)[Ljava/lang/Object;", (void*) &WB_ParseCommandLine --- old/test/gc/g1/TestLargePageUseForAuxMemory.java 2015-05-19 13:49:52.455536709 +0200 +++ new/test/gc/g1/TestLargePageUseForAuxMemory.java 2015-05-19 13:49:52.388534753 +0200 @@ -24,25 +24,28 @@ /* * @test TestLargePageUseForAuxMemory.java * @summary Test that auxiliary data structures are allocated using large pages if available. - * @bug 8058354 + * @bug 8058354 8079208 * @key gc * @library /testlibrary /../../test/lib * @requires (vm.gc=="G1" | vm.gc=="null") * @build jdk.test.lib.* sun.hotspot.WhiteBox * @build TestLargePageUseForAuxMemory - * @ignore 8079208 * @run main ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission * @run main/othervm -Xbootclasspath/a:. -XX:+UseG1GC -XX:+WhiteBoxAPI -XX:+IgnoreUnrecognizedVMOptions -XX:+UseLargePages TestLargePageUseForAuxMemory */ +import java.lang.Math; + import jdk.test.lib.*; +import jdk.test.lib.Asserts; import sun.hotspot.WhiteBox; public class TestLargePageUseForAuxMemory { - static final int HEAP_REGION_SIZE = 4 * 1024 * 1024; + static final long HEAP_REGION_SIZE = 1 * 1024 * 1024; static long largePageSize; static long smallPageSize; + static long allocGranularity; static void checkSmallTables(OutputAnalyzer output, long expectedPageSize) throws Exception { output.shouldContain("G1 'Block offset table': pg_sz=" + expectedPageSize); @@ -54,16 +57,17 @@ output.shouldContain("G1 'Next Bitmap': pg_sz=" + expectedPageSize); } - static void testVM(long heapsize, boolean cardsShouldUseLargePages, boolean bitmapShouldUseLargePages) throws Exception { + static void testVM(String what, long heapsize, boolean cardsShouldUseLargePages, boolean bitmapShouldUseLargePages) throws Exception { + System.out.println(what); ProcessBuilder pb; // Test with large page enabled. pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", "-XX:G1HeapRegionSize=" + HEAP_REGION_SIZE, - "-Xms" + 10 * HEAP_REGION_SIZE, + "-Xms" + heapsize, "-Xmx" + heapsize, "-XX:+TracePageSizes", "-XX:+UseLargePages", - "-XX:+IgnoreUnrecognizedVMOptions", // there is on ObjectAlignmentInBytes in 32 bit builds + "-XX:+IgnoreUnrecognizedVMOptions", // there is no ObjectAlignmentInBytes in 32 bit builds "-XX:ObjectAlignmentInBytes=8", "-version"); @@ -75,11 +79,11 @@ // Test with large page disabled. pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", "-XX:G1HeapRegionSize=" + HEAP_REGION_SIZE, - "-Xms" + 10 * HEAP_REGION_SIZE, + "-Xms" + heapsize, "-Xmx" + heapsize, "-XX:+TracePageSizes", "-XX:-UseLargePages", - "-XX:+IgnoreUnrecognizedVMOptions", // there is on ObjectAlignmentInBytes in 32 bit builds + "-XX:+IgnoreUnrecognizedVMOptions", // there is no ObjectAlignmentInBytes in 32 bit builds "-XX:ObjectAlignmentInBytes=8", "-version"); @@ -98,6 +102,7 @@ WhiteBox wb = WhiteBox.getWhiteBox(); smallPageSize = wb.getVMPageSize(); largePageSize = wb.getVMLargePageSize(); + allocGranularity = wb.getVMAllocationGranularity(); if (largePageSize == 0) { System.out.println("Skip tests because large page support does not seem to be available on this platform."); @@ -112,20 +117,26 @@ final int cardSize = 512; final long heapSizeForCardTableUsingLargePages = largePageSize * cardSize; + final long heapSizeDiffForCardTable = Math.max(Math.max(allocGranularity * cardSize, HEAP_REGION_SIZE), largePageSize); - testVM(heapSizeForCardTableUsingLargePages, true, true); - testVM(heapSizeForCardTableUsingLargePages + HEAP_REGION_SIZE, true, true); - testVM(heapSizeForCardTableUsingLargePages - HEAP_REGION_SIZE, false, true); + Asserts.assertGT(heapSizeForCardTableUsingLargePages, heapSizeDiffForCardTable, + "To test we would require to use an invalid heap size"); + testVM("case1: card table and bitmap use large pages (barely)", heapSizeForCardTableUsingLargePages, true, true); + testVM("case2: card table and bitmap use large pages (extra slack)", heapSizeForCardTableUsingLargePages + heapSizeDiffForCardTable, true, true); + testVM("case3: only bitmap uses large pages (barely not)", heapSizeForCardTableUsingLargePages - heapSizeDiffForCardTable, false, true); } // Minimum heap requirement to get large pages for bitmaps is 128M heap. This seems okay to test // everywhere. final int bitmapTranslationFactor = 8 * 8; // ObjectAlignmentInBytes * BitsPerByte final long heapSizeForBitmapUsingLargePages = largePageSize * bitmapTranslationFactor; + final long heapSizeDiffForBitmap = Math.max(Math.max(allocGranularity * bitmapTranslationFactor, HEAP_REGION_SIZE), largePageSize); + + Asserts.assertGT(heapSizeForBitmapUsingLargePages, heapSizeDiffForBitmap, + "To test we would require to use an invalid heap size"); - testVM(heapSizeForBitmapUsingLargePages, false, true); - testVM(heapSizeForBitmapUsingLargePages + HEAP_REGION_SIZE, false, true); - testVM(heapSizeForBitmapUsingLargePages - HEAP_REGION_SIZE, false, false); + testVM("case4: only bitmap uses large pages (barely)", heapSizeForBitmapUsingLargePages, false, true); + testVM("case5: only bitmap uses large pages (extra slack)", heapSizeForBitmapUsingLargePages + heapSizeDiffForBitmap, false, true); + testVM("case6: nothing uses large pages (barely not)", heapSizeForBitmapUsingLargePages - heapSizeDiffForBitmap, false, false); } } -