Skip to contentSkip to conversation

locking/qspinlock: Fix typo of lock word transition in the uncontended case

PATCH In review Zenghui Yu 3 participants 3 messages Jul 15, 2021 – Aug 9, 2021 Locking primitives

lore
Share & tools
lore

Zenghui Yu

author
#0 lore raw

PATCH 1/1 locking/qspinlock: Fix typo of lock word transition in the uncontended case

If the queue head is the only one in the queue and nobody is concurrently setting PENDING bit, the uncontended transition should be n,0,0 -> 0,0,1.

Fix the typo.

---
 kernel/locking/qspinlock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/locking/qspinlock.c +1 -1
index cbff6ba53d56..591835415698 100644
@@ -355,7 +355,7 @@ void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
 	 * If we observe contention, there is a concurrent locker.
 	 *
 	 * Undo and queue; our setting of PENDING might have made the
-	 * n,0,0 -> 0,0,0 transition fail and it will now be waiting
+	 * n,0,0 -> 0,0,1 transition fail and it will now be waiting
 	 * on @next to become !NULL.
 	 */
 	if (unlikely(val & ~_Q_LOCKED_MASK)) {
Signature · 1 line
2.19.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 15 lines · Zenghui Yu

If the queue head is the only one in the queue and nobody is concurrently setting PENDING bit, the uncontended transition should be n,0,0 -> 0,0,1.

Fix the typo.

---
 kernel/locking/qspinlock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/locking/qspinlock.c +0 -0
index cbff6ba53d56..591835415698 100644

kernel/locking/qspinlock.c void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val) · line 360

Quoted 7 lines
kernel/locking/qspinlock.c +1 -1
@@ -355,7 +355,7 @@ void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
 	 * If we observe contention, there is a concurrent locker.
 	 *
 	 * Undo and queue; our setting of PENDING might have made the
-	 * n,0,0 -> 0,0,0 transition fail and it will now be waiting
+	 * n,0,0 -> 0,0,1 transition fail and it will now be waiting
 	 * on @next to become !NULL.
 	 */

I think this is an important typo fix as you're right that we don't transition directly from having a waitqueue installed in the tail straight to an unlocked state.

Then again, I acked the patch introducing this comment so what do I know?

Will

Acked-by
#2 lore raw
Quoted 27 lines · Will Deacon
Quoted 15 lines · Zenghui Yu

If the queue head is the only one in the queue and nobody is concurrently setting PENDING bit, the uncontended transition should be n,0,0 -> 0,0,1.

Fix the typo.

---
  kernel/locking/qspinlock.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
kernel/locking/qspinlock.c +0 -0
index cbff6ba53d56..591835415698 100644

kernel/locking/qspinlock.c void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val) · line 360

Quoted 7 lines
kernel/locking/qspinlock.c +1 -1
@@ -355,7 +355,7 @@ void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
  	 * If we observe contention, there is a concurrent locker.
  	 *
  	 * Undo and queue; our setting of PENDING might have made the
-	 * n,0,0 -> 0,0,0 transition fail and it will now be waiting
+	 * n,0,0 -> 0,0,1 transition fail and it will now be waiting
  	 * on @next to become !NULL.
  	 */

I think this is an important typo fix as you're right that we don't transition directly from having a waitqueue installed in the tail straight to an unlocked state.

Quoted 3 lines

Then again, I acked the patch introducing this comment so what do I know?

We usually focus more on the actual code than the associated comment. I am not surprise we may miss that. I do agree that the proposed change is better.