RFR: 8374686: ZGC: Convert zMarkTerminate to use Atomic<T>
Axel Boldt-Christmas
aboldtch at openjdk.org
Thu Jan 15 06:54:24 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
-------------
Commit messages:
- ZGC: Convert zMarkTerminate to use Atomic<T>
Changes: https://git.openjdk.org/jdk/pull/29246/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29246&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8374686
Stats: 29 lines in 2 files changed: 1 ins; 3 del; 25 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