BPF List
 help / color / mirror / Atom feed
* [PATCH bpf v3 0/7] Make sleepable arena paths use sleepable alloc_pages
@ 2026-09-25 20:39 Emil Tsalapatis
  2026-09-25 20:39 ` [PATCH bpf v3 1/7] bpf: Use an llist for page allocations Emil Tsalapatis
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: Emil Tsalapatis @ 2026-09-25 20:39 UTC (permalink / raw)
  To: bpf; +Cc: ast, andrii, eddyz87, memxor, daniel, Emil Tsalapatis

The arena_alloc_pages() call takes a sleepable argument based on whether
its caller is a sleepable BPF function. This flag, along with the context
the kfunc is called in, decides whether the call will try to fulfill the
allocation using the regular or the _nolock variant of the alloc_pages
API, by means of bpf_map_alloc_pages().

However, the arena_alloc_pages() call currently only makes allocations
inside an IRQ-disabled critical section. This forces all allocations to
use the _nolock() API, which may eagerly fail where the regular variant
would eventually succeed. There have been reports of this happening for
sched-ext schedulers.

Restructure arena_alloc_pages() to use the _nolock() page allocation API
only when necessary. This requires moving allocations outside of the 
spinlock critical section for sleepable calls, which in turn requires
slightly different logic in the allocation path. Make a separate
sleepable code path that implements this logic within
arena_alloc_pages().

Also fix kfunc specialization to not unnecessarily force the nonsleepable version
of bpf_arena_alloc_pages() for call sites that do not need it. This requires
making specialization per-call site instead of overwriting the descriptor
during fixups. 

Signed-off-by: Emil Tsalapatis <emil@etsalapatis.com>

v1 -> v2 (https://lore.kernel.org/bpf/20260824082530.47553-1-emil@etsalapatis.com/)

- Keep the sleepable and non-sleepable allocation paths within
  arena_alloc_pages (Alexei)
- Incorporate bot feedback on selftests (bot-ci)

v2 -> v3 (https://lore.kernel.org/bpf/20260923191125.5311-1-emil@etsalapatis.com/)

- Remove the intermediate page array allocation in bpf_arena_alloc_pages() and
  use the pcp_llist pointer instead (Alexei)
- Fix function specialization to only specialize to the nonsleepable version
  when necessary


Emil Tsalapatis (7):
  bpf: Use an llist for page allocations
  bpf: Add sleepable argument to bpf_alloc_pages()
  bpf: Add sleepable arena page allocation path
  selftests/bpf: Test large allocations for both sleepable/nonsleepable
    arena users
  bpf: Support call-site kfunc specialization for near calls
  bpf: Support call-site kfunc specialization for far calls
  selftests/bpf: Test per-call site function specialization

 include/linux/bpf.h                           |  10 +-
 include/linux/bpf_verifier.h                  |  15 +-
 kernel/bpf/arena.c                            | 186 +++++++++++-------
 kernel/bpf/fixups.c                           |  18 +-
 kernel/bpf/syscall.c                          |  43 ++--
 kernel/bpf/verifier.c                         |  82 +++++++-
 .../selftests/bpf/prog_tests/file_reader.c    |  15 ++
 .../testing/selftests/bpf/progs/file_reader.c | 129 ++++++++++++
 .../bpf/progs/verifier_arena_large.c          |  64 ++++--
 9 files changed, 434 insertions(+), 128 deletions(-)

-- 
2.52.0


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

end of thread, other threads:[~2026-09-26  7:47 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-25 20:39 [PATCH bpf v3 0/7] Make sleepable arena paths use sleepable alloc_pages Emil Tsalapatis
2026-09-25 20:39 ` [PATCH bpf v3 1/7] bpf: Use an llist for page allocations Emil Tsalapatis
2026-09-25 20:39 ` [PATCH bpf v3 2/7] bpf: Add sleepable argument to bpf_alloc_pages() Emil Tsalapatis
2026-09-25 20:39 ` [PATCH bpf v3 3/7] bpf: Add sleepable arena page allocation path Emil Tsalapatis
2026-09-25 21:25   ` Alexei Starovoitov
2026-09-25 21:57     ` Emil Tsalapatis
2026-09-26  7:47       ` Alexei Starovoitov
2026-09-25 20:39 ` [PATCH bpf v3 4/7] selftests/bpf: Test large allocations for both sleepable/nonsleepable arena users Emil Tsalapatis
2026-09-25 20:39 ` [PATCH bpf v3 5/7] bpf: Support call-site kfunc specialization for near calls Emil Tsalapatis
2026-09-25 20:39 ` [PATCH bpf v3 6/7] bpf: Support call-site kfunc specialization for far calls Emil Tsalapatis
2026-09-25 20:39 ` [PATCH bpf v3 7/7] selftests/bpf: Test per-call site function specialization Emil Tsalapatis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox