8151670: Unexpected concurrent refinement deactivation and reactivation

Refinement threads now use SuspendibleThreadSet::yield.

Reviewed-by: jmasa, mgerdin
This commit is contained in:
Kim Barrett 2016-03-25 15:50:31 -04:00
parent 6bf9194f41
commit cb72aacabb
3 changed files with 66 additions and 40 deletions

View file

@ -76,7 +76,6 @@ void ConcurrentG1RefineThread::initialize() {
}
void ConcurrentG1RefineThread::wait_for_completed_buffers() {
DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
MutexLockerEx x(_monitor, Mutex::_no_safepoint_check_flag);
while (!should_terminate() && !is_active()) {
_monitor->wait(Mutex::_no_safepoint_check_flag);
@ -126,7 +125,12 @@ void ConcurrentG1RefineThread::run_service() {
{
SuspendibleThreadSetJoiner sts_join;
do {
while (!should_terminate()) {
if (sts_join.should_yield()) {
sts_join.yield();
continue; // Re-check for termination after yield delay.
}
size_t curr_buffer_num = dcqs.completed_buffers_num();
// If the number of the buffers falls down into the yellow zone,
// that means that the transition period after the evacuation pause has ended.
@ -138,17 +142,23 @@ void ConcurrentG1RefineThread::run_service() {
if (_next != NULL && !_next->is_active() && curr_buffer_num > _next->_threshold) {
_next->activate();
}
} while (dcqs.apply_closure_to_completed_buffer(_refine_closure,
_worker_id + _worker_id_offset,
_deactivation_threshold,
false /* during_pause */));
deactivate();
log_debug(gc, refine)("Deactivated %d, off threshold: " SIZE_FORMAT ", current: " SIZE_FORMAT,
_worker_id, _deactivation_threshold,
dcqs.completed_buffers_num());
// Process the next buffer, if there are enough left.
if (!dcqs.apply_closure_to_completed_buffer(_refine_closure,
_worker_id + _worker_id_offset,
_deactivation_threshold,
false /* during_pause */)) {
break; // Deactivate, number of buffers fell below threshold.
}
}
}
deactivate();
log_debug(gc, refine)("Deactivated %d, off threshold: " SIZE_FORMAT
", current: " SIZE_FORMAT,
_worker_id, _deactivation_threshold,
dcqs.completed_buffers_num());
if (os::supports_vtime()) {
_vtime_accum = (os::elapsedVTime() - _vtime_start);
} else {