RFR: JDK-8151336: Root region scanning should be cancelled and disabled when the ConcurrentMarkThread::run_service() exits

Bengt Rutisson bengt.rutisson at oracle.com
Tue Mar 15 15:11:43 UTC 2016


Hi again everyone,

Here's an updated webrev:
http://cr.openjdk.java.net/~brutisso/8151336/webrev.01

I removed the extra _has_terminated state and am instead using the 
ConcurrentMarkThread::should_terminate() state to make sure we don't 
start a new initial mark if the concurrent mark thread is about to 
terminate or has already terminated.

The _should_terminate state is set in ConcurrentGCThread::stop() where 
we first take the Terminator_lock with a safepoint check. So, we should 
be able to rely on this value inside of do_collection_pause_at_safepoint().

Thanks,
Bengt

On 2016-03-15 12:55, Bengt Rutisson wrote:
>
> Hi again,
>
> I am working on an update to this webrev. So, please hold off with 
> reviews of the patch below.
>
> Thanks,
> Bengt
>
> On 2016-03-14 12:23, Bengt Rutisson wrote:
>>
>> Hi all,
>>
>> Could I have a couple of reviews for this change?
>>
>> http://cr.openjdk.java.net/~brutisso/8151336/webrev.00/
>> https://bugs.openjdk.java.net/browse/JDK-8151336
>>
>> The run_service() loop in ConcurrentMarkThread looks like this:
>>
>>   while (!_should_terminate) {
>>     // wait until started is set.
>>     sleepBeforeNextCycle();
>>     if (_should_terminate) {
>>       _cm->root_regions()->cancel_scan();
>>       break;
>>     }
>>     // do all the work
>>  }
>>
>> If a full GC is triggered while the ConcurrentMarkThread is in "do 
>> all the work" the full GC will wait for the root region scan. But if 
>> we at the same time decide to exit the VM we will set 
>> _should_terminate to true, which will cause the while() loop to not 
>> continue and we won't get to the cancel_scan call.
>>
>> The proposed fix moves the call to cancel_scan() until after the 
>> while loop has exited. That way we will always cancel any pending 
>> root region scanning.
>>
>> I also introduce a _has_terminated state for G1CMRootRegions to makes 
>> sure that another root region scanning can't be initialized once the 
>> CM thread has exited. This also called for a rename of cancel_scan() 
>> to terminate().
>>
>> Thanks,
>> Bengt
>



More information about the hotspot-gc-dev mailing list