6919638: CMS: ExplicitGCInvokesConcurrent misinteracts with gc locker
Summary: GC-locker induced concurrent full gc should be asynchronous; policy now controlled by a separate flag, which defaults to false.
Reviewed-by: jmasa
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Mon May 03 17:23:58 2010 -0400
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Mon May 03 20:19:05 2010 -0700
@@ -1424,10 +1424,9 @@
bool CMSCollector::shouldConcurrentCollect() {
if (_full_gc_requested) {
- assert(ExplicitGCInvokesConcurrent, "Unexpected state");
if (Verbose && PrintGCDetails) {
gclog_or_tty->print_cr("CMSCollector: collect because of explicit "
- " gc request");
+ " gc request (or gc_locker)");
}
return true;
}
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp Mon May 03 17:23:58 2010 -0400
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp Mon May 03 20:19:05 2010 -0700
@@ -163,6 +163,7 @@
// GenCollectedHeap heap.
void VM_GenCollectFullConcurrent::doit() {
assert(Thread::current()->is_VM_thread(), "Should be VM thread");
+ assert(GCLockerInvokesConcurrent || ExplicitGCInvokesConcurrent, "Unexpected");
GenCollectedHeap* gch = GenCollectedHeap::heap();
if (_gc_count_before == gch->total_collections()) {
@@ -190,7 +191,7 @@
CMSCollector::disable_icms();
// In case CMS thread was in icms_wait(), wake it up.
CMSCollector::start_icms();
- // Nudge the CMS thread to start a concurrent collection
+ // Nudge the CMS thread to start a concurrent collection.
CMSCollector::request_full_gc(_full_gc_count_before);
} else {
FullGCCount_lock->notify_all(); // Inform the Java thread its work is done
@@ -231,7 +232,9 @@
// e.g. at the rate of 1 full gc per ms, this could
// overflow in about 1000 years.
GenCollectedHeap* gch = GenCollectedHeap::heap();
- if (gch->total_full_collections_completed() <= _full_gc_count_before) {
+ if (_gc_cause != GCCause::_gc_locker &&
+ gch->total_full_collections_completed() <= _full_gc_count_before) {
+ assert(ExplicitGCInvokesConcurrent, "Error");
// Now, wait for witnessing concurrent gc cycle to complete,
// but do so in native mode, because we want to lock the
// FullGCEvent_lock, which may be needed by the VM thread
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.hpp Mon May 03 17:23:58 2010 -0400
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.hpp Mon May 03 20:19:05 2010 -0700
@@ -126,8 +126,7 @@
GCCause::Cause gc_cause)
: VM_GC_Operation(gc_count_before, full_gc_count_before, true /* full */) {
_gc_cause = gc_cause;
- assert(FullGCCount_lock != NULL && UseConcMarkSweepGC &&
- ExplicitGCInvokesConcurrent, "Otherwise shouldn't be here");
+ assert(FullGCCount_lock != NULL, "Error");
assert(UseAsyncConcMarkSweepGC, "Else will hang caller");
}
~VM_GenCollectFullConcurrent() {}
--- a/hotspot/src/share/vm/memory/genCollectedHeap.cpp Mon May 03 17:23:58 2010 -0400
+++ b/hotspot/src/share/vm/memory/genCollectedHeap.cpp Mon May 03 20:19:05 2010 -0700
@@ -410,9 +410,9 @@
}
bool GenCollectedHeap::should_do_concurrent_full_gc(GCCause::Cause cause) {
- return (cause == GCCause::_java_lang_system_gc ||
- cause == GCCause::_gc_locker) &&
- UseConcMarkSweepGC && ExplicitGCInvokesConcurrent;
+ return UseConcMarkSweepGC &&
+ ((cause == GCCause::_gc_locker && GCLockerInvokesConcurrent) ||
+ (cause == GCCause::_java_lang_system_gc && ExplicitGCInvokesConcurrent));
}
void GenCollectedHeap::do_collection(bool full,
--- a/hotspot/src/share/vm/runtime/globals.hpp Mon May 03 17:23:58 2010 -0400
+++ b/hotspot/src/share/vm/runtime/globals.hpp Mon May 03 20:19:05 2010 -0700
@@ -1303,6 +1303,10 @@
"also unloads classes during such a concurrent gc cycle " \
"(effective only when UseConcMarkSweepGC)") \
\
+ product(bool, GCLockerInvokesConcurrent, false, \
+ "The exit of a JNI CS necessitating a scavenge also" \
+ " kicks off a bkgrd concurrent collection") \
+ \
develop(bool, UseCMSAdaptiveFreeLists, true, \
"Use Adaptive Free Lists in the CMS generation") \
\