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

[email protected] Mon, 03 Aug 2026 07:34:37 +0000
Newsgroups org.kernel.vger.bpf
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The patch changes the verifier stack depth log format but misses updating tools/testing/selftests/bpf/veristat.c, breaking its ability to report stack depth statistics.
--

--- Patch [1]: [PATCH bpf-next v4 1/3] bpf: Show more useful info in stack depth stats ---
commit 5ac25e38dad528d9d2648231f63d507a8cd63820
Author: Kumar Kartikeya Dwivedi <[email protected]>

bpf: Show more useful info in stack depth stats

This commit changes the format of the verifier's stack depth statistics
to display the maximum depth and each subprogram's depth on separate lines
with their names, instead of a single string of depths.

> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -18777,10 +18777,15 @@ 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 max %d\n", env->max_stack_depth);

[Severity: Medium]
Does this change in the verifier log output also require an update to the
veristat tool?

Looking at tools/testing/selftests/bpf/veristat.c in parse_verif_log(), it
currently parses the log like this:

	if (2 == sscanf(cur, "stack depth %511s max %ld", stack, &s->stats[MAX_STACK])) {

Since the patch removes the "stack depth %d...+%d max %d" format and splits
it into multiple lines ("stack depth max %d" and "stack depth subprog ..."),
it looks like veristat's sscanf will no longer match.

Could this cause veristat to silently fail to parse the statistics and report 0
for both the MAX_STACK and STACK metrics?

-- 
Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=1