Skip to content

RFC: Interfacing LLVM's "atomic volatile" in Rust #212

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

Closed
wants to merge 42 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
43c10b0
First RFC draft for atomic volatile
HadrienG2 Oct 15, 2019
e84c586
Some cross-checking
HadrienG2 Oct 15, 2019
3638bf9
More cross-checking
HadrienG2 Oct 15, 2019
c46335e
One more argument against volatile ops on atomic
HadrienG2 Oct 15, 2019
9cfd45e
Fine-tuning
HadrienG2 Oct 15, 2019
3b2984f
Update rfcs/0000-atomic-volatile.md
HadrienG2 Oct 17, 2019
e920abd
Update rfcs/0000-atomic-volatile.md
HadrienG2 Oct 17, 2019
c423313
Follow suggestions from the PR
HadrienG2 Oct 17, 2019
f0c2381
Rewording
HadrienG2 Oct 17, 2019
ca0c36a
Typo fix
HadrienG2 Oct 17, 2019
e6bee95
Typo
HadrienG2 Oct 17, 2019
dc55924
Clarify the exotic hardware situation
HadrienG2 Oct 17, 2019
9b9783e
Typo fix
HadrienG2 Oct 17, 2019
effdd4b
Propose using a different feature gate for not_atomic stuffé
HadrienG2 Oct 17, 2019
a195f48
Clarification
HadrienG2 Oct 17, 2019
da02234
Avoid first person
HadrienG2 Oct 17, 2019
d32a410
Clarify the assumption of isolated memory
HadrienG2 Oct 17, 2019
10fe05e
Correct inaccurate section about atomic volatile being an LLVM thing
HadrienG2 Oct 17, 2019
24b77e0
Kill another incorrect "atomic volatile is LLVM-specific" + typo-hunting
HadrienG2 Oct 18, 2019
636f5f7
Typo nazi
HadrienG2 Nov 8, 2019
375f279
Remove empty sentence
HadrienG2 Nov 8, 2019
b272333
Add unresolved discussion on shared memory, expand on untrusted share…
HadrienG2 Nov 8, 2019
cf87a64
Review discussion of the IPC use case
HadrienG2 Nov 8, 2019
1c83d8a
Forgotten detail
HadrienG2 Nov 8, 2019
8f6b20b
Update rfcs/0000-atomic-volatile.md
HadrienG2 Nov 21, 2019
e258347
Update rfcs/0000-atomic-volatile.md
HadrienG2 Nov 21, 2019
7b5af33
Update rfcs/0000-atomic-volatile.md
HadrienG2 Nov 21, 2019
ff9d1f1
Disambiguate shared-memory IPC from shared-memory concurrency
HadrienG2 Nov 23, 2019
693d6c1
Talk about spills
HadrienG2 Nov 23, 2019
9cb9328
Talk about barrier issues
HadrienG2 Nov 23, 2019
bfcb98b
Talk about limitations of volatile for virtual memory
HadrienG2 Nov 23, 2019
b573dd4
Weaken wording of how optimizations interact with volatile
HadrienG2 Nov 23, 2019
b81738e
Shorten sentence
HadrienG2 Nov 23, 2019
bab4645
Do not deprecate old read/write_volatile methods
HadrienG2 Nov 25, 2019
10de5da
Reorganize unresolved questions & future possibilities
HadrienG2 Dec 8, 2019
e57bcf8
Remove ordering, rmw, make unordered, and restructure
HadrienG2 Dec 8, 2019
17ab617
More atomics codegen horror stories
HadrienG2 Dec 8, 2019
8aa979f
Air + wording cleanup
HadrienG2 Dec 8, 2019
9114251
Link to P0062R1
HadrienG2 Dec 8, 2019
79f9545
Last read before pinging
HadrienG2 Dec 8, 2019
71ebfcd
Also link to Box issue
HadrienG2 Dec 8, 2019
bb9cefa
Turn VolatileBool into a future extension
HadrienG2 Jan 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More atomics codegen horror stories
  • Loading branch information
HadrienG2 committed Dec 8, 2019
commit 17ab617dd51cb7e8ce399a2a194b13ef6b5d763c
16 changes: 10 additions & 6 deletions rfcs/0000-atomic-volatile.md
Original file line number Diff line number Diff line change
Expand Up @@ -684,13 +684,17 @@ to exert tight control on the stream of hardware instructions that is emitted:

- `Relaxed` and stronger ordering may lead to the emission of different hardware
load and store instructions, or to the emission of hardware memory barriers,
in a target- and ABI-dependent fashion.
in a target- and ABI-dependent fashion. As memory barriers can be coalesced,
the details of which instructions will be used depend on surrounding code.
- `compare_and_swap` will lead to the generation a full loop (and thus break
wait-freedom progress guarantees, which may be unexpected) on hardware based
on the Load-Linked / Store-Conditional (LL/SC) synchronization formalism.
- Other atomic read-modify-write operations may or may not also compile into an
LL/SC loop, depending on whether they are natively supported by hardware, and
whether the compiler backend chose to use them if that is the case.
- Some atomic read-modify-write operations will lead to the generation a loop
(and thus break wait-freedom progress guarantees, which may be unexpected) on
hardware based on the Load-Linked / Store-Conditional (LL/SC) synchronization
formalism. Which instructions will be subjected to this treatment depends on
target CPU instruction set and whether the compiler backend will choose to use
dedicated wait-free instructions over an LL/SC loop.

Clearly, the mental model for the process through which these instructions are
translated into hardware semantics is much more difficult to reason about, and
Expand All @@ -699,8 +703,8 @@ may not be stable across compiler versions and architecture/ABI revisions.
So far, the only use case that was found for these operations was to exert
stronger control over atomic operation emission, on a hypothetical backend
which would optimize atomics aggressively. This use case does not seem like it
would require the full constraints of the `VolatileXyz`, and would probably be
better implemented as an extension of `std::sync::atomic::Ordering`.
would require the full constraints of the `VolatileXyz` API, and it could
therefore probably be turned into an extension of `std::sync::atomic::Ordering`.

One possibility would be to duplicate every ordering with a volatile variant
(e.g. `RelaxedVolatile`, `AcquireVolatile...`). Another possibility would be to
Expand Down