提交 a0bf5551 编写于 作者: I iveresov

6841831: G1: assert(contains_reference(from),"We just added it!") fires

Summary: During parallel rset updating we have to make sure that the worker ids of the refinement threads do not intersect with the worker ids that can be claimed by the mutator threads.
Reviewed-by: tonyp
上级 2c49aee0
......@@ -33,12 +33,13 @@ ConcurrentG1Refine::ConcurrentG1Refine() :
_threads(NULL), _n_threads(0)
{
if (G1ConcRefine) {
_n_threads = (G1ParallelRSetThreads > 0) ? G1ParallelRSetThreads : ParallelGCThreads;
_n_threads = (int)thread_num();
if (_n_threads > 0) {
_threads = NEW_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _n_threads);
int worker_id_offset = (int)DirtyCardQueueSet::num_par_ids();
ConcurrentG1RefineThread *next = NULL;
for (int i = _n_threads - 1; i >= 0; i--) {
ConcurrentG1RefineThread* t = new ConcurrentG1RefineThread(this, next, i);
ConcurrentG1RefineThread* t = new ConcurrentG1RefineThread(this, next, worker_id_offset, i);
assert(t != NULL, "Conc refine should have been created");
assert(t->cg1r() == this, "Conc refine thread should refer to this");
_threads[i] = t;
......@@ -48,6 +49,13 @@ ConcurrentG1Refine::ConcurrentG1Refine() :
}
}
size_t ConcurrentG1Refine::thread_num() {
if (G1ConcRefine) {
return (G1ParallelRSetThreads > 0) ? G1ParallelRSetThreads : ParallelGCThreads;
}
return 0;
}
void ConcurrentG1Refine::init() {
if (G1ConcRSLogCacheSize > 0 || G1ConcRSCountTraversals) {
G1CollectedHeap* g1h = G1CollectedHeap::heap();
......
......@@ -29,7 +29,6 @@ class G1RemSet;
class ConcurrentG1Refine: public CHeapObj {
ConcurrentG1RefineThread** _threads;
int _n_threads;
// The cache for card refinement.
bool _use_cache;
bool _def_use_cache;
......@@ -86,4 +85,6 @@ class ConcurrentG1Refine: public CHeapObj {
void clear_and_record_card_counts();
void print_final_card_counts();
static size_t thread_num();
};
......@@ -30,8 +30,10 @@
// The CM thread is created when the G1 garbage collector is used
ConcurrentG1RefineThread::
ConcurrentG1RefineThread(ConcurrentG1Refine* cg1r, ConcurrentG1RefineThread *next, int worker_id) :
ConcurrentG1RefineThread(ConcurrentG1Refine* cg1r, ConcurrentG1RefineThread *next,
int worker_id_offset, int worker_id) :
ConcurrentGCThread(),
_worker_id_offset(worker_id_offset),
_worker_id(worker_id),
_active(false),
_next(next),
......@@ -114,7 +116,7 @@ void ConcurrentG1RefineThread::run() {
} else {
lower_limit = DCQBarrierProcessCompletedThreshold / 4; // For now.
}
while (dcqs.apply_closure_to_completed_buffer(_worker_id, lower_limit)) {
while (dcqs.apply_closure_to_completed_buffer(_worker_id + _worker_id_offset, lower_limit)) {
double end_vtime_sec;
double elapsed_vtime_sec;
int elapsed_vtime_ms;
......
......@@ -34,6 +34,7 @@ class ConcurrentG1RefineThread: public ConcurrentGCThread {
double _vtime_start; // Initial virtual time.
double _vtime_accum; // Initial virtual time.
int _worker_id;
int _worker_id_offset;
// The refinement threads collection is linked list. A predecessor can activate a successor
// when the number of the rset update buffer crosses a certain threshold. A successor
......@@ -73,7 +74,8 @@ class ConcurrentG1RefineThread: public ConcurrentGCThread {
public:
// Constructor
ConcurrentG1RefineThread(ConcurrentG1Refine* cg1r, ConcurrentG1RefineThread* next, int worker_id);
ConcurrentG1RefineThread(ConcurrentG1Refine* cg1r, ConcurrentG1RefineThread* next,
int worker_id_offset, int worker_id);
// Printing
void print();
......
......@@ -71,11 +71,11 @@ DirtyCardQueueSet::DirtyCardQueueSet() :
_all_active = true;
}
// Determines how many mutator threads can process the buffers in parallel.
size_t DirtyCardQueueSet::num_par_ids() {
return MAX2(ParallelGCThreads, (size_t)2);
return os::processor_count();
}
void DirtyCardQueueSet::initialize(Monitor* cbl_mon, Mutex* fl_lock,
int max_completed_queue,
Mutex* lock, PtrQueueSet* fl_owner) {
......@@ -85,8 +85,6 @@ void DirtyCardQueueSet::initialize(Monitor* cbl_mon, Mutex* fl_lock,
_shared_dirty_card_queue.set_lock(lock);
_free_ids = new FreeIdSet((int) num_par_ids(), _cbl_mon);
bool b = _free_ids->claim_perm_id(0);
guarantee(b, "Must reserve id zero for concurrent refinement thread.");
}
void DirtyCardQueueSet::handle_zero_index_for_thread(JavaThread* t) {
......
......@@ -1052,10 +1052,11 @@ bool OtherRegionsTable::contains_reference_locked(oop* from) const {
}
// Determines how many threads can add records to an rset in parallel.
// This can be done by either mutator threads together with the
// concurrent refinement threads or GC threads.
int HeapRegionRemSet::num_par_rem_sets() {
// We always have at least two, so that a mutator thread can claim an
// id and add to a rem set.
return (int) MAX2(ParallelGCThreads, (size_t)2);
return (int)MAX2(DirtyCardQueueSet::num_par_ids() + ConcurrentG1Refine::thread_num(), ParallelGCThreads);
}
HeapRegionRemSet::HeapRegionRemSet(G1BlockOffsetSharedArray* bosa,
......
......@@ -282,6 +282,7 @@ heapRegionRemSet.hpp sparsePRT.hpp
heapRegionRemSet.cpp allocation.hpp
heapRegionRemSet.cpp bitMap.inline.hpp
heapRegionRemSet.cpp concurrentG1Refine.hpp
heapRegionRemSet.cpp g1BlockOffsetTable.inline.hpp
heapRegionRemSet.cpp g1CollectedHeap.inline.hpp
heapRegionRemSet.cpp heapRegionRemSet.hpp
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册