-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Tracking Issue for arithmetic and certain bitwise ops on AtomicPtr
#99108
Comments
fill new tracking issue for `feature(strict_provenance_atomic_ptr)` New tracking issue: rust-lang#99108. The generic strict provenance issue has a lot of discussions on its own, so I think it's meaningful to have a separate issue for atomic ptr methods.
In terms of implementation details, I think we should also improve the types at which we call the |
"The problem" with making rhs rust/library/core/src/intrinsics.rs Line 111 in 8a392a5
Making the second argument of a different type will probably require compiler changes. |
Indeed, and I think those compiler changes should be made. :) |
23: Provide stable equivalent of #![feature(strict_provenance_atomic_ptr)] r=taiki-e a=taiki-e This provides stable equivalent of [`#![feature(strict_provenance_atomic_ptr)]`](rust-lang/rust#99108). - `AtomicPtr::fetch_ptr_{add,sub}` - `AtomicPtr::fetch_byte_{add,sub}` - `AtomicPtr::fetch_{or,and,xor}` These APIs are compatible with strict-provenance on `cfg(miri)`. Otherwise, they are compatible with permissive-provenance. Once `#![feature(strict_provenance_atomic_ptr)]` is stabilized, these APIs will be strict-provenance compatible in all cases from the version in which it is stabilized. (This is also a generalization of what [I did in crossbeam-epoch](crossbeam-rs/crossbeam#796).) Co-authored-by: Taiki Endo <[email protected]>
I think |
I think the only open question about this API is whether there is a better name for |
Why not just |
@tgross35 note that all atomic operations are wrapping, so I don't really like |
@RalfJung are there any implementation blockers to stabilizing these API, now that It sounds like nobody is super thrilled with the |
I don't know how these are implemented, but from an opsem perspective this all seems fine.
Note that the wrapping ptr arithmetic operations are equivalent to |
The implementation is a bit odd, since it goes via Worse, for LLVM we are casting everything to integers and emit an atomic integer |
Why isn't it a correct implementation? Isn't going through a pointer to integer to pointer cast conservatively correct, just sub-optimal from an optimization perspective? We can add an atomicrmw ptradd flavor, but I don't think it would really make any difference in terms of LLVM behavior. Things like fetch_or would have to go via integers anyway. |
The problem is that in memory, there is a pointer (i.e. data with provenance). We then do an I don't know if LLVM ever replaces |
The But really, I just want this to be stabilized. I'd rather seethe writing those method names because the type is arguably unusable without these methods. |
Does anyone have a use case for Though I would prefer I also think |
Indeed the methods I'm really looking for personally are the bitwise ones. Arithmetic is useful to me for e.g. concurrent allocation but you need |
It does look like there are some uses of it floating around, probably using the version from It looks like
Agreed that this is probably the most useful bit of the API. I think it is still blocked on some resolution to the above LLVM behavior / provenance question though. |
Ah kernel-level usage makes sense. I would still disagree that this should be default behavior so the current API seems fine.
Is there discussion about that anywhere? Even if the current implementation is problematic, stabilizing would be useful for Miri compatibility. |
AIUI there isn't anything problematic with our API, just possibly some LLVM semantics that our intrinsics invoke. But I'll bring this up on In any case the docs should probably gain a note about provenance since this is indeed tricky. |
For naming, I can't come up with anything better than
That being said, |
There is no add_ptr, but yes sub_ptr is being renamed. |
Feature gate:
#![feature(strict_provenance_atomic_ptr)]
This is a tracking issue for arithmetic and certain bitwise operations on
AtomicPtr
.As part of the strict provenance experiment #95228.
This feature adds arithmetic (
add
,sub
) and bitwise (or
,end
,xor
) atomic operations forAtomicPtr
in order to replace uses ofAtomicUsize
-but-actually-a-pointer to preserve provenance information for the compiler and removeusize
->ptr
casts from existing code.Arithmetic ops behave as the their non-atomic wrapping versions. Bitwise ops behave as
.map_addr(|x| x op val)
.Public API
Steps / History
Unresolved Questions
AtomicPtr::fetch_ptr_{add,sub}
toAtomicPtr::fetch_{add,sub}
libs-team#126)Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩
The text was updated successfully, but these errors were encountered: