BPF List
 help / color / mirror / Atom feed
From: Barret Rhoden <brho@google.com>
To: Eduard Zingerman <eddyz87@gmail.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: Mon, 30 Mar 2026 14:23:36 -0400	[thread overview]
Message-ID: <bdb289c5-c52c-4124-961f-db42553a2893@google.com> (raw)
In-Reply-To: <b943320a099bc171a10e533935eef8dd06b30e2c.camel@gmail.com>

On 3/27/26 4:10 PM, Eduard Zingerman wrote:?
> 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.

great tips, thanks!  i opted for the global function one; it's a common 
sledgehammer in my "fight the verifier" toolkit.  =)

the loop function was calling a very large function, so that was 
probably the right tool for the job.  next time i'll take a look at 
veristat.

thanks,

barret



  reply	other threads:[~2026-03-30 18:23 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
2026-03-30 18:23         ` Barret Rhoden [this message]
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=bdb289c5-c52c-4124-961f-db42553a2893@google.com \
    --to=brho@google.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --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