[PATCH bpf-next v2 3/5] bpf: Check recursion per task for programs on syscall tracepoints
From: Mike Bazov via B4 Relay
Date: Wed Nov 11 2026 - 15:08:07 EST
From: Mike Bazov <mikeba@xxxxxxxxxxxxxxx>
Since commit 57918341dd19 ("bpf: Add sleepable support for classic
tracepoint programs"), classic tracepoint programs on syscall
tracepoints run before perf disables preemption, through
trace_call_bpf_faultable() and bpf_prog_run_array_sleepable(). That
runner still checks recursion with the per-CPU counter, so a task
preempted inside such a program blocks every other task on the same
CPU, and their runs are dropped as recursion misses. A sleepable
program that faults keeps the counter raised for the whole sleep.
Use the per-task check from the previous patch. The runner publishes one
frame for the whole program array, so the program is recorded in it per
item and cleared before the next one.
Fixes: 57918341dd19 ("bpf: Add sleepable support for classic tracepoint programs")
Signed-off-by: Mike Bazov <mikeba@xxxxxxxxxxxxxxx>
---
include/linux/bpf.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 52e29b374b4a..649ff2950fd6 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -3549,9 +3549,9 @@ bpf_prog_run_array_sleepable(const struct bpf_prog_array *array,
continue;
}
- if (unlikely(!bpf_prog_get_recursion_context(prog))) {
+ if (unlikely(!bpf_prog_enter_recur_ctx(prog, &run_ctx.run_ctx))) {
bpf_prog_inc_misses_counter(prog);
- bpf_prog_put_recursion_context(prog);
+ bpf_prog_exit_recur_ctx(prog, &run_ctx.run_ctx);
item++;
continue;
}
@@ -3565,7 +3565,7 @@ bpf_prog_run_array_sleepable(const struct bpf_prog_array *array,
ret &= run_prog(prog, ctx);
}
- bpf_prog_put_recursion_context(prog);
+ bpf_prog_exit_recur_ctx(prog, &run_ctx.run_ctx);
item++;
}
bpf_reset_run_ctx(old_run_ctx);
--
2.43.0