All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
To: "Eduard Zingerman" <eddyz87@gmail.com>, <bpf@vger.kernel.org>
Cc: "Andrii Nakryiko" <andrii@kernel.org>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Emil Tsalapatis" <emil@etsalapatis.com>, <kkd@meta.com>,
	<kernel-team@meta.com>
Subject: Re: [PATCH bpf-next v1 1/3] bpf: Show more useful info in stack depth stats
Date: Sun, 02 Aug 2026 23:59:19 +0200	[thread overview]
Message-ID: <DKESN3I6A9IA.270SX0UXGSEJ3@gmail.com> (raw)
In-Reply-To: <ae774dbff74cb78cff1fe27915a9bd8fc4bd990f.camel@gmail.com>

On Sun Aug 2, 2026 at 11:02 PM CEST, Eduard Zingerman wrote:
> On Sun, 2026-08-02 at 01:03 +0200, Kumar Kartikeya Dwivedi wrote:
>> Currently, the output of stack depth statistics is two crude, with a
>> list of captured stack depths ordered by the subprog numbers. The actual
>> subprog numbers are determined by libbpf, hence it is hard to associate
>> the stack depth statistic back to the subprog by name.
>>
>> Change the format to:
>> stack depth <subprog>=<depth> ... max=<depth>
>>
>> In case the subprog name is not specified, use subprog[N] as the string.
>>
>> Suggested-by: Andrii Nakryiko <andrii@kernel.org>
>> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
>> ---
>>  kernel/bpf/verifier.c                         | 16 ++++++++++++----
>>  .../bpf/progs/verifier_basic_stack.c          |  4 ++--
>>  .../bpf/progs/verifier_bpf_fastcall.c         | 19 +++++++++++--------
>>  .../bpf/progs/verifier_private_stack.c        |  9 ++++++---
>>  .../selftests/bpf/progs/verifier_var_off.c    |  4 ++--
>>  5 files changed, 33 insertions(+), 19 deletions(-)
>>
>> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
>> index 8d0635ee48c7..51ac0a9ae339 100644
>> --- a/kernel/bpf/verifier.c
>> +++ b/kernel/bpf/verifier.c
>> @@ -18703,10 +18703,18 @@ static void print_verification_stats(struct bpf_verifier_env *env)
>>  	if (env->log.level & BPF_LOG_STATS) {
>>  		verbose(env, "verification time %lld usec\n",
>>  			div_u64(env->verification_time, 1000));
>> -		verbose(env, "stack depth %d", env->subprog_info[0].stack_depth);
>> -		for (i = 1; i < subprog_cnt; i++)
>> -			verbose(env, "+%d", env->subprog_info[i].stack_depth);
>> -		verbose(env, " max %d\n", env->max_stack_depth);
>> +		verbose(env, "stack depth");
>> +		for (i = 0; i < subprog_cnt; i++) {
>> +			const char *name = env->subprog_info[i].name;
>> +
>> +			if (name && name[0])
>> +				verbose(env, " %s=%d", name,
>> +					env->subprog_info[i].stack_depth);
>> +			else
>> +				verbose(env, " subprog[%d]=%d", i,
>> +					env->subprog_info[i].stack_depth);
>
> That would be not very convenient to parse by veristat,
> but I'd print every subprogram on it's own line.
>

I can do that, but let's agree on the format before I get to it.
How should it look like? Prefix with stack depth every line, and print stack
depth max ... as the very first line? Like so:

stack depth max N
stack depth subprog 0 <name> N
...
stack depth subprog N <name> N

?

>> +		}
>> +		verbose(env, " max=%d\n", env->max_stack_depth);
>
> I think check_max_stack_depth_subprog() needs a similar update,
> at the moment it reports a not very helpful error like this:
>
>   combined stack size of 34 calls is 528. Too large
>
> Printing the offending spine would be helpful.
>

I'll do that in verifier errors patch set. This is just for the verification
stats, that are outside its scope.

> ...


  reply	other threads:[~2026-08-02 21:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-01 23:03 [PATCH bpf-next v1 0/3] Improve stack depth verification stats output Kumar Kartikeya Dwivedi
2026-08-01 23:03 ` [PATCH bpf-next v1 1/3] bpf: Show more useful info in stack depth stats Kumar Kartikeya Dwivedi
2026-08-01 23:11   ` sashiko-bot
2026-08-01 23:15     ` Kumar Kartikeya Dwivedi
2026-08-02  0:35   ` bot+bpf-ci
2026-08-02 21:02   ` Eduard Zingerman
2026-08-02 21:59     ` Kumar Kartikeya Dwivedi [this message]
2026-08-02 22:03       ` Eduard Zingerman
2026-08-01 23:03 ` [PATCH bpf-next v1 2/3] selftests/bpf: Adjust veristat stack depth parsing Kumar Kartikeya Dwivedi
2026-08-02 21:11   ` Eduard Zingerman
2026-08-02 22:00     ` Kumar Kartikeya Dwivedi
2026-08-01 23:03 ` [PATCH bpf-next v1 3/3] selftests/bpf: Test stack depth stats without BTF subprog names Kumar Kartikeya Dwivedi
2026-08-02 21:54   ` Eduard Zingerman
2026-08-02 22:00     ` Kumar Kartikeya Dwivedi

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=DKESN3I6A9IA.270SX0UXGSEJ3@gmail.com \
    --to=memxor@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=kernel-team@meta.com \
    --cc=kkd@meta.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.