mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH bpf v2 0/4] bpf: Don't spin on rhtab bucket locks with IRQs disabled
@ 2026-11-23  0:25 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
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Mani Tofigh via B4 Relay @ 2026-11-23  0:25 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Mykyta Yatsenko, Herbert Xu, Andrew Morton, Shuah Khan
  Cc: Thomas Graf, Eduard Zingerman, Kumar Kartikeya Dwivedi,
	Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa,
	Emil Tsalapatis, Ihor Solodrai, bpf, linux-crypto, linux-kernel,
	linux-kselftest, tz2294, Mani Tofigh

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@columbia.edu

---
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@columbia.edu>



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-11-23  1:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23  0:25 [PATCH bpf v2 0/4] bpf: Don't spin on rhtab bucket locks with IRQs disabled 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
2026-11-23  0:25 ` [PATCH bpf v2 4/4] selftests/bpf: Test rhtab deletes from inside a resize Mani Tofigh via B4 Relay

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®