Commit ca110694 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

Documentation/locking/atomic: Finish the document...

Julia reported that the document looked unfinished, and it is. I
forgot to include the example cooked up by Paul here:

and I added an explicit example showing how, while it is an ACQUIRE
pattern, it really does provide an MB.
Reported-by: default avatarJulia Cartwright <>
Signed-off-by: default avatarPeter Zijlstra (Intel) <>
Cc: Boqun Feng <>
Cc: Linus Torvalds <>
Cc: Paul E. McKenney <>
Cc: Peter Zijlstra <>
Cc: Thomas Gleixner <>
Cc: Will Deacon <>
Signed-off-by: default avatarIngo Molnar <>
parent e6f3faa7
......@@ -197,4 +197,46 @@ Further, while something like:
is a 'typical' RELEASE pattern, the barrier is strictly stronger than
a RELEASE. Similarly for something like:
is an ACQUIRE pattern (though very much not typical), but again the barrier is
strictly stronger than ACQUIRE. As illustrated:
C strong-acquire
P1(int *x, atomic_t *y)
r0 = READ_ONCE(*x);
r1 = atomic_read(y);
P2(int *x, atomic_t *y)
WRITE_ONCE(*x, 1);
(r0=1 /\ r1=0)
This should not happen; but a hypothetical atomic_inc_acquire() --
(void)atomic_fetch_inc_acquire() for instance -- would allow the outcome,
since then:
P1 P2
t = LL.acq *y (0)
*x = 1;
r0 = *x (1)
r1 = *y (0)
SC *y, t;
is allowed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment