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

Axel Boldt-Christmas aboldtch at openjdk.org
Tue Jan 27 08:26:21 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 for the reviews. Compiled locally with latest master merged.

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

PR Comment: https://git.openjdk.org/jdk/pull/29246#issuecomment-3803793390


More information about the hotspot-gc-dev mailing list