RFR: Put regulator thread stop after gc thread iteration is prevented
William Kemper
wkemper at openjdk.org
Wed Mar 22 22:29:30 UTC 2023
On Wed, 22 Mar 2023 08:11:56 GMT, Y. Srinivas Ramakrishna <ysr at openjdk.org> wrote:
>> Record that shutdown sequence has begun before we request the regulator thread to stop.
>
> src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp line 2365:
>
>> 2363: // Step 0a. Stop requesting collections.
>> 2364: regulator_thread()->stop();
>> 2365:
>
> May be rename them Steps 0.a and 0.b in the order in which they are executed?
>
> Could you state the advantage of doing steps in this rather than the old order? (I confess I looked at the code but couldn't find an immediate reason why this may be preferable to the previous order, e.g. does it accelerate the shutdown if the actions are in this new order, or something else such as prevention of a potential deadlock or a crash?)
The previous code would have allowed these events:
1. shutdown thread stops regulator thread
2. control thread begins iteration of gc threads (shutdown not 'recorded' yet)
3. shutdown thread records shutdown (meant to prevent iteration of stopped threads)
4. control thread visits stopped regulator thread (which could be unsafe)
This change reduces the chances of the control thread iterating the gc threads after the regulator thread is stopped. Of course, without a robust locking sequence it may _still_ happen, but this code is closer to the intended sequence.
-------------
PR Review Comment: https://git.openjdk.org/shenandoah/pull/231#discussion_r1145470359
More information about the shenandoah-dev
mailing list