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

Bengt Rutisson bengt.rutisson at oracle.com
Mon Mar 14 11:23:03 UTC 2016

Hi all,

Could I have a couple of reviews for this change?


The run_service() loop in ConcurrentMarkThread looks like this:

   while (!_should_terminate) {
     // wait until started is set.
     if (_should_terminate) {
     // 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 

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 


More information about the hotspot-gc-dev mailing list