Skip to content

Commit 125b0bb

Browse files
committed
asm-generic: qspinlock: fix queued_spin_value_unlocked() implementation
We really don't want to do atomic_read() or anything like that, since we already have the value, not the lock. The whole point of this is that we've loaded the lock from memory, and we want to check whether the value we loaded was a locked one or not. The main use of this is the lockref code, which loads both the lock and the reference count in one atomic operation, and then works on that combined value. With the atomic_read(), the compiler would pointlessly spill the value to the stack, in order to then be able to read it back "atomically". This is the qspinlock version of commit c6f4a90 ("asm-generic: ticket-lock: Optimize arch_spin_value_unlocked()") which fixed this same bug for ticket locks. Cc: Guo Ren <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Waiman Long <[email protected]> Link: https://lore.kernel.org/all/CAHk-=whNRv0v6kQiV5QO6DJhjH4KEL36vWQ6Re8Csrnh4zbRkQ@mail.gmail.com/ Signed-off-by: Linus Torvalds <[email protected]>
1 parent c2d5304 commit 125b0bb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/asm-generic/qspinlock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static __always_inline int queued_spin_is_locked(struct qspinlock *lock)
7070
*/
7171
static __always_inline int queued_spin_value_unlocked(struct qspinlock lock)
7272
{
73-
return !atomic_read(&lock.val);
73+
return !lock.val.counter;
7474
}
7575

7676
/**

0 commit comments

Comments
 (0)