RFR: 8323807: Async UL: Add a stalling mode to async UL [v2]
David Holmes
dholmes at openjdk.org
Wed Apr 3 01:20:04 UTC 2024
On Tue, 2 Apr 2024 12:01:27 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> 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.)
Actually for a lock-free traversal you need `load_acquire` and `release_store` so that other writes to the buffer, and the data therein, are visible. Sorry I should have recalled that sooner.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17757#discussion_r1548799333
More information about the hotspot-runtime-dev
mailing list