Re: [PATCH bpf-next v7 3/6] bpf: Show more useful info in stack depth stats

Eduard Zingerman <[email protected]>
Newsgroups org.kernel.vger.bpf
Message-ID <[email protected]>
On Sat, 2026-08-08 at 08:25 +0200, Kumar Kartikeya Dwivedi wrote:
> Stack depth statistics list captured depths in subprogram-number order,
> while per-verification instruction counts are reported separately. Since
> libbpf determines subprogram numbers, it is hard to associate either
> statistic with its subprogram name or see where verifier work is spent.
> 
> Now that self and inclusive instruction counts are available for every
> subprogram, keep the combined maximum stack depth on its own line and print
> one uniform record for each subprogram. Represent the main program as
> subprog 0, then classify each record as main, global, or static before
> reporting insns_self, insns_total, and stack depth.
> 
> The aggregate processed count is the sum of all self counts, while each
> total shows verifier work rooted at that subprogram.
> 
> When no subprogram name is available, print <unknown>. Keep the existing
> aggregate "processed ... insns" record unchanged for compatibility.
> 
> Suggested-by: Andrii Nakryiko <[email protected]>
> Signed-off-by: Kumar Kartikeya Dwivedi <[email protected]>
> ---

Acked-by: Eduard Zingerman <[email protected]>

...

> diff --git a/tools/testing/selftests/bpf/progs/verifier_basic_stack.c b/tools/testing/selftests/bpf/progs/verifier_basic_stack.c
> index d3df7a9f1d8c..3a9ee8b55fbd 100644
> --- a/tools/testing/selftests/bpf/progs/verifier_basic_stack.c
> +++ b/tools/testing/selftests/bpf/progs/verifier_basic_stack.c
> @@ -27,7 +27,9 @@ __naked void stack_out_of_bounds(void)
>  
>  SEC("socket")
>  __description("uninitialized stack1")
> -__success __log_level(4) __msg("stack depth 8")
> +__success __log_level(4)
> +__msg("subprog 0 (uninitialized_stack1) main insns_self {{[0-9]+}} "
> +      "insns_total {{[0-9]+}} stack 8")

Nit: let's avoid splitting these literals, also the following would do:

     __msg("subprog 0 (uninitialized_stack1) main {{.*}} stack 8").

...
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.