< prev index next >

test/gc/arguments/TestSmallInitialHeapWithLargePageAndNUMA.java

Print this page
rev 11780 : [mq]: webrev.0
rev 11781 : [mq]: webrev.1


  24 /*
  25  * @test TestSmallInitialHeapWithLargePageAndNUMA
  26  * @bug 8023905
  27  * @requires os.family == "linux"
  28  * @requires vm.gc.Parallel
  29  * @summary Check large pages and NUMA are working together via the output message.
  30  * @library /testlibrary /test/lib /test/lib/share/classes
  31  * @modules java.base/jdk.internal.misc
  32  * @modules java.management/sun.management
  33  * @build TestSmallInitialHeapWithLargePageAndNUMA
  34  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  35  * @run main/othervm -Xbootclasspath/a:. -XX:+UseHugeTLBFS -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestSmallInitialHeapWithLargePageAndNUMA
  36 */
  37 
  38 import jdk.test.lib.ProcessTools;
  39 import jdk.test.lib.OutputAnalyzer;
  40 import sun.hotspot.WhiteBox;
  41 
  42 public class TestSmallInitialHeapWithLargePageAndNUMA {
  43 
  44   private static final String MSG_EXIT_TOO_SMALL_HEAP = "Failed initializing NUMA. Too small initial heap size";
  45   private static final String MSG_GC_TRIGGERED_BEFORE_INIT = "GC triggered before VM initialization completed.";
  46 
  47   public static void main(String[] args) throws Exception {
  48 
  49     WhiteBox wb = WhiteBox.getWhiteBox();
  50     long heapAlignment = wb.getHeapAlignment();
  51 
  52     // NUMA with large pages is not fully compatible in Linux, so we are using pin region.
  53     // And the pin region case, we will skip freeing memory if the page size is larger than the default page size.
  54     // If we allocate pages less than NUMA node, NUMA will try to use default page size.
  55     // And this will conflict for pin region.
  56     // Assume the minimum NUMA node as 2.
  57     long initHeap = heapAlignment;
  58     long maxHeap = heapAlignment * 2;
  59 
  60     String[] vmArgs = {"-XX:+UseParallelGC",
  61                        "-Xms" + String.valueOf(initHeap),
  62                        "-Xmx" + String.valueOf(maxHeap),
  63                        "-XX:+UseNUMA",
  64                        "-XX:+UseHugeTLBFS",
  65                        "-XX:+PrintFlagsFinal",
  66                        "-version"};
  67 
  68     ProcessBuilder pb_enabled = ProcessTools.createJavaProcessBuilder(vmArgs);
  69     OutputAnalyzer analyzer = new OutputAnalyzer(pb_enabled.start());
  70 
  71     if (largePageOrNumaEnabled(analyzer)) {
  72       // We reach here, if both NUMA and HugeTLB are supported.
  73       // However final flags will not be printed as NUMA initialization will be failed.
  74       checkAnalyzerValues(analyzer, 1, MSG_EXIT_TOO_SMALL_HEAP);
  75     }




  24 /*
  25  * @test TestSmallInitialHeapWithLargePageAndNUMA
  26  * @bug 8023905
  27  * @requires os.family == "linux"
  28  * @requires vm.gc.Parallel
  29  * @summary Check large pages and NUMA are working together via the output message.
  30  * @library /testlibrary /test/lib /test/lib/share/classes
  31  * @modules java.base/jdk.internal.misc
  32  * @modules java.management/sun.management
  33  * @build TestSmallInitialHeapWithLargePageAndNUMA
  34  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  35  * @run main/othervm -Xbootclasspath/a:. -XX:+UseHugeTLBFS -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestSmallInitialHeapWithLargePageAndNUMA
  36 */
  37 
  38 import jdk.test.lib.ProcessTools;
  39 import jdk.test.lib.OutputAnalyzer;
  40 import sun.hotspot.WhiteBox;
  41 
  42 public class TestSmallInitialHeapWithLargePageAndNUMA {
  43 
  44   private static final String MSG_EXIT_TOO_SMALL_HEAP = "Failed initializing NUMA with large pages. Too small heap size";
  45   private static final String MSG_GC_TRIGGERED_BEFORE_INIT = "GC triggered before VM initialization completed.";
  46 
  47   public static void main(String[] args) throws Exception {
  48 
  49     WhiteBox wb = WhiteBox.getWhiteBox();
  50     long heapAlignment = wb.getHeapAlignment();
  51 
  52     // When using large pages, Linux does not support freeing parts of reserved and committed memory.
  53     // And current Linux implementation uses page size as a condition to actually freeing memory.
  54     // If we allocate pages less than NUMA node, NUMA will try to use default page size and
  55     // this will free the memory which Linux does not support.
  56     // Assume the minimum NUMA node as 2.
  57     long initHeap = heapAlignment;
  58     long maxHeap = heapAlignment * 2;
  59 
  60     String[] vmArgs = {"-XX:+UseParallelGC",
  61                        "-Xms" + String.valueOf(initHeap),
  62                        "-Xmx" + String.valueOf(maxHeap),
  63                        "-XX:+UseNUMA",
  64                        "-XX:+UseHugeTLBFS",
  65                        "-XX:+PrintFlagsFinal",
  66                        "-version"};
  67 
  68     ProcessBuilder pb_enabled = ProcessTools.createJavaProcessBuilder(vmArgs);
  69     OutputAnalyzer analyzer = new OutputAnalyzer(pb_enabled.start());
  70 
  71     if (largePageOrNumaEnabled(analyzer)) {
  72       // We reach here, if both NUMA and HugeTLB are supported.
  73       // However final flags will not be printed as NUMA initialization will be failed.
  74       checkAnalyzerValues(analyzer, 1, MSG_EXIT_TOO_SMALL_HEAP);
  75     }


< prev index next >