documentation: memory-barriers: fix smp_mb__before_spinlock() semantics
PATCH RESEND 1/1 documentation: memory-barriers: fix smp_mb__before_spinlock() semantics
Our current documentation claims that, when followed by an ACQUIRE, smp_mb__before_spinlock() orders prior loads against subsequent loads and stores, which isn't actually true.
Fix the documentation to state that this sequence orders only prior stores against subsequent loads and stores.
---
Could somebody pick this up please? I guess I could route it via the arm64 tree with an Ack, but I'd rather it went through Paul or -tip.
Documentation/memory-barriers.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
Documentation/memory-barriers.txt +3 -4
@@ -1768,10 +1768,9 @@ for each construct. These operations all imply certain barriers: Memory operations issued before the ACQUIRE may be completed after the ACQUIRE operation has completed. An smp_mb__before_spinlock(), - combined with a following ACQUIRE, orders prior loads against - subsequent loads and stores and also orders prior stores against - subsequent stores. Note that this is weaker than smp_mb()! The - smp_mb__before_spinlock() primitive is free on many architectures. + combined with a following ACQUIRE, orders prior stores against + subsequent loads and stores. Note that this is weaker than smp_mb()! + The smp_mb__before_spinlock() primitive is free on many architectures. (2) RELEASE operation implication:
Signature · 1 line
2.1.4
Quoted 3 lines · Will Deacon
Could somebody pick this up please? I guess I could route it via the arm64 tree with an Ack, but I'd rather it went through Paul or -tip.
I think this would be the best route ;)
Documentation/memory-barriers.txt for each construct. These operations all imply certain barriers: · line 1773
Quoted 13 lines
Documentation/memory-barriers.txt +3
-4@@ -1768,10 +1768,9 @@ for each construct. These operations all imply certain barriers: Memory operations issued before the ACQUIRE may be completed after the ACQUIRE operation has completed. An smp_mb__before_spinlock(), - combined with a following ACQUIRE, orders prior loads against - subsequent loads and stores and also orders prior stores against - subsequent stores. Note that this is weaker than smp_mb()! The - smp_mb__before_spinlock() primitive is free on many architectures. + combined with a following ACQUIRE, orders prior stores against + subsequent loads and stores. Note that this is weaker than smp_mb()! + The smp_mb__before_spinlock() primitive is free on many architectures.
I agree, this description was always wrong.
But perhaps you can also update the comment above smp_mb__before_spinlock? It only documents the STORE - LOAD serialization, and this was on purpose.
But people started to use this helper assuming that it can also serialize the STOREs. Perhaps the changelog could also mention this fact, this is why we need to update this comment and fix memory-barriers.txt.
Oleg.
Quoted 7 lines · Will Deacon
Our current documentation claims that, when followed by an ACQUIRE,
smp_mb__before_spinlock()orders prior loads against subsequent loads and stores, which isn't actually true.Fix the documentation to state that this sequence orders only prior stores against subsequent loads and stores.
Quoted 8 lines
Cc Oleg Nesterov <[email protected]>Cc "Paul E. McKenney" <[email protected]>Cc Peter Zijlstra <[email protected]>Signed-off-by Will Deacon <[email protected]>---
Could somebody pick this up please? I guess I could route it via the arm64 tree with an Ack, but I'd rather it went through Paul or -tip.
Queued for 4.2, along with a separate patch for PowerPC that make it so that PowerPC actually behaves as described below. ;-)
Thanx, Paul
Quoted 10 lines
Documentation/memory-barriers.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)Documentation/memory-barriers.txt +0
-0@@ -1768,10 +1768,9 @@ for each construct. These operations all imply certain barriers: Memory operations issued before the ACQUIRE may be completed after
Documentation/memory-barriers.txt for each construct. These operations all imply certain barriers: · line 1775
Quoted 10 lines
Documentation/memory-barriers.txt +3
-4the ACQUIRE operation has completed. An smp_mb__before_spinlock(), - combined with a following ACQUIRE, orders prior loads against - subsequent loads and stores and also orders prior stores against - subsequent stores. Note that this is weaker than smp_mb()! The - smp_mb__before_spinlock() primitive is free on many architectures. + combined with a following ACQUIRE, orders prior stores against + subsequent loads and stores. Note that this is weaker than smp_mb()! + The smp_mb__before_spinlock() primitive is free on many architectures. (2) RELEASE operation implication:
------------------------------------------------------------------------
powerpc: Fix smp_mb__before_spinlock()
Currently, smp_mb__before_spinlock() is defined to be smp_wmb() in core code, but this is not sufficient on PowerPC. This patch therefore supplies an override for the generic definition to strengthen smp_mb__before_spinlock() to smp_mb(), as is needed on PowerPC.
arch/powerpc/include/asm/barrier.h +1 -0
@@ -89,5 +89,6 @@ do { \#define smp_mb__before_atomic () smp_mb()#define smp_mb__after_atomic () smp_mb() +#define smp_mb__before_spinlock () smp_mb()#endif /* _ASM_POWERPC_BARRIER_H */
Quoted 23 lines · Oleg Nesterov
Quoted 3 lines · Will Deacon
Could somebody pick this up please? I guess I could route it via the arm64 tree with an Ack, but I'd rather it went through Paul or -tip.
I think this would be the best route ;)
Documentation/memory-barriers.txt for each construct. These operations all imply certain barriers: · line 1773
Quoted 13 lines
Documentation/memory-barriers.txt +3
-4@@ -1768,10 +1768,9 @@ for each construct. These operations all imply certain barriers: Memory operations issued before the ACQUIRE may be completed after the ACQUIRE operation has completed. An smp_mb__before_spinlock(), - combined with a following ACQUIRE, orders prior loads against - subsequent loads and stores and also orders prior stores against - subsequent stores. Note that this is weaker than smp_mb()! The - smp_mb__before_spinlock() primitive is free on many architectures. + combined with a following ACQUIRE, orders prior stores against + subsequent loads and stores. Note that this is weaker than smp_mb()! + The smp_mb__before_spinlock() primitive is free on many architectures.I agree, this description was always wrong.
Quoted 6 lines
But perhaps you can also update the comment above
smp_mb__before_spinlock? It only documents the STORE - LOAD serialization, and this was on purpose.But people started to use this helper assuming that it can also serialize the STOREs. Perhaps the changelog could also mention this fact, this is why we need to update this comment and fix memory-barriers.txt.
If Will agrees, like the following?
Thanx, Paul
------------------------------------------------------------------------
documentation: memory-barriers: Fix smp_mb__before_spinlock() semantics
Our current documentation claims that, when followed by an ACQUIRE, smp_mb__before_spinlock() orders prior loads against subsequent loads and stores, which isn't the intent. This commit therefore fixes the documentation to state that this sequence orders only prior stores against subsequent loads and stores.
In addition, the original intent of smp_mb__before_spinlock() was to only order prior loads against subsequent stores, however, people have started using it as if it ordered prior loads against subsequent loads and stores. This commit therefore also updates smp_mb__before_spinlock()'s header comment to reflect this new reality.
Documentation/memory-barriers.txt +3 -4
@@ -1784,10 +1784,9 @@ for each construct. These operations all imply certain barriers: Memory operations issued before the ACQUIRE may be completed after the ACQUIRE operation has completed. An smp_mb__before_spinlock(), - combined with a following ACQUIRE, orders prior loads against - subsequent loads and stores and also orders prior stores against - subsequent stores. Note that this is weaker than smp_mb()! The - smp_mb__before_spinlock() primitive is free on many architectures. + combined with a following ACQUIRE, orders prior stores against + subsequent loads and stores. Note that this is weaker than smp_mb()! + The smp_mb__before_spinlock() primitive is free on many architectures. (2) RELEASE operation implication:
include/linux/spinlock.h +1 -1
@@ -120,7 +120,7 @@ do { \/* * Despite its name it doesn't necessarily has to be a full barrier. * It should only guarantee that a STORE before the critical section -* can not be reordered with a LOAD inside this section. +* can not be reordered with LOADs and STOREs inside this section. * spin_lock() is the one-way barrier, this LOAD can not escape out * of the region. So the default implementation simply ensures that * a STORE can not move into the critical section, smp_wmb() should
Quoted 2 lines · Paul E. McKenney
If Will agrees, like the following?
Looks good to me, thanks ;)
Quoted 52 lines
documentation: memory-barriers: Fix
smp_mb__before_spinlock()semanticsOur current documentation claims that, when followed by an ACQUIRE,
smp_mb__before_spinlock()orders prior loads against subsequent loads and stores, which isn't the intent. This commit therefore fixes the documentation to state that this sequence orders only prior stores against subsequent loads and stores.In addition, the original intent of
smp_mb__before_spinlock()was to only order prior loads against subsequent stores, however, people have started using it as if it ordered prior loads against subsequent loads and stores. This commit therefore also updates smp_mb__before_spinlock()'s header comment to reflect this new reality.Cc Oleg Nesterov <[email protected]>Cc "Paul E. McKenney" <[email protected]>Cc Peter Zijlstra <[email protected]>Signed-off-by Will Deacon <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>Documentation/memory-barriers.txt +3
-4@@ -1784,10 +1784,9 @@ for each construct. These operations all imply certain barriers: Memory operations issued before the ACQUIRE may be completed after the ACQUIRE operation has completed. An smp_mb__before_spinlock(), - combined with a following ACQUIRE, orders prior loads against - subsequent loads and stores and also orders prior stores against - subsequent stores. Note that this is weaker than smp_mb()! The - smp_mb__before_spinlock() primitive is free on many architectures. + combined with a following ACQUIRE, orders prior stores against + subsequent loads and stores. Note that this is weaker than smp_mb()! + The smp_mb__before_spinlock() primitive is free on many architectures. (2) RELEASE operation implication:include/linux/spinlock.h +1
-1@@ -120,7 +120,7 @@ do { \/* * Despite its name it doesn't necessarily has to be a full barrier. * It should only guarantee that a STORE before the critical section -* can not be reordered with a LOAD inside this section. +* can not be reordered with LOADs and STOREs inside this section. * spin_lock() is the one-way barrier, this LOAD can not escape out * of the region. So the default implementation simply ensures that * a STORE can not move into the critical section, smp_wmb() should
Quoted 5 lines · Oleg Nesterov
Quoted 2 lines · Paul E. McKenney
If Will agrees, like the following?
Looks good to me, thanks ;)
Same here, thanks for sorting that out Paul.
Will
Quoted 8 lines · Will Deacon
Quoted 5 lines · Oleg Nesterov
Quoted 2 lines · Paul E. McKenney
If Will agrees, like the following?
Looks good to me, thanks ;)
Same here, thanks for sorting that out Paul.
Very good, thank you both!
Thanx, Paul