mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-12-05 10:17:58 -05:00
locking/mcs: Fix mcs_spin_lock() ordering
Similar to commitb4b29f9485("locking/osq: Fix ordering of node initialisation in osq_lock") the use of xchg_acquire() is fundamentally broken with MCS like constructs. Furthermore, it turns out we rely on the global transitivity of this operation because the unlock path observes the pointer with a READ_ONCE(), not an smp_load_acquire(). This is non-critical because the MCS code isn't actually used and mostly serves as documentation, a stepping stone to the more complex things we've build on top of the idea. Reported-by: Andrea Parri <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Paul E. McKenney <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Will Deacon <[email protected]> Fixes:3552a07a9c("locking/mcs: Use acquire/release semantics") Signed-off-by: Ingo Molnar <[email protected]>
This commit is contained in:
parent
39a1142dbb
commit
920c720aa5
1 changed files with 7 additions and 1 deletions
|
|
@ -67,7 +67,13 @@ void mcs_spin_lock(struct mcs_spinlock **lock, struct mcs_spinlock *node)
|
|||
node->locked = 0;
|
||||
node->next = NULL;
|
||||
|
||||
prev = xchg_acquire(lock, node);
|
||||
/*
|
||||
* We rely on the full barrier with global transitivity implied by the
|
||||
* below xchg() to order the initialization stores above against any
|
||||
* observation of @node. And to provide the ACQUIRE ordering associated
|
||||
* with a LOCK primitive.
|
||||
*/
|
||||
prev = xchg(lock, node);
|
||||
if (likely(prev == NULL)) {
|
||||
/*
|
||||
* Lock acquired, don't need to set node->locked to 1. Threads
|
||||
|
|
|
|||
Loading…
Reference in a new issue