Patch "asm-generic: qspinlock: fix queued_spin_value_unlocked() implementation" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    asm-generic: qspinlock: fix queued_spin_value_unlocked() implementation

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     asm-generic-qspinlock-fix-queued_spin_value_unlocked.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 1a9f60ee5b64483d4a1462a2b62d230e2e621293
Author: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Date:   Thu Nov 9 22:22:13 2023 -0800

    asm-generic: qspinlock: fix queued_spin_value_unlocked() implementation
    
    [ Upstream commit 125b0bb95dd6bec81b806b997a4ccb026eeecf8f ]
    
    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 c6f4a9002252 ("asm-generic:
    ticket-lock: Optimize arch_spin_value_unlocked()") which fixed this same
    bug for ticket locks.
    
    Cc: Guo Ren <guoren@xxxxxxxxxx>
    Cc: Ingo Molnar <mingo@xxxxxxxxxx>
    Cc: Waiman Long <longman@xxxxxxxxxx>
    Link: https://lore.kernel.org/all/CAHk-=whNRv0v6kQiV5QO6DJhjH4KEL36vWQ6Re8Csrnh4zbRkQ@xxxxxxxxxxxxxx/
    Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/include/asm-generic/qspinlock.h b/include/asm-generic/qspinlock.h
index 9cc457597ddf8..1a688e5b8b0b5 100644
--- a/include/asm-generic/qspinlock.h
+++ b/include/asm-generic/qspinlock.h
@@ -47,7 +47,7 @@ static __always_inline int queued_spin_is_locked(struct qspinlock *lock)
  */
 static __always_inline int queued_spin_value_unlocked(struct qspinlock lock)
 {
-	return !atomic_read(&lock.val);
+	return !lock.val.counter;
 }
 
 /**




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux