summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@kernel.org>2026-05-13 18:38:31 -0700
committerAlexei Starovoitov <ast@kernel.org>2026-05-13 18:38:31 -0700
commite651f3ce1364d06d97bb7cc4aa5b23146420a67d (patch)
tree46d5982b8e4ff5d99e4a5e96e200def9aa00dbb6 /kernel
parent74a9bb761a434ea3be1e0c59cd67b37217eb042c (diff)
parentf0015ffbf40c7c6db148163bd6f8c53f14933b53 (diff)
Merge branch 'bpf-maximum-combined-stack-depth'
Paul Chaignon says: ==================== bpf: Maximum combined stack depth This patchset dumps the maximum combined stack depth in verifier logs and parses it in veristat. Changes in v3: - Increment spec_cnt field in veristat for new MAX_STACK id (AI bot). Changes in v2: - Remove unnecessary max_stack_depth assignment (Eduard). - Fix and test incorrect handling of private stacks. - Add veristat metric (Eduard). ==================== Link: https://patch.msgid.link/cover.1778700777.git.paul.chaignon@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/bpf/verifier.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 82b9531f87f6..76a07f09ab64 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -5177,6 +5177,8 @@ process_func:
}
if (subprog[idx].priv_stack_mode == PRIV_STACK_ADAPTIVE) {
+ if (subprog_depth > env->max_stack_depth)
+ env->max_stack_depth = subprog_depth;
if (subprog_depth > MAX_BPF_STACK) {
verbose(env, "stack size of subprog %d is %d. Too large\n",
idx, subprog_depth);
@@ -5184,6 +5186,8 @@ process_func:
}
} else {
depth += subprog_depth;
+ if (depth > env->max_stack_depth)
+ env->max_stack_depth = depth;
if (depth > MAX_BPF_STACK) {
total = 0;
for (tmp = idx; tmp >= 0; tmp = dinfo[tmp].caller)
@@ -18555,7 +18559,7 @@ static void print_verification_stats(struct bpf_verifier_env *env)
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, "\n");
+ verbose(env, " max %d\n", env->max_stack_depth);
verbose(env, "insns processed %d", env->subprog_info[0].insn_processed);
for (i = 1; i < subprog_cnt; i++)
if (bpf_subprog_is_global(env, i))