[tip: locking/core] locking/osq: Simplify osq_unlock()
From: tip-bot2 for Peter Zijlstra
Date: Fri Nov 06 2026 - 05:40:47 EST
The following commit has been merged into the locking/core branch of tip:
Commit-ID: 4a701e4af8215226807c59915ed5d2ffbcde070f
Gitweb: https://git.kernel.org/tip/4a701e4af8215226807c59915ed5d2ffbcde070f
Author: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
AuthorDate: Tue, 15 Sep 2026 15:54:34 +02:00
Committer: Ingo Molnar <mingo@xxxxxxxxxx>
CommitterDate: Fri, 06 Nov 2026 11:16:24 +01:00
locking/osq: Simplify osq_unlock()
It is now easy to observe that the start of osq_unlock() and the
body of osq_wait_unlink_next() are in fact identical and there is
no point in repeating this code.
No change in functionality intended.
Suggested-by: David Laight <david.laight.linux@xxxxxxxxx>
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Cc: Waiman Long <longman@xxxxxxxxxx>
Cc: linux-kernel@xxxxxxxxxxxxxxx
---
kernel/locking/osq_lock.c | 19 -------------------
1 file changed, 19 deletions(-)
diff --git a/kernel/locking/osq_lock.c b/kernel/locking/osq_lock.c
index e3cd066..a6c89e5 100644
--- a/kernel/locking/osq_lock.c
+++ b/kernel/locking/osq_lock.c
@@ -216,24 +216,5 @@ bool osq_lock(struct optimistic_spin_queue *lock)
void osq_unlock(struct optimistic_spin_queue *lock)
{
- struct optimistic_spin_node *node, *next;
- int curr = encode_cpu(smp_processor_id());
-
- /*
- * Fast path for the uncontended case.
- */
- if (atomic_try_cmpxchg_release(&lock->tail, &curr, OSQ_UNLOCKED_VAL))
- return;
-
- /*
- * Second most likely case.
- */
- node = this_cpu_ptr(&osq_node);
- next = xchg(&node->next, NULL);
- if (next) {
- WRITE_ONCE(next->prev_cpu, 0);
- return;
- }
-
osq_wait_unlink_next(lock, OSQ_UNLOCKED_VAL);
}