-
Notifications
You must be signed in to change notification settings - Fork 473
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
AtomicCell: Why do you use SeqCst? #317
Comments
I agree with @RalfJung that:
|
@RalfJung Thank you so much for digging into Crossbeam, I really appreciate it! <3 Memory orderings of I've been pushing hard for guaranteeing In crossbeam-rs/crossbeam-utils#39, my belief was that simply adding a I wonder if we can just put that All that said, I could be wrong and overlooking something important here. Am I? Another point against And, to reiterate: Finally, it's worth pointing out that Go developers had a similar, long discussion about Apologies for feeling so anxious about |
One more thing: I haven't really decided whether the right mental model for |
I think there is no simple code that is correct with
I have no idea how to verify if that is the case for your seqlock construction. Unfortunately |
Maybe we could ask the libs team what they think in Berlin next week? But first it would be good to hear from @jeehoonkang if putting a |
This recent great blogpost said that
AtomicCell
doesn't let the user choose the memory ordering, which is fair, but of course I had to immediately check which one it uses ;) . I was very surprised to see it useSeqCst
. I would have expectedAcq
/Rel
/AcqRel
. This allows reasoning by ownership transfer, which is strong enough for almost everything.I wouldn't usually care enough to actually submit an issue about this, but now I found this comment:
This is not in the documentation as far as I can see, but I agree it makes sense as a principle. The thing is, from all I know it is perfectly legal to implement locks with release-acquire spinlocks, so by this argument, the accesses in
AtomicCell
should definitely be release-acquire!The post claims that
will pass when using
Mutex<Cell>
, but (assuming this was tested) I think that is just an accident of the current implementation. Nothing in the C11 memory model requires this to pass when using locks, and you absolutely shouldn't rely on it.Cc @jeehoonkang @stjepang
The text was updated successfully, but these errors were encountered: