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, 03 Dec 2026 20:03:07 +0000 [thread overview]
Message-ID: <DNBD7525M49F.10V12YJ4V4JOU@gmail.com> (raw)
In-Reply-To: <DNAPUBI5JFNS.I5B7K2RNSXA7@gmail.com>
On Thu Dec 3, 2026 at 1:44 AM UTC, Alexei Starovoitov wrote:
> On Wed Dec 2, 2026 at 5:29 PM UTC, Andrii Nakryiko wrote:
> >
> > slot = (old & 1) ? scratch_slot_get_slow(mask, old, depth) : zero;
> >
> > If I change "zero" above to actual "0", it causes 3x more verification
> > instructions (which for the task switch handler gets me over 1mln),
> > because verifier starts tracking zero const value as special branch
> > everywhere, with eliding NULL check after map lookup, etc. zero global
> > var mitigates that.
>
> Will check.
I see the growth since 7.1. That line alone doesn't give me 3x and 1M
together. Processed insns of wprof_task_switch in pull 170, -mcpu=v4,
default rodata:
clang 20 clang 24
kernel zero 0 zero 0
---------------- ---- ---- ---- ----
6.18 164K 166K 157K 159K
7.1 218K 259K 206K 248K
7.3 234K 320K 212K 294K
7.4-rc 159K 245K 137K 219K
bpf-next 174K 242K 314K 511K
bpf-next + [1] 93K 94K 112K 112K
Which kernel, clang and options did you use?
Did you change only this line?
The elision is there since 6.14 and costs nothing up to 7.1.
The growth has two causes. clang 20, each cause removed:
kernel zero 0 no spill same ids both
-------- ---- ---- -------- -------- ----
7.1 218K 259K 218K 259K 218K
7.3 234K 320K 255K 292K 234K
7.4-rc 159K 245K 180K 217K 159K
bpf-next 174K 242K 180K 243K 181K
- Spill, since 7.1. With 0 clang keeps 'prev' in r3 instead of r6.
One arm of task_id() spills it around bpf_get_smp_processor_id().
task_infos_emit() walks items[] with a pointer. Stack liveness takes
that as a read of the whole frame. So the dead slot keeps the two arms
apart. The value 0 plays no role here.
- Ids, since 7.2. The NULL check keeps the id, see 06d518a5583f.
An elided lookup has no id, so check_ids() fails.
So the gain depends on register allocation. With SCRATCH_DEPTH 4
7.3 takes 290K with 'zero' and 243K with 0.
Pls keep 'zero' for released kernels. Without the other 'zero' lines
11 wprof_ut_* progs hit 1M on 6.18 to 7.4-rc.
bpf-next loads all 46 progs without 'zero'.
wprof_task_switch is slow on bpf-next for two more reasons:
- task_state() returns a value of one of two maps. Such states stay
apart.
- task_infos_emit() loads tis->items[i].task with a variable offset.
Pass 0 gets a number and fails, so more passes follow.
[1] fixes the liveness and the two maps.
With it 0 and 'zero' cost the same, 135-185 ms instead of 250-750 ms.
[1] https://lore.kernel.org/bpf/20261203195823.4058490-1-alexei.starovoitov@gmail.com/
next prev parent reply other threads:[~2026-12-03 20:03 UTC|newest]
Thread overview: 35+ 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
2026-12-01 21:06 ` Andrii Nakryiko
2026-12-02 17:29 ` Andrii Nakryiko
2026-12-03 1:44 ` Alexei Starovoitov
2026-12-03 20:03 ` 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=DNBD7525M49F.10V12YJ4V4JOU@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