-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Potential to weaken ordering for success case of compare_exhange
s in race
module
#220
Comments
This does look reasonable to me, yeah! Although, as usual, I am unnerved by the fact that we don't have any tools to check this (or maybe I am missing them?). Could you send a PR? You can also adjust the Changelog and bump the patch version in Cargo.toml, so that we release this together with #219 |
Since the load during success for compare exchange is `0`/`null` and no `Release` store of this value exists, using an `Aquire` load for this case adds no additional synchronization. Fixes matklad#220
Note that CAS failure ordering that is stronger than success ordering requires Rust 1.64+: rust-lang/rust#98383 |
Gah! 🙁
The only thing that comes to my mind is testing with loom. I don't know if it is exactly what you are looking for though. |
For example, the compare exchange for
OnceNonZeroUsize
usesAcqRel
for the success case:once_cell/src/race.rs
Line 100 in d706539
The
Acquire
portion of theAcqRel
here is for the load of0
, however there is noRelease
store of0
so this will not synchronize with anything. Note that the construction ofOnceNonZeroUsize
still has a happens-before relationship to this since we have an&self
reference. Thus, I think aRelease
ordering is sufficient here for the desired synchronization to be achieved (including taking this documentation into account):I believe this applies to all uses of
compare_exchange
in this module.(happy to make a PR if this looks reasonable)
The text was updated successfully, but these errors were encountered: