RFR: 8372738: ZGC: C2 allocation reloc promotion deopt race
Axel Boldt-Christmas
aboldtch at openjdk.org
Fri Nov 28 15:30:07 UTC 2025
On Fri, 28 Nov 2025 15:11:07 GMT, Erik Österlund <eosterlund at openjdk.org> wrote:
> In https://bugs.openjdk.org/browse/JDK-8371200 a race was handled between flip promoting objects, their promotion barriers, tenuring threshold selection and signalling to the JIT slow path allocation code to deoptimize. It made sure that flip promoted objects are made old before a handshake with the Java threads, and ran promotion barriers to erase any raw nulls after the handshake. This order was crucial to the fix.
>
> Now unfortunately, there is a related problem for relocate promoting objects. Such objects run the promotion barriers before the object becomes old, which is the signal for the JIT allocation slow path code to deopt. Unfortunately, the order should be the opposite, similar to flip promoted objects. I propose signalling that relocate promoting pages are marked as relocate promoted during relocation set selection, and include that as a condition for deopt in the allocation slow path. The relocation set selection runs before the handshake, hence ensuring that promotion barriers won't race with JIT compiled code that has elided barriers.
>
> T1-5 tests look good. The test that failed before reproduces an observable issue without the fix and not after the fix.
Looks good. A lot nice to have all the promotion barriers in one place.
src/hotspot/share/gc/z/zPage.hpp line 55:
> 53: ZRememberedSet _remembered_set;
> 54: ZMultiPartitionTracker* const _multi_partition_tracker;
> 55: volatile bool _relocate_promoted;
Could use the fancy new `Atomic<bool>`. But I am currently working on a patch to migrate all our `volatile` + `AtomicAccess` to `Atomic`, so I think we can leave it using the old style for now.
-------------
Marked as reviewed by aboldtch (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/28558#pullrequestreview-3519336671
PR Review Comment: https://git.openjdk.org/jdk/pull/28558#discussion_r2571966339
More information about the hotspot-gc-dev
mailing list