提交 91df12bb 编写于 作者: Y ysr

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
上级 1ddd8d21
......@@ -1424,10 +1424,9 @@ bool ConcurrentMarkSweepGeneration::should_collect(bool full,
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;
}
......
......@@ -163,6 +163,7 @@ void VM_CMS_Final_Remark::doit() {
// 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 @@ void VM_GenCollectFullConcurrent::doit() {
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 @@ void VM_GenCollectFullConcurrent::doit_epilogue() {
// 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
......
......@@ -126,8 +126,7 @@ class VM_GenCollectFullConcurrent: public VM_GC_Operation {
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() {}
......
......@@ -410,9 +410,9 @@ bool GenCollectedHeap::must_clear_all_soft_refs() {
}
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,
......
......@@ -1303,6 +1303,10 @@ class CommandLineFlags {
"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") \
\
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册