RFR: Refix ShenandoahPurgeSATBTask

Zhengyu Gu zgu at openjdk.java.net
Mon Apr 12 15:52:58 UTC 2021


On Mon, 12 Apr 2021 15:33:10 GMT, Roman Kennke <rkennke at openjdk.org> wrote:

>> My early fix was incomplete and incorrect.
>> 
>> 1) ShenandoahPurgeSATBTask needs to change thread claim token for iterating threads in parallel, this was missing in early change.
>> 2) Threads::threads_do() -> Threads::possibly_parallel_threads_do() was incorrect, the later version only iterates Java and VM threads. This part of changes are reverted.
>> 3) A minor change: declaring _trashed_oops as volatile as it is a shared variable.
>
> src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.cpp line 99:
> 
>> 97: 
>> 98: public:
>> 99:   volatile size_t _trashed_oops;
> 
> If it the intention is to make shared access to the field safe, then C++ volatile does not (fully) achieve this. You also need to use Atomic::inc() and similar to change/read it.

Adding volatile keyword, mainly just for coding convention on shared variable. It uses Atomic::add() to update variable, so it is correct.

-------------

PR: https://git.openjdk.java.net/shenandoah/pull/25


More information about the shenandoah-dev mailing list