RFR: 8374686: ZGC: Convert zMarkTerminate to use Atomic<T> [v3]

Stefan Karlsson stefank at openjdk.org
Thu Jan 15 15:39:55 UTC 2026


On Thu, 15 Jan 2026 12:35:13 GMT, Axel Boldt-Christmas <aboldtch at openjdk.org> wrote:

>> Convert usages of AtomicAccess to Atomic<T> in zMarkTerminate.
>> 
>> There are a few things that potentially should be changed here. 
>> 
>> First the `_nworkers` variable was accessed through the AtomicAccess API in a handful of places. In this patch I changed it to always be an Atomic. However, this variable is only ever read concurrently. It only gets modified before we schedule a task on the workers (either for a new task, or after all workers have stopped working because we are resizing the work gang size).  So potentially this could just be changed to a uint with plain loads and stores.
>> 
>> The other variables have mutual exclusion when updated, but are read concurrently without synchronisation. In this patch I changed the volatile load + sub/add + atomic relaxed store [+ volatile load] into a simple atomic relaxed add/sub [and fetch]. The main reason being that I thought the code became less verbose, easier to read and understand. 
>> 
>> Testing:
>>  * GHA
>>  * HotSpot GC tests with ZGC linux x64 and linux aarch64
>
> Axel Boldt-Christmas has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Const the locals

Thanks!

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

Marked as reviewed by stefank (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/29246#pullrequestreview-3666237029


More information about the hotspot-gc-dev mailing list