From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: <mikeba@sentinelone.com>, <bpf@vger.kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>
Cc: "Martin KaFai Lau" <martin.lau@linux.dev>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Jiri Olsa" <jolsa@kernel.org>,
"John Fastabend" <john.fastabend@gmail.com>,
"Emil Tsalapatis" <emil@etsalapatis.com>,
"Ihor Solodrai" <ihor.solodrai@linux.dev>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Masami Hiramatsu" <mhiramat@kernel.org>,
"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>,
"JP Kobryn" <jp.kobryn@linux.dev>,
<linux-trace-kernel@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH bpf-next v2 0/5] bpf: Check recursion per task for preemptible programs
Date: Thu, 12 Nov 2026 01:18:42 +0000 [thread overview]
Message-ID: <DMSU4S7392QQ.357Y29RMDZ8BJ@gmail.com> (raw)
In-Reply-To: <20261111-bpf-preempt-v2-r2-v2-0-9d8f6b952ad2@sentinelone.com>
On Wed, Nov 11, 2026 at 11:39 AM Mike Bazov via B4 Relay <devnull+mikeba.sentinelone.com@kernel.org> wrote:
> This series checks recursion per task instead. Each run already links a
> run context into the task's chain (current->bpf_ctx); the run context
> now records the program, and the check walks the task's chain.
The link walk doesn't look too bad,
but pls share bench trig-fentry/exit/rawtp numbers.
Maybe we should do a per-task array of progs instead to detect recursion?
It's likely more cache efficient than link list walk.
Just for the record here is the illustration of
the case I was concerned about earlier:
task A, cpu 0 task B, cpu 0
buf = lookup(&percpu_scratch)
fill buf
<preempted>
buf = lookup(&percpu_scratch)
fill buf
output(buf)
output(buf) <- data of B
today with the series
----------- ----------------- -----------------
run of B skipped runs
event of A correct has the data of B
who sees it recursion_misses nobody
A prog with a scratch map of its own is correct today and
that's what plenty of production bpf progs use today.
This patch set will make them send corrupted events, and nothing counts
this corrupted events. Today, at least, you have a miss count.
Please add it to commit log, so that trade-offs are clear.
Commit log here and in cover letter talk about 'what'.
It needs 'why' and 'trade offs'.
Also should we add an verbose warning to the verifier that
when the tracing prog that uses per-cpu maps might have corrupted
per-cpu data? I know, no one is reading the warnings unless they
are verifier errors, but above scenario really worries me.
I thought about automatic insertion of bpf_preempt_disable() for such lookups
and bpf_preempt_enable() in epilogue.
Maybe that's the way?
> - Timed may_goto keeps its budget per program and CPU, as before: a run
> in another task can renew the budget of a preempted run.
Not quite.
Today prog->active rejects B before the first insns of the prog.
These insns set count and timestamp.
With the link list approach every B gives A 250 ms more:
task A, cpu 0 task B, cpu 0
spins on may_goto
<preempted>
enters the prog:
count = BPF_MAX_TIMED_LOOPS
timestamp = 0
spins for 250 ms more
On a hot function A never ends, and it holds rcu_read_lock.
So the promise of may_goto that I just fixed a week or so ago
will be borken again.
pw-bot: cr
prev parent reply other threads:[~2026-11-12 1:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 19:39 Mike Bazov via B4 Relay
2026-11-11 19:39 ` [PATCH bpf-next v2 1/5] bpf: Avoid per-CPU private stack in preemptible tracing progs Mike Bazov via B4 Relay
2026-11-11 21:07 ` bot+bpf-ci
2026-11-11 19:39 ` [PATCH bpf-next v2 2/5] bpf: Check program recursion per task via bpf_ctx Mike Bazov via B4 Relay
2026-11-12 1:04 ` Alexei Starovoitov
2026-11-11 19:39 ` [PATCH bpf-next v2 3/5] bpf: Check recursion per task for programs on syscall tracepoints Mike Bazov via B4 Relay
2026-11-11 19:39 ` [PATCH bpf-next v2 4/5] selftests/bpf: Add trampoline and raw_tp preemption recursion test Mike Bazov via B4 Relay
2026-11-11 19:39 ` [PATCH bpf-next v2 5/5] selftests/bpf: Test syscall tracepoint programs under preemption Mike Bazov via B4 Relay
2026-11-12 1:18 ` Alexei Starovoitov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DMSU4S7392QQ.357Y29RMDZ8BJ@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=jp.kobryn@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mathieu.desnoyers@efficios.com \
--cc=memxor@gmail.com \
--cc=mhiramat@kernel.org \
--cc=mikeba@sentinelone.com \
--cc=rostedt@goodmis.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®