[PATCH bpf v2 0/4] bpf: Don't spin on rhtab bucket locks with IRQs disabled
From: Mani Tofigh via B4 Relay
Date: Sun Nov 22 2026 - 19:25:20 EST
A BPF program with IRQs disabled can run inside a bucket lock's critical
section on its own CPU, e.g., a kprobe on the hash function the resize
worker calls with the lock held. An insert or delete of that bucket
then spins forever, and a lookup can retry forever.
v2 follows Alexei's trylock design (patch 1) and Mykyta's lookup change
(patch 2), turns it on for rhtab (patch 3) and adds a selftest (patch
4). The kvmalloc(GFP_ATOMIC) in rhashtable_insert_rehash() is left for
a follow-up.
Reproducer: https://github.com/manitofigh/files/blob/main/linux-repros/rhashlock.c
---
Changes in v2:
- Trylock the bucket lock with IRQs disabled instead of failing every
insert and delete (Alexei)
- Drop bpf_disable_instrumentation() from rhtab (Alexei)
- Don't retry lookups with IRQs disabled (Mykyta)
- Add a selftest
- Link to v1: https://patch.msgid.link/20261103-bpf-rhtab-irqs-disabled-v1-1-9874d96a088c@xxxxxxxxxxxx
---
Mani Tofigh (4):
rhashtable: Add trylock_irqsoff for callers that can't spin
rhashtable: Don't retry trylock_irqsoff lookups with IRQs disabled
bpf: Don't spin on rhtab bucket locks with IRQs disabled
selftests/bpf: Test rhtab deletes from inside a resize
include/linux/rhashtable-types.h | 3 ++
include/linux/rhashtable.h | 45 ++++++++++++++++++++++--
kernel/bpf/hashtab.c | 17 ++-------
lib/rhashtable.c | 9 +++--
tools/testing/selftests/bpf/prog_tests/rhash.c | 34 ++++++++++++++++++
tools/testing/selftests/bpf/progs/rhash_resize.c | 34 ++++++++++++++++++
6 files changed, 122 insertions(+), 20 deletions(-)
---
base-commit: 84afebd853437e44cb71f718be11d90e4c1a59dd
change-id: 20261103-bpf-rhtab-irqs-disabled-c4646c9e0fe2
Best regards,
--
Mani Tofigh <mt4022@xxxxxxxxxxxx>