mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: bot+bpf-ci@kernel.org
To: jain.sm@gmail.com,memxor@gmail.com,ast@kernel.org
Cc: daniel@iogearbox.net,andrii@kernel.org,eddyz87@gmail.com,martin.lau@linux.dev,song@kernel.org,yonghong.song@linux.dev,jolsa@kernel.org,emil@etsalapatis.com,ihor.solodrai@linux.dev,bpf@vger.kernel.org,linux-kernel@vger.kernel.org,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next v2] rqspinlock: Keep claiming the lock while the queue head is still the tail
Date: Wed, 18 Nov 2026 11:27:44 +0000 (UTC)	[thread overview]
Message-ID: <5c75ee187165e77ac4a71e59084adaa793051388b57dd217f63430c2c8ebdbca@mail.kernel.org> (raw)
In-Reply-To: <20261118104758.98620-1-jain.sm@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2276 bytes --]

> 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

      reply	other threads:[~2026-11-18 11:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 10:47 Shashank Mohan Jain
2026-11-18 11:27 ` bot+bpf-ci [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5c75ee187165e77ac4a71e59084adaa793051388b57dd217f63430c2c8ebdbca@mail.kernel.org \
    --to=bot+bpf-ci@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=jain.sm@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mason@kernel.org \
    --cc=memxor@gmail.com \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®