From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Andrii Nakryiko" <andrii.nakryiko@gmail.com>
Cc: <mikeba@sentinelone.com>, <bpf@vger.kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"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 v3 0/4] bpf: Check recursion per task for preemptible programs
Date: Thu, 26 Nov 2026 03:29:55 +0000 [thread overview]
Message-ID: <DN4TOVIA1HK7.HEPNDE8WF6HZ@gmail.com> (raw)
In-Reply-To: <CAEf4BzYxBM3R1s6XDSpN5htzMho4Jp2uBsx9ZBKTPNBvmEffxw@mail.gmail.com>
On Wed Nov 25, 2026 at 5:35 AM UTC, Andrii Nakryiko wrote:
> On Tue, Nov 24, 2026 at 6:00 PM Alexei Starovoitov
> <alexei.starovoitov@gmail.com> wrote:
>>
>> On Tue, Nov 24, 2026 at 01:47 PM Andrii Nakryiko <andrii.nakryiko@gmail.com> wrote:
>> >> + for (ctx = old_ctx; ctx; ctx = ctx->saved_run_ctx) {
>> >
>> > do you mind checking if unlikely() around ctx improves performance?
>>
>> Mike,
>> pls try it on respin.
>>
>> > So basically to opt out from this behavior BPF program would need to
>> > stop using any per-CPU maps and just implement its own poor man's
>> > per-CPU storage?
>>
>> poor mans's per-cpu with bpf_get_smp_processor_id() shouldn't work
>> as an opt-out. See section 6.
>
> it's hard to weed through that verbiage in section 6, are you
> proposing to mark "needs per-cpu protection" if BPF program is calling
> bpf_get_smp_processor_id()?
yes, because it fixes real prog (falco).
>>
>> > And even using SEC(".percpu") would still be detected
>> > as per-CPU usage, right?
>>
>> This one is pretty much brand new, so there is no data to make
>> a decision. I can see arguments both ways.
>
> .percpu is backed by PERCPU_ARRAY, so we don't need any data to say
> that it will trigger the protection, do we?
I think it's slightly different vs normal percpu-array.
.percpu is pseudo_map_value
map is pseudo_map_fd.
So we can distinguish if we want to.
What I was trying to say is that .percpu is likely only in Leon's tool.
So this one is easy to fix is we do _not_ want 'needs_percpu_prot' on it.
I'm fine whichever way.
> Still, choosing between handling all events and having bugs (fixable)
> of handling per-CPU data in my BPF program, I'll choose the former.
but with the diff I proposed you get both:
per-cpu maps work and there are no missed events.
> Even if we don't want to make that a default, that's fine, but please
> at least give me a way to opt out from the kernel's
> over-protectiveness :) and not using per-cpu maps is not a way to opt
I don't follow what opt-out you're asking about.
Out of implicit preempt disable when you're using per-cpu array?
Why? How does it hurt your prog?
> out, it has its valid uses even with preemption. Think about simple
> per-CPU stats/counters updated with atomic operations and aggregated
wait what? per-cpu _with_ atomic? who does that?
bpf gained _local_ atomic just weeks ago.
per-cpu with full strong atomic is odd. Why would anyone use that?
The only case I can think of is nmi-safe-counters.
When we introduced per-cpu maps 10+ years ago the use case was
packet bytes and count, so that bpf prog can do
map_val->pkt_cnt++; map_val->pkt_bytes++;
and that's what everyone was doing since then.
combination of migrate_disable and preempt=lazy broke that accounting
pattern, so implicit preempt_disable unbreaks them.
next prev parent reply other threads:[~2026-11-26 3:29 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 11:29 [PATCH bpf-next v3 0/4] bpf: Check recursion per task for preemptible programs Mike Bazov via B4 Relay
2026-11-17 11:29 ` [PATCH bpf-next v3 1/4] bpf: Avoid per-CPU private stack in preemptible tracing progs Mike Bazov via B4 Relay
2026-11-17 11:44 ` sashiko-bot
2026-11-17 11:29 ` [PATCH bpf-next v3 2/4] bpf: Mark programs whose runs must not overlap on a CPU Mike Bazov via B4 Relay
2026-11-19 5:04 ` JP Kobryn (CrowdStrike)
2026-11-19 11:23 ` [EXT.MSG] " Mike Bazov
2026-11-17 11:29 ` [PATCH bpf-next v3 3/4] bpf: Check program recursion per task via bpf_ctx Mike Bazov via B4 Relay
2026-11-17 12:20 ` bot+bpf-ci
2026-11-19 5:05 ` JP Kobryn (CrowdStrike)
2026-11-19 11:35 ` [EXT.MSG] " Mike Bazov
2026-11-23 12:49 ` Mike Bazov
2026-11-24 22:04 ` Andrii Nakryiko
2026-11-25 14:12 ` Mike Bazov
2026-11-17 11:29 ` [PATCH bpf-next v3 4/4] selftests/bpf: Add preemption recursion test for tracing programs Mike Bazov via B4 Relay
2026-11-19 5:09 ` JP Kobryn (CrowdStrike)
2026-11-19 12:13 ` [EXT.MSG] " Mike Bazov
2026-11-19 5:02 ` [PATCH bpf-next v3 0/4] bpf: Check recursion per task for preemptible programs JP Kobryn (CrowdStrike)
[not found] ` <CAPnbwjpmRCR3F4V3StUz=702AdWZzHHZjP68GepnYdYykjoC8g@mail.gmail.com>
2026-11-19 11:22 ` [EXT.MSG] " Mike Bazov
2026-11-21 3:01 ` JP Kobryn (CrowdStrike)
2026-11-24 6:21 ` Alexei Starovoitov
2026-11-24 16:10 ` Mike Bazov
2026-11-24 20:26 ` Alexei Starovoitov
2026-11-25 12:03 ` Mike Bazov
2026-11-26 2:48 ` Alexei Starovoitov
2026-11-24 21:47 ` Andrii Nakryiko
2026-11-25 2:00 ` Alexei Starovoitov
2026-11-25 5:35 ` Andrii Nakryiko
2026-11-26 3:29 ` Alexei Starovoitov [this message]
2026-11-25 2:06 ` JP Kobryn (CrowdStrike)
2026-11-25 4:02 ` Alexei Starovoitov
2026-11-25 20:23 ` JP Kobryn (CrowdStrike)
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=DN4TOVIA1HK7.HEPNDE8WF6HZ@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii.nakryiko@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