RFR: 8308881: Strong CLD oop handle roots are demoted to non-roots concurrently [v2]
Erik Österlund
eosterlund at openjdk.org
Fri May 26 14:00:56 UTC 2023
On Fri, 26 May 2023 13:19:38 GMT, Axel Boldt-Christmas <aboldtch at openjdk.org> wrote:
> Is there any issue with memory order access here?
> From my understanding this works because a GC which starts before `demote_strong_roots` has the property if it observers `_keep_alive == 0` then in must have observed `demote_strong_roots` (either root throughout or it observed the transition through barriers). And if a GC starts after `demote_strong_roots` it must never observe `_keep_alive != 0`.
If the GC races with these accesses, it doesn't matter if the race hits before or after the accesses. The accesses themselves will sync with the GC. To be precise:
1. If the object relocated, the load barrier will detect that and the new value stored will pointed to the to-space object.
2. The store barrier will load the previous value and enqueue for marking, so that we don't miss there was an oop in there that needed to be marked.
3. After the last store, the colors will be right with both ZGC collectors. GC will never perform non-monotonic transitions away from the best color, which the store ensures we will get.
If the GC processes the location before these accesses, it will ensure the above properties. Whoever gets there first doesn't matter as long as one of them will.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/14154#issuecomment-1564433544
More information about the hotspot-gc-dev
mailing list