From: bot+bpf-ci@kernel.org
To: mt4022@columbia.edu,ast@kernel.org,daniel@iogearbox.net,andrii@kernel.org,yatsenko@meta.com,herbert@gondor.apana.org.au,akpm@linux-foundation.org,shuah@kernel.org
Cc: tgraf@suug.ch,eddyz87@gmail.com,memxor@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-crypto@vger.kernel.org,linux-kernel@vger.kernel.org,linux-kselftest@vger.kernel.org,tz2294@columbia.edu,mt4022@columbia.edu,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 v2 3/4] bpf: Don't spin on rhtab bucket locks with IRQs disabled
Date: Mon, 23 Nov 2026 01:13:57 +0000 (UTC) [thread overview]
Message-ID: <ef9a71b38c0ce6eb0a5112debcb242e7b52694ab5284c7a589e5952c299b3b68@mail.kernel.org> (raw)
In-Reply-To: <20261122-bpf-rhtab-irqs-disabled-v2-3-207aedcc2215@columbia.edu>
[-- Attachment #1: Type: text/plain, Size: 2664 bytes --]
> bpf: Don't spin on rhtab bucket locks with IRQs disabled
TL;DR: On CONFIG_SMP=n kernels without DEBUG_SPINLOCK, setting trylock_irqsoff
on rhtab may make every new-key insert and delete fail with -EBUSY when IRQs
are disabled, even if the bucket is unlocked, contrary to the commit message.
> diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c
> --- a/kernel/bpf/hashtab.c
> +++ b/kernel/bpf/hashtab.c
> @@ -2983,6 +2983,7 @@ struct bpf_rhtab {
> static const struct rhashtable_params rhtab_params = {
> .head_offset = offsetof(struct rhtab_elem, node),
> .key_offset = offsetof(struct rhtab_elem, data),
> + .trylock_irqsoff = true,
> };
On CONFIG_SMP=n kernels without CONFIG_DEBUG_SPINLOCK, can this make every
insert of a new key and every delete fail with -EBUSY whenever the caller
has IRQs disabled, even when no CPU holds the bucket lock?
rht_lock_or_busy() does this:
if (!params.trylock_irqsoff || !irqs_disabled()) {
*flags = rht_lock(tbl, bkt);
return true;
}
/* bit_spin_trylock() always succeeds on UP without DEBUG_SPINLOCK */
if (!IS_ENABLED(CONFIG_SMP) && !IS_ENABLED(CONFIG_DEBUG_SPINLOCK))
return false;
The check happens before any test of the bucket, so
__rhashtable_insert_fast() returns ERR_PTR(-EBUSY) and
__rhashtable_remove_fast_one() returns -EBUSY every time.
rhtab_map_update_elem() then frees the new element and returns -EBUSY, and
rhtab_delete_elem() returns -EBUSY. Updates of existing keys still work,
because rhtab_map_update_existing() takes no lock.
Programs running with IRQs disabled (int3-based kprobes, perf_event
programs, tracepoint, fentry and struct_ops programs in IRQs-off regions,
hardirq context) could insert and delete on UP before this patch, since
bit_spin_lock() only disables preemption there and never spins. Most
programs ignore the helper's return value, so the failure may go
unnoticed.
The commit message says these operations "now fail with -EBUSY when the
bucket is locked, by this CPU or another one, and work as before
otherwise". Is that accurate on such kernels?
Only the earlier rhashtable patch mentions the UP behaviour ("On UP
without DEBUG_SPINLOCK the lock bit isn't kept, so these callers always
get -EBUSY there"). Could this patch state that limitation too, or could
the lock bit be kept on UP for trylock_irqsoff tables so that rhtab fails
only when the bucket is actually held?
---
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/45090312341
next prev parent reply other threads:[~2026-11-23 1:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 0:25 [PATCH bpf v2 0/4] " Mani Tofigh via B4 Relay
2026-11-23 0:25 ` [PATCH bpf v2 1/4] rhashtable: Add trylock_irqsoff for callers that can't spin Mani Tofigh via B4 Relay
2026-11-23 0:58 ` bot+bpf-ci
2026-11-23 0:25 ` [PATCH bpf v2 2/4] rhashtable: Don't retry trylock_irqsoff lookups with IRQs disabled Mani Tofigh via B4 Relay
2026-11-23 0:25 ` [PATCH bpf v2 3/4] bpf: Don't spin on rhtab bucket locks " Mani Tofigh via B4 Relay
2026-11-23 1:13 ` bot+bpf-ci [this message]
2026-11-23 0:25 ` [PATCH bpf v2 4/4] selftests/bpf: Test rhtab deletes from inside a resize Mani Tofigh via B4 Relay
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=ef9a71b38c0ce6eb0a5112debcb242e7b52694ab5284c7a589e5952c299b3b68@mail.kernel.org \
--to=bot+bpf-ci@kernel.org \
--cc=akpm@linux-foundation.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=herbert@gondor.apana.org.au \
--cc=ihor.solodrai@linux.dev \
--cc=jolsa@kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@kernel.org \
--cc=martin.lau@linux.dev \
--cc=mason@kernel.org \
--cc=memxor@gmail.com \
--cc=mt4022@columbia.edu \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=tgraf@suug.ch \
--cc=tz2294@columbia.edu \
--cc=yatsenko@meta.com \
--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®