提交 893ceddc 编写于 作者: J johnc

7143858: G1: Back to back young GCs with the second GC having a minimally sized eden

Summary: Before the last thread to leave a JNI critical region was able to schedule a GCLocker Initiated GC, another thread was attempting an allocation and saw that the GCLocker region was no longer active and successfully scheduled a GC. Stall allocating threads until the GCLocker Initiated GC is performed and then retry the allocation.
Reviewed-by: brutisso, huntch
上级 93e4073b
...@@ -952,9 +952,18 @@ HeapWord* G1CollectedHeap::attempt_allocation_slow(size_t word_size, ...@@ -952,9 +952,18 @@ HeapWord* G1CollectedHeap::attempt_allocation_slow(size_t word_size,
} }
should_try_gc = false; should_try_gc = false;
} else { } else {
// Read the GC count while still holding the Heap_lock. // The GCLocker may not be active but the GCLocker initiated
gc_count_before = total_collections(); // GC may not yet have been performed (GCLocker::needs_gc()
should_try_gc = true; // returns true). In this case we do not try this GC and
// wait until the GCLocker initiated GC is performed, and
// then retry the allocation.
if (GC_locker::needs_gc()) {
should_try_gc = false;
} else {
// Read the GC count while still holding the Heap_lock.
gc_count_before = total_collections();
should_try_gc = true;
}
} }
} }
...@@ -975,6 +984,9 @@ HeapWord* G1CollectedHeap::attempt_allocation_slow(size_t word_size, ...@@ -975,6 +984,9 @@ HeapWord* G1CollectedHeap::attempt_allocation_slow(size_t word_size,
return NULL; return NULL;
} }
} else { } else {
// The GCLocker is either active or the GCLocker initiated
// GC has not yet been performed. Stall until it is and
// then retry the allocation.
GC_locker::stall_until_clear(); GC_locker::stall_until_clear();
} }
...@@ -1054,9 +1066,18 @@ HeapWord* G1CollectedHeap::attempt_allocation_humongous(size_t word_size, ...@@ -1054,9 +1066,18 @@ HeapWord* G1CollectedHeap::attempt_allocation_humongous(size_t word_size,
if (GC_locker::is_active_and_needs_gc()) { if (GC_locker::is_active_and_needs_gc()) {
should_try_gc = false; should_try_gc = false;
} else { } else {
// Read the GC count while still holding the Heap_lock. // The GCLocker may not be active but the GCLocker initiated
gc_count_before = total_collections(); // GC may not yet have been performed (GCLocker::needs_gc()
should_try_gc = true; // returns true). In this case we do not try this GC and
// wait until the GCLocker initiated GC is performed, and
// then retry the allocation.
if (GC_locker::needs_gc()) {
should_try_gc = false;
} else {
// Read the GC count while still holding the Heap_lock.
gc_count_before = total_collections();
should_try_gc = true;
}
} }
} }
...@@ -1081,6 +1102,9 @@ HeapWord* G1CollectedHeap::attempt_allocation_humongous(size_t word_size, ...@@ -1081,6 +1102,9 @@ HeapWord* G1CollectedHeap::attempt_allocation_humongous(size_t word_size,
return NULL; return NULL;
} }
} else { } else {
// The GCLocker is either active or the GCLocker initiated
// GC has not yet been performed. Stall until it is and
// then retry the allocation.
GC_locker::stall_until_clear(); GC_locker::stall_until_clear();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册