]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
bpf: Add sleepable support for raw tracepoint programs
authorMykyta Yatsenko <yatsenko@meta.com>
Wed, 22 Apr 2026 19:41:06 +0000 (12:41 -0700)
committerKumar Kartikeya Dwivedi <memxor@gmail.com>
Wed, 22 Apr 2026 20:44:24 +0000 (22:44 +0200)
commit439ebd5b5708f236f7a4a9784194f7ecb77cd814
treef82bb95a9f0dbcd041bb9c3892103aa7003c228e
parent9012cf2491e3c5d28d098b0d6da804af82977032
bpf: Add sleepable support for raw tracepoint programs

Rework __bpf_trace_run() to support sleepable BPF programs by using
explicit RCU flavor selection, following the uprobe_prog_run() pattern.

For sleepable programs, use rcu_read_lock_tasks_trace() for lifetime
protection with migrate_disable(). For non-sleepable programs, use the
regular rcu_read_lock_dont_migrate().

Remove the preempt_disable_notrace/preempt_enable_notrace pair from
the faultable tracepoint BPF probe wrapper in bpf_probe.h, since
migration protection and RCU locking are now handled per-program
inside __bpf_trace_run().

Adapt bpf_prog_test_run_raw_tp() for sleepable programs: reject
BPF_F_TEST_RUN_ON_CPU since sleepable programs cannot run in hardirq
or preempt-disabled context, and call __bpf_prog_test_run_raw_tp()
directly instead of via smp_call_function_single(). Rework
__bpf_prog_test_run_raw_tp() to select RCU flavor per-program and
add per-program recursion context guard for private stack safety.

Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/bpf/20260422-sleepable_tracepoints-v13-1-99005dff21ef@meta.com
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
include/trace/bpf_probe.h
kernel/trace/bpf_trace.c
net/bpf/test_run.c