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

Axel Boldt-Christmas aboldtch at openjdk.org
Thu Jan 15 12:35:13 UTC 2026


> 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

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/29246/files
  - new: https://git.openjdk.org/jdk/pull/29246/files/2a87be98..9030cdd7

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=29246&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=29246&range=01-02

  Stats: 5 lines in 1 file changed: 0 ins; 0 del; 5 mod
  Patch: https://git.openjdk.org/jdk/pull/29246.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/29246/head:pull/29246

PR: https://git.openjdk.org/jdk/pull/29246


More information about the hotspot-gc-dev mailing list