提交 d0aa394b 编写于 作者: J johnc

6930581: G1: assert(ParallelGCThreads > 1 || n_yielded() ==...

6930581: G1: assert(ParallelGCThreads > 1 || n_yielded() == _hrrs->occupied(),"Should have yielded all the ..
Summary: During RSet updating, when ParallelGCThreads is zero, references that point into the collection set are added directly the referenced region's RSet. This can cause the sparse table in the RSet to expand. RSet scanning and the "occupied" routine will then operate on different instances of the sparse table causing the assert to trip. This may also cause some cards added post expansion to be missed during RSet scanning. When ParallelGCThreads is non-zero such references are recorded on the "references to be scanned" queue and the card containing the reference is recorded in a dirty card queue for use in the event of an evacuation failure. Employ the parallel code in the serial case to avoid expanding the RSets of regions in the collection set.
Reviewed-by: iveresov, ysr, tonyp
上级 e49283a2
...@@ -122,7 +122,7 @@ public: ...@@ -122,7 +122,7 @@ public:
HRInto_G1RemSet::HRInto_G1RemSet(G1CollectedHeap* g1, CardTableModRefBS* ct_bs) HRInto_G1RemSet::HRInto_G1RemSet(G1CollectedHeap* g1, CardTableModRefBS* ct_bs)
: G1RemSet(g1), _ct_bs(ct_bs), _g1p(_g1->g1_policy()), : G1RemSet(g1), _ct_bs(ct_bs), _g1p(_g1->g1_policy()),
_cg1r(g1->concurrent_g1_refine()), _cg1r(g1->concurrent_g1_refine()),
_par_traversal_in_progress(false), _traversal_in_progress(false),
_cset_rs_update_cl(NULL), _cset_rs_update_cl(NULL),
_cards_scanned(NULL), _total_cards_scanned(0) _cards_scanned(NULL), _total_cards_scanned(0)
{ {
...@@ -484,28 +484,24 @@ HRInto_G1RemSet::oops_into_collection_set_do(OopsInHeapRegionClosure* oc, ...@@ -484,28 +484,24 @@ HRInto_G1RemSet::oops_into_collection_set_do(OopsInHeapRegionClosure* oc,
// is updated immediately. // is updated immediately.
DirtyCardQueue into_cset_dcq(&_g1->into_cset_dirty_card_queue_set()); DirtyCardQueue into_cset_dcq(&_g1->into_cset_dirty_card_queue_set());
if (ParallelGCThreads > 0) { assert((ParallelGCThreads > 0) || worker_i == 0, "invariant");
// The two flags below were introduced temporarily to serialize
// the updating and scanning of remembered sets. There are some // The two flags below were introduced temporarily to serialize
// race conditions when these two operations are done in parallel // the updating and scanning of remembered sets. There are some
// and they are causing failures. When we resolve said race // race conditions when these two operations are done in parallel
// conditions, we'll revert back to parallel remembered set // and they are causing failures. When we resolve said race
// updating and scanning. See CRs 6677707 and 6677708. // conditions, we'll revert back to parallel remembered set
if (G1UseParallelRSetUpdating || (worker_i == 0)) { // updating and scanning. See CRs 6677707 and 6677708.
updateRS(&into_cset_dcq, worker_i); if (G1UseParallelRSetUpdating || (worker_i == 0)) {
} else { updateRS(&into_cset_dcq, worker_i);
_g1p->record_update_rs_processed_buffers(worker_i, 0.0);
_g1p->record_update_rs_time(worker_i, 0.0);
}
if (G1UseParallelRSetScanning || (worker_i == 0)) {
scanRS(oc, worker_i);
} else {
_g1p->record_scan_rs_time(worker_i, 0.0);
}
} else { } else {
assert(worker_i == 0, "invariant"); _g1p->record_update_rs_processed_buffers(worker_i, 0.0);
updateRS(&into_cset_dcq, 0); _g1p->record_update_rs_time(worker_i, 0.0);
scanRS(oc, 0); }
if (G1UseParallelRSetScanning || (worker_i == 0)) {
scanRS(oc, worker_i);
} else {
_g1p->record_scan_rs_time(worker_i, 0.0);
} }
// We now clear the cached values of _cset_rs_update_cl for this worker // We now clear the cached values of _cset_rs_update_cl for this worker
...@@ -524,9 +520,9 @@ prepare_for_oops_into_collection_set_do() { ...@@ -524,9 +520,9 @@ prepare_for_oops_into_collection_set_do() {
DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
dcqs.concatenate_logs(); dcqs.concatenate_logs();
assert(!_par_traversal_in_progress, "Invariant between iterations."); assert(!_traversal_in_progress, "Invariant between iterations.");
set_traversal(true);
if (ParallelGCThreads > 0) { if (ParallelGCThreads > 0) {
set_par_traversal(true);
_seq_task->set_par_threads((int)n_workers()); _seq_task->set_par_threads((int)n_workers());
} }
guarantee( _cards_scanned == NULL, "invariant" ); guarantee( _cards_scanned == NULL, "invariant" );
...@@ -623,9 +619,7 @@ void HRInto_G1RemSet::cleanup_after_oops_into_collection_set_do() { ...@@ -623,9 +619,7 @@ void HRInto_G1RemSet::cleanup_after_oops_into_collection_set_do() {
// Set all cards back to clean. // Set all cards back to clean.
_g1->cleanUpCardTable(); _g1->cleanUpCardTable();
if (ParallelGCThreads > 0) { set_traversal(false);
set_par_traversal(false);
}
DirtyCardQueueSet& into_cset_dcqs = _g1->into_cset_dirty_card_queue_set(); DirtyCardQueueSet& into_cset_dcqs = _g1->into_cset_dirty_card_queue_set();
int into_cset_n_buffers = into_cset_dcqs.completed_buffers_num(); int into_cset_n_buffers = into_cset_dcqs.completed_buffers_num();
...@@ -660,7 +654,7 @@ void HRInto_G1RemSet::cleanup_after_oops_into_collection_set_do() { ...@@ -660,7 +654,7 @@ void HRInto_G1RemSet::cleanup_after_oops_into_collection_set_do() {
"all buffers should be freed"); "all buffers should be freed");
_g1->into_cset_dirty_card_queue_set().clear_n_completed_buffers(); _g1->into_cset_dirty_card_queue_set().clear_n_completed_buffers();
assert(!_par_traversal_in_progress, "Invariant between iterations."); assert(!_traversal_in_progress, "Invariant between iterations.");
} }
class UpdateRSObjectClosure: public ObjectClosure { class UpdateRSObjectClosure: public ObjectClosure {
......
...@@ -148,10 +148,10 @@ protected: ...@@ -148,10 +148,10 @@ protected:
size_t* _cards_scanned; size_t* _cards_scanned;
size_t _total_cards_scanned; size_t _total_cards_scanned;
// _par_traversal_in_progress is "true" iff a parallel traversal is in // _traversal_in_progress is "true" iff a traversal is in progress.
// progress.
bool _par_traversal_in_progress; bool _traversal_in_progress;
void set_par_traversal(bool b) { _par_traversal_in_progress = b; } void set_traversal(bool b) { _traversal_in_progress = b; }
// Used for caching the closure that is responsible for scanning // Used for caching the closure that is responsible for scanning
// references into the collection set. // references into the collection set.
......
...@@ -62,13 +62,13 @@ template <class T> inline void HRInto_G1RemSet::par_write_ref_nv(HeapRegion* fro ...@@ -62,13 +62,13 @@ template <class T> inline void HRInto_G1RemSet::par_write_ref_nv(HeapRegion* fro
HeapRegion* to = _g1->heap_region_containing(obj); HeapRegion* to = _g1->heap_region_containing(obj);
// The test below could be optimized by applying a bit op to to and from. // The test below could be optimized by applying a bit op to to and from.
if (to != NULL && from != NULL && from != to) { if (to != NULL && from != NULL && from != to) {
// The _par_traversal_in_progress flag is true during the collection pause, // The _traversal_in_progress flag is true during the collection pause,
// false during the evacuation failure handing. This should avoid a // false during the evacuation failure handling. This should avoid a
// potential loop if we were to add the card containing 'p' to the DCQS // potential loop if we were to add the card containing 'p' to the DCQS
// that's used to regenerate the remembered sets for the collection set, // that's used to regenerate the remembered sets for the collection set,
// in the event of an evacuation failure, here. The UpdateRSImmediate // in the event of an evacuation failure, here. The UpdateRSImmediate
// closure will eventally call this routine. // closure will eventally call this routine.
if (_par_traversal_in_progress && if (_traversal_in_progress &&
to->in_collection_set() && !self_forwarded(obj)) { to->in_collection_set() && !self_forwarded(obj)) {
assert(_cset_rs_update_cl[tid] != NULL, "should have been set already"); assert(_cset_rs_update_cl[tid] != NULL, "should have been set already");
......
...@@ -424,7 +424,7 @@ void SparsePRT::cleanup_all() { ...@@ -424,7 +424,7 @@ void SparsePRT::cleanup_all() {
SparsePRT::SparsePRT(HeapRegion* hr) : SparsePRT::SparsePRT(HeapRegion* hr) :
_expanded(false), _next_expanded(NULL) _hr(hr), _expanded(false), _next_expanded(NULL)
{ {
_cur = new RSHashTable(InitialCapacity); _cur = new RSHashTable(InitialCapacity);
_next = _cur; _next = _cur;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册