This commit is contained in:
Jon Masamitsu 2016-06-11 00:12:28 +00:00
commit 2899284bf6
3 changed files with 78 additions and 0 deletions

View File

@ -1605,6 +1605,9 @@ void CMSCollector::do_compaction_work(bool clear_all_soft_refs) {
_inter_sweep_timer.reset(); _inter_sweep_timer.reset();
_inter_sweep_timer.start(); _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); gch->post_full_gc_dump(gc_timer);
gc_timer->register_gc_end(); gc_timer->register_gc_end();

View File

@ -1433,6 +1433,10 @@ WB_ENTRY(jlong, WB_MetaspaceCapacityUntilGC(JNIEnv* env, jobject wb))
return (jlong) MetaspaceGC::capacity_until_GC(); return (jlong) MetaspaceGC::capacity_until_GC();
WB_END 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)) WB_ENTRY(void, WB_AssertMatchingSafepointCalls(JNIEnv* env, jobject o, jboolean mutexSafepointValue, jboolean attemptedNoSafepointValue))
Monitor::SafepointCheckRequired sfpt_check_required = mutexSafepointValue ? Monitor::SafepointCheckRequired sfpt_check_required = mutexSafepointValue ?
@ -1813,6 +1817,7 @@ static JNINativeMethod methods[] = {
CC"(Ljava/lang/ClassLoader;JJ)V", (void*)&WB_FreeMetaspace }, CC"(Ljava/lang/ClassLoader;JJ)V", (void*)&WB_FreeMetaspace },
{CC"incMetaspaceCapacityUntilGC", CC"(J)J", (void*)&WB_IncMetaspaceCapacityUntilGC }, {CC"incMetaspaceCapacityUntilGC", CC"(J)J", (void*)&WB_IncMetaspaceCapacityUntilGC },
{CC"metaspaceCapacityUntilGC", CC"()J", (void*)&WB_MetaspaceCapacityUntilGC }, {CC"metaspaceCapacityUntilGC", CC"()J", (void*)&WB_MetaspaceCapacityUntilGC },
{CC"metaspaceShouldConcurrentCollect", CC"()Z", (void*)&WB_MetaspaceShouldConcurrentCollect },
{CC"getCPUFeatures", CC"()Ljava/lang/String;", (void*)&WB_GetCPUFeatures }, {CC"getCPUFeatures", CC"()Ljava/lang/String;", (void*)&WB_GetCPUFeatures },
{CC"getNMethod0", CC"(Ljava/lang/reflect/Executable;Z)[Ljava/lang/Object;", {CC"getNMethod0", CC"(Ljava/lang/reflect/Executable;Z)[Ljava/lang/Object;",
(void*)&WB_GetNMethod }, (void*)&WB_GetNMethod },

View File

@ -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());
}
}
}