Merge
authortschatzl
Wed, 24 Jun 2015 11:55:18 +0200
changeset 31393 3c910fd51238
parent 31391 dbef845a80ba (current diff)
parent 31392 863f78743771 (diff)
child 31396 c8e4926f1d2c
child 31399 167037a29ab4
Merge
--- a/hotspot/src/share/vm/prims/whitebox.cpp	Wed Jun 24 10:28:00 2015 +0200
+++ b/hotspot/src/share/vm/prims/whitebox.cpp	Wed Jun 24 11:55:18 2015 +0200
@@ -90,6 +90,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
@@ -1301,13 +1305,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
--- a/hotspot/test/gc/g1/TestLargePageUseForAuxMemory.java	Wed Jun 24 10:28:00 2015 +0200
+++ b/hotspot/test/gc/g1/TestLargePageUseForAuxMemory.java	Wed Jun 24 11:55:18 2015 +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,18 @@
         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 + " heapsize " + heapsize + " card table should use large pages " + cardsShouldUseLargePages + " " +
+                           "bitmaps should use large pages " + bitmapShouldUseLargePages);
         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 +80,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 +103,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 +118,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);
 
-        testVM(heapSizeForBitmapUsingLargePages, false, true);
-        testVM(heapSizeForBitmapUsingLargePages + HEAP_REGION_SIZE, false, true);
-        testVM(heapSizeForBitmapUsingLargePages - HEAP_REGION_SIZE, false, false);
+        Asserts.assertGT(heapSizeForBitmapUsingLargePages, heapSizeDiffForBitmap,
+                         "To test we would require to use an invalid heap size");
+
+        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);
     }
 }
-