Merge
authorjmasa
Sat, 11 Jun 2016 00:12:28 +0000
changeset 39271 e73eb62f991d
parent 39269 fbef515ea566 (current diff)
parent 39270 9b12d5739295 (diff)
child 39272 65c0727c04db
Merge
--- a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp	Fri Jun 10 15:19:32 2016 -0700
+++ b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp	Sat Jun 11 00:12:28 2016 +0000
@@ -1605,6 +1605,9 @@
   _inter_sweep_timer.reset();
   _inter_sweep_timer.start();
 
+  // No longer a need to do a concurrent collection for Metaspace.
+  MetaspaceGC::set_should_concurrent_collect(false);
+
   gch->post_full_gc_dump(gc_timer);
 
   gc_timer->register_gc_end();
--- a/hotspot/src/share/vm/prims/whitebox.cpp	Fri Jun 10 15:19:32 2016 -0700
+++ b/hotspot/src/share/vm/prims/whitebox.cpp	Sat Jun 11 00:12:28 2016 +0000
@@ -1433,6 +1433,10 @@
   return (jlong) MetaspaceGC::capacity_until_GC();
 WB_END
 
+WB_ENTRY(jboolean, WB_MetaspaceShouldConcurrentCollect(JNIEnv* env, jobject wb))
+  return MetaspaceGC::should_concurrent_collect();
+WB_END
+
 
 WB_ENTRY(void, WB_AssertMatchingSafepointCalls(JNIEnv* env, jobject o, jboolean mutexSafepointValue, jboolean attemptedNoSafepointValue))
   Monitor::SafepointCheckRequired sfpt_check_required = mutexSafepointValue ?
@@ -1813,6 +1817,7 @@
      CC"(Ljava/lang/ClassLoader;JJ)V",                (void*)&WB_FreeMetaspace },
   {CC"incMetaspaceCapacityUntilGC", CC"(J)J",         (void*)&WB_IncMetaspaceCapacityUntilGC },
   {CC"metaspaceCapacityUntilGC", CC"()J",             (void*)&WB_MetaspaceCapacityUntilGC },
+  {CC"metaspaceShouldConcurrentCollect", CC"()Z",     (void*)&WB_MetaspaceShouldConcurrentCollect },
   {CC"getCPUFeatures",     CC"()Ljava/lang/String;",  (void*)&WB_GetCPUFeatures     },
   {CC"getNMethod0",         CC"(Ljava/lang/reflect/Executable;Z)[Ljava/lang/Object;",
                                                       (void*)&WB_GetNMethod         },
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/gc/metaspace/TestMetaspaceCMSCancel.java	Sat Jun 11 00:12:28 2016 +0000
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.Asserts;
+import sun.hotspot.WhiteBox;
+
+/* @test TestMetaspaceCMSCancel
+ * @bug 8026752
+ * @summary Tests cancel of CMS concurrent cycle for Metaspace after a full GC
+ * @library /testlibrary /test/lib /test/lib/share/classes
+ * @modules java.base/jdk.internal.misc
+ * @build TestMetaspaceCMSCancel
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm TestMetaspaceCMSCancel
+ */
+
+
+public class TestMetaspaceCMSCancel {
+
+    public static void main(String[] args) throws Exception {
+        // Set a small MetaspaceSize so that a CMS concurrent collection will be
+        // scheduled.  Set CMSWaitDuration to 5s so that the concurrent collection
+        // start may be delayed.  It does not guarantee 5s before the start of the
+        // concurrent collection but does increase the probability that it will
+        // be started later.  System.gc() is used to invoke a full collection.  Set
+        // ExplicitGCInvokesConcurrent to off so it is a STW collection.
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xbootclasspath/a:.",
+                                                                  "-XX:+UnlockDiagnosticVMOptions",
+                                                                  "-XX:+WhiteBoxAPI",
+                                                                  "-XX:+UseConcMarkSweepGC",
+                                                                  "-XX:MetaspaceSize=2m",
+                                                                  "-XX:CMSWaitDuration=5000",
+                                                                  "-XX:-ExplicitGCInvokesConcurrent",
+                                                                  "-Xlog:gc*=debug",
+                                                                  MetaspaceGCTest.class.getName());
+
+        OutputAnalyzer output = new OutputAnalyzer(pb.start());
+        output.shouldNotContain("Concurrent Reset");
+        output.shouldHaveExitValue(0);
+    }
+
+    static class MetaspaceGCTest {
+        public static void main(String [] args) {
+            WhiteBox wb = WhiteBox.getWhiteBox();
+            System.gc();
+            Asserts.assertFalse(wb.metaspaceShouldConcurrentCollect());
+        }
+    }
+}