Re: [PATCH bpf-next v2] rqspinlock: Keep claiming the lock while the queue head is still the tail

From: bot+bpf-ci

Date: Wed Nov 18 2026 - 06:27:50 EST


> rqspinlock: Keep claiming the lock while the queue head is still the tail

TL;DR: Nits only: two comments in rqspinlock.c (queue-head claim and pending
undo path) still describe the old behaviour and could be updated to match the
new retry loop.

> diff --git a/kernel/bpf/rqspinlock.c b/kernel/bpf/rqspinlock.c
> --- a/kernel/bpf/rqspinlock.c
> +++ b/kernel/bpf/rqspinlock.c

[ ... ]

> @@ -624,20 +624,23 @@ int __lockfunc resilient_queued_spin_lock_slowpath(rqspinlock_t *lock, u32 val)
> * Otherwise, we only need to grab the lock.
> */
>
> - /*
> - * Note: at this point: (val & _Q_PENDING_MASK) == 0, because of the
> - * above wait condition, therefore any concurrent setting of
> - * PENDING will make the uncontended transition fail.
> - */
> if ((val & _Q_TAIL_MASK) == tail) {
> - if (atomic_try_cmpxchg_relaxed(&lock->val, &val, _Q_LOCKED_VAL))
> - goto release; /* No contention */
> + u32 new = _Q_LOCKED_VAL;
> +
> + for (;;) {
> + if (atomic_try_cmpxchg_relaxed(&lock->val, &val, new))
> + goto release; /* No queued successor */
> + if ((val & _Q_TAIL_MASK) != tail)
> + break;
> + /* A pending claimant can abandon before publishing a tail. */
> + new = _Q_LOCKED_VAL | (val & _Q_PENDING_MASK);
> + }
> }

This isn't a bug, but the comment block just above this hunk still
describes the old behaviour:

* If the queue head is the only one in the queue (lock value == tail)
* and nobody is pending, clear the tail code and grab the lock.

The new loop also clears the tail when pending is set, keeping the
pending bit (the n,1,0 -> 0,1,1 transition). Could that comment be
updated?

Similarly, the comment on the pending claimant's undo path still says:

* 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
* on @next to become !NULL.

With this change the head no longer waits on @next in that case while the
tail is still its own. Could that comment be adjusted in this patch as
well?


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/44290867653