RFR: 8376126: G1: Convert remaining volatiles in G1ConcurrentMark to Atomic<T>

Kim Barrett kbarrett at openjdk.org
Fri Jan 23 19:26:37 UTC 2026


On Thu, 22 Jan 2026 16:36:08 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:

> Hi all,
> 
>   please convert remaining volatile declarations in `G1ConcurrentMark` to use `Atomic<T>`. These volatiles are used to indicate concurrent phased access (like changing the variable in thread A, then reading the variable in thread B while A is dormant, or only ever updating it in one direction) where concurrency safety is provided by barriers between these phases. But there are also other cases)
> 
> The exception is `G1ConcurrentMark::_finger` that has apparently been overlooked in an earlier changes.
> 
> Testing: gha
> 
> Thanks,
>   Thomas

One minor nit.  Otherwise looks good.

src/hotspot/share/gc/g1/g1ConcurrentMark.cpp line 580:

> 578:   uint max_num_regions = _g1h->max_num_regions();
> 579:   for (uint i = 0; i < max_num_regions; i++) {
> 580:     ::new (&_top_at_rebuild_starts[i]) Atomic<HeapWord*>{};

Should add include of "cppstdlib/new.hpp".

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

Marked as reviewed by kbarrett (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/29368#pullrequestreview-3699196035
PR Review Comment: https://git.openjdk.org/jdk/pull/29368#discussion_r2722517093


More information about the hotspot-gc-dev mailing list