BPF List
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Kumar Kartikeya Dwivedi <memxor@gmail.com>, bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	 Daniel Borkmann <daniel@iogearbox.net>,
	Emil Tsalapatis <emil@etsalapatis.com>,
	kkd@meta.com, kernel-team@meta.com
Subject: Re: [PATCH bpf-next v7 1/6] bpf: Track verifier instruction stats for each subprogram
Date: Tue, 11 Aug 2026 12:35:03 -0700	[thread overview]
Message-ID: <0acc9bbb617d931401fd5a6300513a23cac956d4.camel@gmail.com> (raw)
In-Reply-To: <20260808062601.1070988-2-memxor@gmail.com>

On Sat, 2026-08-08 at 08:25 +0200, Kumar Kartikeya Dwivedi wrote:
> The verifier currently records one instruction count for the main program
> and each global subprogram checked independently. Static subprograms are
> explored within callers, so their verification cost cannot be reported
> separately.
> 
> Track both self and inclusive instruction counts for every subprogram.
> Charge each processed instruction as self work to the current subprogram and
> to a path-local subtotal in its function frame. When a function returns, add
> the callee subtotal to its inclusive count and to its parent subtotal. Fold
> any remaining frames when a path terminates or is pruned.
> 
> Instruction subtotals are accounting state, not semantic verifier state.
> Clear them when a verifier state is copied so work before a path fork is
> charged once, rather than again when a saved branch is explored. If copying
> a saved state fails before all frames are allocated, skip missing frames
> while folding the current path.
> 
> This generic frame accounting also records self and inclusive totals when an
> asynchronous callback starts as a fresh frame-zero state. It does not yet
> charge that independently explored callback path back to the main or global
> exploration root which scheduled it. That will be done in subsequent
> changes.
> 
> This does not change the verification statistics output format. It only
> prepares the counters for per-subprogram reporting.
> 
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> ---

Acked-by: Eduard Zingerman <eddyz87@gmail.com>

>  include/linux/bpf_verifier.h |  5 +++-
>  kernel/bpf/verifier.c        | 55 ++++++++++++++++++++++++++++++------
>  2 files changed, 50 insertions(+), 10 deletions(-)
> 
> diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
> index a2a40caca0a0..f16ee6602179 100644
> --- a/include/linux/bpf_verifier.h
> +++ b/include/linux/bpf_verifier.h
> @@ -385,6 +385,8 @@ struct bpf_func_state {
>  	 *                           | number of simulations is tracked in frame N
>  	 */
>  	u32 callback_depth;
> +	/* Instructions processed in this frame and callees on the current path. */
> +	u32 insns_subtotal;

Another possibility is to have the array of counters in the
bpf_verifier_env itself. But I don't want to push for another respin.

>  	/* The following fields should be last. See copy_func_state() */
>  	/* The state of the stack. Each element of the array describes BPF_REG_SIZE

...

  reply	other threads:[~2026-08-11 19:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-08  6:25 [PATCH bpf-next v7 0/6] Improve stack depth verification stats output Kumar Kartikeya Dwivedi
2026-08-08  6:25 ` [PATCH bpf-next v7 1/6] bpf: Track verifier instruction stats for each subprogram Kumar Kartikeya Dwivedi
2026-08-11 19:35   ` Eduard Zingerman [this message]
2026-08-08  6:25 ` [PATCH bpf-next v7 2/6] bpf: Attribute async callback instructions to verification roots Kumar Kartikeya Dwivedi
2026-08-08  7:40   ` bot+bpf-ci
2026-08-11 20:01   ` Eduard Zingerman
2026-08-08  6:25 ` [PATCH bpf-next v7 3/6] bpf: Show more useful info in stack depth stats Kumar Kartikeya Dwivedi
2026-08-08  6:45   ` sashiko-bot
2026-08-11 20:04   ` Eduard Zingerman
2026-08-08  6:25 ` [PATCH bpf-next v7 4/6] selftests/bpf: Adjust veristat stack depth parsing Kumar Kartikeya Dwivedi
2026-08-11 20:50   ` Eduard Zingerman
2026-08-08  6:25 ` [PATCH bpf-next v7 5/6] selftests/bpf: Test stack depth stats without BTF subprog names Kumar Kartikeya Dwivedi
2026-08-11 21:18   ` Eduard Zingerman
2026-08-08  6:25 ` [PATCH bpf-next v7 6/6] selftests/bpf: Test subprogram instruction statistics Kumar Kartikeya Dwivedi
2026-08-08  6:36   ` sashiko-bot
2026-08-11 21:37   ` Eduard Zingerman

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=0acc9bbb617d931401fd5a6300513a23cac956d4.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=emil@etsalapatis.com \
    --cc=kernel-team@meta.com \
    --cc=kkd@meta.com \
    --cc=memxor@gmail.com \
    /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