Re: [PATCH v3 next 1/5] Only clear node->locked in the slow osq_lock() path

From: David Laight

Date: Fri Mar 06 2026 - 18:01:25 EST


On Fri, 6 Mar 2026 22:51:46 +0000
david.laight.linux@xxxxxxxxx wrote:

Apologies to Yafang for mistyping his address...

> From: David Laight <david.laight.linux@xxxxxxxxx>
>
> node->locked is used to indicate that the owner of the lock has handed it
> off to the waiting CPU.
> As such it's value is only relevant in the slow path so it need not be
> initialised in the fast path.
>
> Signed-off-by: David Laight <david.laight.linux@xxxxxxxxx>
> ---
> kernel/locking/osq_lock.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/locking/osq_lock.c b/kernel/locking/osq_lock.c
> index b4233dc2c2b0..96c6094157b5 100644
> --- a/kernel/locking/osq_lock.c
> +++ b/kernel/locking/osq_lock.c
> @@ -97,7 +97,6 @@ bool osq_lock(struct optimistic_spin_queue *lock)
> int curr = encode_cpu(smp_processor_id());
> int old;
>
> - node->locked = 0;
> node->next = NULL;
> node->cpu = curr;
>
> @@ -113,6 +112,7 @@ bool osq_lock(struct optimistic_spin_queue *lock)
>
> prev = decode_cpu(old);
> node->prev = prev;
> + node->locked = 0;
>
> /*
> * osq_lock() unqueue