RFR: 8323807: Async UL: Add a stalling mode to async UL [v2]
David Holmes
dholmes at openjdk.org
Tue Apr 2 12:05:13 UTC 2024
On Tue, 2 Apr 2024 11:41:03 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:
>> I'll change them to use `Atomic::store`, but shouldn't releasing the lock cause a full memory fence and therefore prevent the store from being delayed? Or is there something else that I'm missing?
>
> To answer your question: Yes, this can be called without either lock being held. The goal is to have a cheaper variant of `await_message`. I renamed this to `maybe_has_message` to indicate that you must check whether a message exists when you take the consumer lock.
If read without any lock then the reads could happen around the same time as a store and so before the lock is released and has any memory affects. And technically the release of a lock only synchronizes with the acquire of the same lock by another thread - any memory affects broader than that are just implementation artifacts. So if you want to be strictly correct you need `Atomic::store` to pair with the lock-free `Atomic::load`. (And on most platforms these will just turn into regular loads and stores anyway.)
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17757#discussion_r1547734936
More information about the hotspot-runtime-dev
mailing list