From: Eduard Zingerman <eddyz87@gmail.com>
To: Barret Rhoden <brho@google.com>
Cc: Levi Zim <i@kxxt.dev>,
bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org,
daniel@iogearbox.net, martin.lau@linux.dev, kernel-team@fb.com,
yonghong.song@linux.dev,
Matt Bobrowski <mattbobrowski@google.com>,
Josh Don <joshdon@google.com>
Subject: Re: [PATCH 0/2] bpf: calls to bpf_loop() should have an SCC and accumulate backedges
Date: Fri, 27 Mar 2026 13:10:37 -0700 [thread overview]
Message-ID: <b943320a099bc171a10e533935eef8dd06b30e2c.camel@gmail.com> (raw)
In-Reply-To: <9a418287-f8e3-4064-8364-ff85793de74e@google.com>
On Fri, 2026-03-27 at 12:41 -0700, Barret Rhoden wrote:
> hi everyone -
>
> On 3/6/26 3:27 AM, Eduard Zingerman wrote:
> > On Fri, 2026-03-06 at 16:20 +0800, Levi Zim wrote:
>
> ...
>
> > > I have a BPF program [1] that is badly affected by the patch that it no
> > > longer loads on 6.19.5 due to
> > > E2BIG error.
> ...
>
> >
> > I'll take a detailed look tomorrow, but am curious if patch-set [1]
> > helps with your program? As far as I understand it is not a part of
> > 6.19, as it was not marked as "fixes".
> >
> > [1] https://lore.kernel.org/bpf/20251230-loop-stack-misc-pruning-v1-0-585cfd6cec51@gmail.com/
> >
> i'm in a similar situation - my scheduling program, which uses
> bpf_loop(), won't load with the dreaded E2BIG:
>
> processed 1000001 insns (limit 1000000) max_states_per_insn 76
> total_states 59608 peak_states 171016 mark_read 0
>
> i tried the patch at [1], and no luck there either.
>
> are there any tricks with this new SCC stuff to help with verification?
Hi Barret,
Is it possible for you to share the program code?
If not, here are a few generic tips:
- If there is bpf_for or bpf_loop based loop and you hit 1M
instructions limit, this means that internal loop state does not
converge to some previously visited state from verifier point of
view.
- Most likely there is a pattern like this:
v = 0; v = 0;
bpf_for(i, ...) { bpf_for(i, ...) {
... ...
v += 1; - or - v += 1;
} use v for memory access
use v for memory access. }
Or its equivalent in bpf_loop terms.
'v' might also be a pointer incremented inside a loop.
Unfortunately, we don't have a simple way to identify which variable
is a culprit. We do have a way to identify which loop fails to converge:
the 'veristat' tool executed with --top-src-lines=N option will
print out C lines corresponding to instructions that verifier
visited most-often before giving up.
- There are several possible remedies for the pattern above:
- hide exact value of 'v' from verifier by initializing
it using a global, see tools/testing/selftests/bpf/progs/arena_htab.c
variable 'zero'.
- change the logic to rely on 'i' instead of 'v',
for 'i' verifier does not know exact value, but knows its range.
- Another generic advice is to split program into global subprograms.
Global subprograms called from the loop body won't inflate the callers
verification budget.
It is hard to provide more specific advice w/o seeing the program
code.
Thanks,
Eduard
P.S.
I know that loops handling is a major pita, we are working on a
solution but it's a complex problem.
next prev parent reply other threads:[~2026-03-27 20:10 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-30 7:13 [PATCH 0/2] bpf: calls to bpf_loop() should have an SCC and accumulate backedges Eduard Zingerman
2025-12-30 7:13 ` [PATCH 1/2] bpf: bpf_scc_visit instance and backedges accumulation for bpf_loop() Eduard Zingerman
2025-12-30 10:20 ` Breno Leitao
2025-12-30 7:13 ` [PATCH 2/2] selftests/bpf: test cases for bpf_loop SCC and state graph backedges Eduard Zingerman
2025-12-30 17:53 ` [PATCH 0/2] bpf: calls to bpf_loop() should have an SCC and accumulate backedges Eduard Zingerman
2025-12-30 23:50 ` patchwork-bot+netdevbpf
2026-03-06 8:20 ` Levi Zim
2026-03-06 8:27 ` Eduard Zingerman
2026-03-06 9:41 ` Levi Zim
2026-03-06 15:40 ` Levi Zim
2026-03-27 19:41 ` Barret Rhoden
2026-03-27 20:10 ` Eduard Zingerman [this message]
2026-03-30 18:23 ` Barret Rhoden
2026-03-27 20:10 ` Barret Rhoden
2026-03-28 1:29 ` Alexei Starovoitov
2026-03-30 18:23 ` Barret Rhoden
2026-04-03 21:58 ` Emil Tsalapatis
2026-04-04 23:49 ` Barret Rhoden
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=b943320a099bc171a10e533935eef8dd06b30e2c.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=brho@google.com \
--cc=daniel@iogearbox.net \
--cc=i@kxxt.dev \
--cc=joshdon@google.com \
--cc=kernel-team@fb.com \
--cc=martin.lau@linux.dev \
--cc=mattbobrowski@google.com \
--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