Blame SOURCES/8179084-pr3409-rh1455694.patch

545c29
# HG changeset patch
545c29
# User dholmes
545c29
# Date 1493428477 14400
545c29
#      Fri Apr 28 21:14:37 2017 -0400
545c29
# Node ID 2fee74c5547889d9698a2636e0a5170f9e66fb9c
545c29
# Parent  13a04e8df5a3af73794146b930b32556c7cbc5b0
545c29
8179084, PR3409, RH1455694: HotSpot VM fails to start when AggressiveHeap is set
545c29
Reviewed-by: kbarrett, stefank
545c29
545c29
diff --git a/src/share/vm/runtime/arguments.cpp b/src/share/vm/runtime/arguments.cpp
545c29
--- openjdk/hotspot/src/share/vm/runtime/arguments.cpp
545c29
+++ openjdk/hotspot/src/share/vm/runtime/arguments.cpp
545c29
@@ -3193,8 +3193,6 @@
545c29
 
545c29
       // Enable parallel GC and adaptive generation sizing
545c29
       FLAG_SET_CMDLINE(bool, UseParallelGC, true);
545c29
-      FLAG_SET_DEFAULT(ParallelGCThreads,
545c29
-                       Abstract_VM_Version::parallel_worker_threads());
545c29
 
545c29
       // Encourage steady state memory management
545c29
       FLAG_SET_CMDLINE(uintx, ThresholdTolerance, 100);
545c29
diff --git a/test/TEST.groups b/test/TEST.groups
545c29
--- openjdk/hotspot/test/TEST.groups
545c29
+++ openjdk/hotspot/test/TEST.groups
545c29
@@ -1,5 +1,5 @@
545c29
 #
545c29
-# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
545c29
+# Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
545c29
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
545c29
 #
545c29
 # This code is free software; you can redistribute it and/or modify it
545c29
@@ -164,6 +164,7 @@
545c29
   gc/TestGCLogRotationViaJcmd.java \
545c29
   gc/g1/TestHumongousAllocInitialMark.java \
545c29
   gc/g1/TestHumongousShrinkHeap.java \
545c29
+  gc/arguments/TestAggressiveHeap.java \
545c29
   gc/arguments/TestG1HeapRegionSize.java \
545c29
   gc/metaspace/TestMetaspaceMemoryPool.java \
545c29
   gc/arguments/TestDynMinHeapFreeRatio.java \
545c29
diff --git a/test/gc/arguments/TestAggressiveHeap.java b/test/gc/arguments/TestAggressiveHeap.java
545c29
new file mode 100644
545c29
--- /dev/null
545c29
+++ openjdk/hotspot/test/gc/arguments/TestAggressiveHeap.java
545c29
@@ -0,0 +1,91 @@
545c29
+/*
545c29
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
545c29
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
545c29
+ *
545c29
+ * This code is free software; you can redistribute it and/or modify it
545c29
+ * under the terms of the GNU General Public License version 2 only, as
545c29
+ * published by the Free Software Foundation.
545c29
+ *
545c29
+ * This code is distributed in the hope that it will be useful, but WITHOUT
545c29
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
545c29
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
545c29
+ * version 2 for more details (a copy is included in the LICENSE file that
545c29
+ * accompanied this code).
545c29
+ *
545c29
+ * You should have received a copy of the GNU General Public License version
545c29
+ * 2 along with this work; if not, write to the Free Software Foundation,
545c29
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
545c29
+ *
545c29
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
545c29
+ * or visit www.oracle.com if you need additional information or have any
545c29
+ * questions.
545c29
+ */
545c29
+
545c29
+/*
545c29
+ * @test TestAggressiveHeap
545c29
+ * @key gc
545c29
+ * @bug 8179084
545c29
+ * @summary Test argument processing for -XX:+AggressiveHeap.
545c29
+ * @library /testlibrary
545c29
+ * @run driver TestAggressiveHeap
545c29
+ */
545c29
+
545c29
+import java.lang.management.ManagementFactory;
545c29
+import javax.management.MBeanServer;
545c29
+import javax.management.ObjectName;
545c29
+
545c29
+import com.oracle.java.testlibrary.OutputAnalyzer;
545c29
+import com.oracle.java.testlibrary.ProcessTools;
545c29
+
545c29
+public class TestAggressiveHeap {
545c29
+
545c29
+    public static void main(String args[]) throws Exception {
545c29
+        if (canUseAggressiveHeapOption()) {
545c29
+            testFlag();
545c29
+        }
545c29
+    }
545c29
+
545c29
+    // Note: Not a normal boolean flag; -XX:-AggressiveHeap is invalid.
545c29
+    private static final String option = "-XX:+AggressiveHeap";
545c29
+
545c29
+    // Option requires at least 256M, else error during option processing.
545c29
+    private static final long minMemory = 256 * 1024 * 1024;
545c29
+
545c29
+    // bool UseParallelGC := true {product}
545c29
+    private static final String parallelGCPattern =
545c29
+        " *bool +UseParallelGC *:= *true +\\{product\\}";
545c29
+
545c29
+    private static void testFlag() throws Exception {
545c29
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
545c29
+            option, "-XX:+PrintFlagsFinal", "-version");
545c29
+
545c29
+        OutputAnalyzer output = new OutputAnalyzer(pb.start());
545c29
+
545c29
+        output.shouldHaveExitValue(0);
545c29
+
545c29
+        String value = output.firstMatch(parallelGCPattern);
545c29
+        if (value == null) {
545c29
+            throw new RuntimeException(
545c29
+                option + " didn't set UseParallelGC");
545c29
+        }
545c29
+    }
545c29
+
545c29
+    private static boolean haveRequiredMemory() throws Exception {
545c29
+        MBeanServer server = ManagementFactory.getPlatformMBeanServer();
545c29
+        ObjectName os = new ObjectName("java.lang", "type", "OperatingSystem");
545c29
+        Object attr = server.getAttribute(os, "TotalPhysicalMemorySize");
545c29
+        String value = attr.toString();
545c29
+        long memory = Long.parseLong(value);
545c29
+        return memory >= minMemory;
545c29
+    }
545c29
+
545c29
+    private static boolean canUseAggressiveHeapOption() throws Exception {
545c29
+        if (!haveRequiredMemory()) {
545c29
+            System.out.println(
545c29
+                "Skipping test of " + option + " : insufficient memory");
545c29
+            return false;
545c29
+        }
545c29
+        return true;
545c29
+    }
545c29
+}
545c29
+