Improve stack depth verification stats output
Subsystems (4)
Kumar Kartikeya Dwivedi
maintainerv7 cover Improve stack depth verification stats output
Some improvements for more clarity in the stack depth verification statistics output. See commit logs for details.
For example, ./test_progs -t subprogs/subprogs_alone loads prog4, which has a main program, two static subprograms, and two independently verified global subprograms. A sample run produces:
verification time 1765 usec
stack depth max 48
subprog 0 (prog4) main insns_self 29 insns_total 51 stack 8
subprog 1 (get_task_tgid) global insns_self 9 insns_total 9 stack 8
subprog 2 (sub4) static insns_self 15 insns_total 22 stack 8
subprog 3 (sub3) static insns_self 7 insns_total 7 stack 0
subprog 4 (sub1) global insns_self 10 insns_total 10 stack 8
processed 70 insns (limit 1000000) max_states_per_insn 0 total_states 7 peak_states 7 mark_read 0
The insns_self counts account for every processed instruction exactly once:
29 + 9 + 15 + 7 + 10 = 70
The main program and global subprograms are independent exploration roots, so their insns_total counts also account for the full processed budget:
51 + 9 + 10 = 70
Static subprogram totals provide a nested, top-down breakdown inside their root. In this example:
sub4: 22 = 15 self + 7 in sub3
prog4: 51 = 29 self + 22 in sub4
The global subprogram bodies are accounted in their own root totals rather than being included in prog4 or the static callees which call them.
Asynchronous callbacks start from fresh frame-zero verifier states, but the work remains part of the do_check_common() invocation for the main or global verification root under which it was scheduled. Running:
./test_progs -t verifier_subprog_insn_stats/stats_async_nested -v
produces the following stats:
stack depth max 0
subprog 0 (stats_async_nested) main insns_self 9 insns_total 25 stack 0 subprog 1 (stats_async_nested_schedule) static insns_self 7 insns_total 7 stack 0 subprog 2 (stats_async_outer) static insns_self 7 insns_total 7 stack 0 subprog 3 (stats_async_nested_leaf) static insns_self 2 insns_total 2 stack 0 processed 25 insns
Here, 9 + 2 + 7 + 7 = 25. The main root total is the complete verifier budget for its do_check_common() invocation, including both directly and transitively scheduled asynchronous callbacks. Static subprogram and callback totals remain local to their synchronous paths.
Changelog:
----------
v6 -> v7
v6: https://lore.kernel.org/bpf/[email protected]
* Rename insns_own to insns_self throughout. (Andrii)
* Drop the async accounting call stack and attribute callback work to the scheduling main or global verification root using its processed-insn delta. (Eduard, Andrii)
* Skip missing frames when folding instruction totals after a partial verifier state copy. (BPF CI Bot)
* Use explicit callback argument operands in deterministic instruction-count tests and update tests and examples for root attribution. (BPF CI Bot)
v5 -> v6
v5: https://lore.kernel.org/bpf/[email protected]
* Track self and inclusive instruction counts for main, global, and static subprograms. (Andrii, Eduard)
* Keep instruction subtotals path-local across verifier state copies.
* Propagate async callback budget through nested scheduling chains. (Andrii)
* Split per-subprogram instruction accounting into a preparatory patch.
* Add deterministic selftests with exact self, total, and processed counts.
v4 -> v5
v4: https://lore.kernel.org/bpf/[email protected]
* Change the format to combine instruction counts and stack depths into per-program records. (Andrii)
* Adjust veristat for the new format while retaining support for the legacy format.
* Explain why the legacy stack parsing buffer is zero-initialized. (BPF CI Bot)
v3 -> v4
v3: https://lore.kernel.org/bpf/[email protected]
* Read names from subprog_info directly to avoid an out-of-bounds access when func_info validation fails. (BPF CI Bot)
v2 -> v3
v2: https://lore.kernel.org/bpf/[email protected]
* Reuse subprog_name() to fetch subprogram names. (BPF CI Bot)
v1 -> v2
v1: https://lore.kernel.org/bpf/[email protected]
* Use multi-line format. (Eduard)
* Adjust veristat to work with old and new format.
* Adjust selftest log_level without new option. (Eduard)
Kumar Kartikeya Dwivedi (6):
bpf: Track verifier instruction stats for each subprogram
bpf: Attribute async callback instructions to verification roots
bpf: Show more useful info in stack depth stats selftests/bpf: Adjust veristat stack depth parsing selftests/bpf: Test stack depth stats without BTF subprog names selftests/bpf: Test subprogram instruction statistics
include/linux/bpf_verifier.h | 5 +- kernel/bpf/verifier.c | 75 ++++-- .../selftests/bpf/prog_tests/verifier.c | 2 + .../bpf/progs/verifier_basic_stack.c | 8 +- .../bpf/progs/verifier_bpf_fastcall.c | 38 ++- .../bpf/progs/verifier_global_subprogs.c | 6 +- .../bpf/progs/verifier_private_stack.c | 22 +- .../bpf/progs/verifier_subprog_insn_stats.c | 228 ++++++++++++++++++ .../selftests/bpf/progs/verifier_var_off.c | 8 +- tools/testing/selftests/bpf/test_verifier.c | 2 +- tools/testing/selftests/bpf/verifier/calls.c | 12 +- tools/testing/selftests/bpf/veristat.c | 16 +- 12 files changed, 385 insertions(+), 37 deletions(-) create mode 100644 tools/testing/selftests/bpf/progs/verifier_subprog_insn_stats.c
base-commit: 51476f6a06ef55cecf785ae1622c638fa8cfb846
Signature · 1 line
2.53.0
Kumar Kartikeya Dwivedi
maintainerPATCH v7 1/6 bpf: Track verifier instruction stats for each subprogram
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.
--- include/linux/bpf_verifier.h | 5 +++- kernel/bpf/verifier.c | 55 ++++++++++++++++++++++++++++++------ 2 files changed, 50 insertions(+), 10 deletions(-)
include/linux/bpf_verifier.h +4 -1
@@ -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;/* The following fields should be last. See copy_func_state() */ /* The state of the stack. Each element of the array describes BPF_REG_SIZE
@@ -803,7 +805,8 @@ struct bpf_subprog_info {u32 exit_idx;/* Index of one of the BPF_EXIT instructions in this subprogram */ u16 stack_depth;/* max. stack depth used by this function */ u16 stack_extra; -u32 insn_processed; +u32 insns_total; +u32 insns_self;/* offsets in range [stack_depth .. fastcall_stack_off) * are used for bpf_fastcall spills and fills. */
kernel/bpf/verifier.c +46 -9
127 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH bpf-next v7 1/6] bpf: Track verifier instruction stats for each subprogram
Quoted 23 lines · Kumar Kartikeya Dwivedi
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.
Quoted 5 lines
This does not change the verification statistics output format. It only prepares the counters for per-subprogram reporting.
Signed-off-by Kumar Kartikeya Dwivedi <[email protected]>---
Quoted 9 lines
include/linux/bpf_verifier.h | 5 +++- kernel/bpf/verifier.c | 55 ++++++++++++++++++++++++++++++------ 2 files changed, 50 insertions(+), 10 deletions(-)include/linux/bpf_verifier.h +0
-0
include/linux/bpf_verifier.h struct bpf_func_state { · line 389
Quoted 5 lines
include/linux/bpf_verifier.h +2
-0@@ -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.
Quoted 2 lines
include/linux/bpf_verifier.h +0
-0/* The following fields should be last. See copy_func_state() */ /* The state of the stack. Each element of the array describes BPF_REG_SIZE
...
Kumar Kartikeya Dwivedi
maintainerPATCH v7 2/6 bpf: Attribute async callback instructions to verification roots
In reply to Kumar Kartikeya DwivediAsynchronous callbacks are explored as fresh frame-zero verifier states, so normal callee-to-caller accounting cannot propagate their instruction budget to the main or global subprogram whose verification scheduled them.
The callback exploration still happens within the same do_check_common() invocation as that independent verification root. Record env->insn_processed before checking each main or global subprogram, then override the root's inclusive count with the delta afterwards. This includes all directly and transitively scheduled asynchronous callbacks in the root's total without maintaining a separate accounting call stack.
Static subprogram and callback totals remain local to their synchronous call paths. Their self counts continue to account for each processed instruction exactly once.
--- kernel/bpf/verifier.c | 5 +++++ 1 file changed, 5 insertions(+)
kernel/bpf/verifier.c +5 -0
@@ -18762,6 +18762,7 @@ static int do_check_subprogs(struct bpf_verifier_env *env)struct bpf_prog_aux *aux = env->prog->aux;struct bpf_func_info_aux *sub_aux;int i, ret, new_cnt; +u32 insn_processed;if (!aux->func_info)return 0 ;
@@ -18780,9 +18781,11 @@ static int do_check_subprogs(struct bpf_verifier_env *env)if (!sub_aux->called || sub_aux->verified)continue ; + insn_processed = env->insn_processed; env->insn_idx = env->subprog_info[i].start;WARN_ON_ONCE (env->insn_idx ==0 ); ret =do_check_common (env, i); + env->subprog_info[i].insns_total = env->insn_processed - insn_processed;if (ret) {return ret; }else if (env->log.level &BPF_LOG_LEVEL ) {
@@ -18809,10 +18812,12 @@ static int do_check_subprogs(struct bpf_verifier_env *env)static int do_check_main (struct bpf_verifier_env *env) { +u32 insn_processed = env->insn_processed;int ret; env->insn_idx =0 ; ret =do_check_common (env,0 ); + env->subprog_info[0 ].insns_total = env->insn_processed - insn_processed;if (!ret) env->prog->aux->stack_depth = env->subprog_info[0 ].stack_depth;return ret;
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH bpf-next v7 2/6] bpf: Attribute async callback instructions to verification roots
This isn't a bug, but looking at the parent commit 01220a5c1336 ("bpf: Track verifier instruction stats for each subprogram"), it deleted the insn_processed snapshot and delta assignment from both…
Quoted 13 lines
kernel/bpf/verifier.c +1
-0@@ -18762,6 +18762,7 @@ static int do_check_subprogs(struct bpf_verifier_env *env)struct bpf_prog_aux *aux = env->prog->aux;struct bpf_func_info_aux *sub_aux;int i, ret, new_cnt; +u32 insn_processed;if (!aux->func_info)return 0 ;
kernel/bpf/verifier.c static int do_check_subprogs(struct bpf_verifier_env *env) · line 18788
Quoted 8 lines
kernel/bpf/verifier.c +2
-0@@ -18780,9 +18781,11 @@ static int do_check_subprogs(struct bpf_verifier_env *env)if (!sub_aux->called || sub_aux->verified)continue ; + insn_processed = env->insn_processed; env->insn_idx = env->subprog_info[i].start;WARN_ON_ONCE (env->insn_idx ==0 ); ret =do_check_common (env, i); + env->subprog_info[i].insns_total = env->insn_processed - insn_processed;
This isn't a bug, but looking at the parent commit 01220a5c1336 ("bpf: Track verifier instruction stats for each subprogram"), it deleted the insn_processed snapshot and delta assignment from both do_check_subprogs() and do_check_main(), and now this patch adds them back with only the field name changed (insn_processed to insns_total).
Could the parent patch have kept these lines (with the rename) rather than deleting and restoring them across two commits?
Quoted 3 lines
kernel/bpf/verifier.c +0
-0if (ret) {return ret; }else if (env->log.level &BPF_LOG_LEVEL ) {
[ ... ]
kernel/bpf/verifier.c static int do_check_subprogs(struct bpf_verifier_env *env) · line 18823
Quoted 13 lines
kernel/bpf/verifier.c +2
-0@@ -18809,10 +18812,12 @@ static int do_check_subprogs(struct bpf_verifier_env *env)static int do_check_main (struct bpf_verifier_env *env) { +u32 insn_processed = env->insn_processed;int ret; env->insn_idx =0 ; ret =do_check_common (env,0 ); + env->subprog_info[0 ].insns_total = env->insn_processed - insn_processed;if (!ret) env->prog->aux->stack_depth = env->subprog_info[0 ].stack_depth;return ret;
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/31244455347
Eduard Zingerman
maintainerRe: [PATCH bpf-next v7 2/6] bpf: Attribute async callback instructions to verification roots
In reply to Kumar Kartikeya DwivediOn Sat, 2026-08-08 at 08:25 +0200, Kumar Kartikeya Dwivedi wrote:
...
Quoted 25 lines
kernel/bpf/verifier.c +3
-0@@ -18762,6 +18762,7 @@ static int do_check_subprogs(struct bpf_verifier_env *env)struct bpf_prog_aux *aux = env->prog->aux;struct bpf_func_info_aux *sub_aux;int i, ret, new_cnt; +u32 insn_processed;if (!aux->func_info)return 0 ;@@ -18780,9 +18781,11 @@ static int do_check_subprogs(struct bpf_verifier_env *env)if (!sub_aux->called || sub_aux->verified)continue ; + insn_processed = env->insn_processed; env->insn_idx = env->subprog_info[i].start;WARN_ON_ONCE (env->insn_idx ==0 ); ret =do_check_common (env, i); + env->subprog_info[i].insns_total = env->insn_processed - insn_processed;if (ret) {return ret; }else if (env->log.level &BPF_LOG_LEVEL ) {
kernel/bpf/verifier.c static int do_check_subprogs(struct bpf_verifier_env *env) · line 18820
Quoted 9 lines
kernel/bpf/verifier.c +2
-0@@ -18809,10 +18812,12 @@ static int do_check_subprogs(struct bpf_verifier_env *env)static int do_check_main (struct bpf_verifier_env *env) { +u32 insn_processed = env->insn_processed;int ret; env->insn_idx =0 ; ret =do_check_common (env,0 ); + env->subprog_info[0 ].insns_total = env->insn_processed - insn_processed;
Let's move this accounting inside do_check_common(). Also, having a comment like:
/*
* The override is needed to account for async subprograms,
* which are verified with their own set of stack frames and
* thus are not accounted as callees by account_current_path().
* Accumulate their total counts as total counts of the main
* or global subprog hosting the async call.
*/
would be helpful.
Quoted 3 lines
kernel/bpf/verifier.c +0
-0if (!ret) env->prog->aux->stack_depth = env->subprog_info[0 ].stack_depth;return ret;
Kumar Kartikeya Dwivedi
maintainerPATCH v7 3/6 bpf: Show more useful info in stack depth stats
In reply to Kumar Kartikeya DwivediStack 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.
--- kernel/bpf/verifier.c | 23 ++++++----- .../bpf/progs/verifier_basic_stack.c | 8 +++- .../bpf/progs/verifier_bpf_fastcall.c | 38 +++++++++++++++---- .../bpf/progs/verifier_global_subprogs.c | 6 ++- .../bpf/progs/verifier_private_stack.c | 22 +++++++++-- .../selftests/bpf/progs/verifier_var_off.c | 8 +++- 6 files changed, 80 insertions(+), 25 deletions(-)
kernel/bpf/verifier.c +14 -9
@@ -18832,15 +18832,20 @@ 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,"insns processed %d" , env->subprog_info[0 ].insns_total); -for (i =1 ; i < subprog_cnt; i++) -if (bpf_subprog_is_global (env, i)) -verbose (env,"+%d" , env->subprog_info[i].insns_total); -verbose (env,"\n" ); +verbose (env,"stack depth max %d\n" , env->max_stack_depth); +for (i =0 ; i < subprog_cnt; i++) { +const char *name = env->subprog_info[i].name; +const char *kind; + +if (!name || !name[0 ]) + name ="<unknown>" ; + kind = i ==0 ?"main" : +bpf_subprog_is_global (env, i) ?"global" :"static" ; +verbose (env,"subprog %d (%s) %s insns_self %d insns_total %d stack %d\n" , + i, name, kind, env->subprog_info[i].insns_self, + env->subprog_info[i].insns_total, + env->subprog_info[i].stack_depth); + } } verbose(env, "processed %d insns (limit %d) max_states_per_insn %d " "total_states %d peak_states %d mark_read %d\n",
tools/testing/selftests/bpf/progs/verifier_basic_stack.c +6 -2
@@ -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") __failure_unpriv __msg_unpriv("invalid read from stack") __naked void uninitialized_stack1(void) {
@@ -45,7 +47,9 @@ __naked void uninitialized_stack1(void) SEC("socket") __description("uninitialized stack2") -__success __log_level(4) __msg("stack depth 8") +__success __log_level(4) +__msg("subprog 0 (uninitialized_stack2) main insns_self {{[0-9]+}} " + "insns_total {{[0-9]+}} stack 8") __failure_unpriv __msg_unpriv("invalid read from stack") __naked void uninitialized_stack2(void) {
tools/testing/selftests/bpf/progs/verifier_bpf_fastcall.c +30 -8
@@ -10,7 +10,8 @@ SEC("raw_tp") __arch_x86_64 -__log_level(4) __msg("stack depth 8") +__log_level(4) +__msg("subprog 0 (simple) main insns_self {{[0-9]+}} insns_total {{[0-9]+}} stack 8") __xlated("4: r5 = 5") __xlated("5: r0 = ")__xlated ("6: r0 = &(void __percpu *)(r0)" )
@@ -96,7 +97,9 @@ __naked void canary_zero_spills(void) SEC("raw_tp") __arch_x86_64 -__log_level(4) __msg("stack depth 16") +__log_level(4) +__msg("subprog 0 (wrong_reg_in_pattern1) main insns_self {{[0-9]+}} " + "insns_total {{[0-9]+}} stack 16") __xlated("1: *(u64 *)(r10 -16) = r1") __xlated("...")__xlated ("3: r0 = &(void __percpu *)(r0)" )
@@ -598,7 +601,9 @@ __naked static void subprogs_use_independent_offsets_aux(void) SEC("raw_tp") __arch_x86_64 -__log_level(4) __msg("stack depth 8") +__log_level(4) +__msg("subprog 0 (helper_call_does_not_prevent_bpf_fastcall) main insns_self {{[0-9]+}} " + "insns_total {{[0-9]+}} stack 8") __xlated("2: r0 = &(void __percpu *)(r0)") __success__naked void helper_call_does_not_prevent_bpf_fastcall (void )
@@ -620,7 +625,9 @@ __naked void helper_call_does_not_prevent_bpf_fastcall(void) SEC("raw_tp") __arch_x86_64 -__log_level(4) __msg("stack depth 24") +__log_level(4) +__msg("subprog 0 (may_goto_interaction_x86_64) main insns_self {{[0-9]+}} " + "insns_total {{[0-9]+}} stack 24")/* may_goto counter at -24 */ __xlated ("0: *(u64 *)(r10 -24) =" )/* may_goto timestamp at -16 */
@@ -661,7 +668,9 @@ __naked void may_goto_interaction_x86_64(void) SEC("raw_tp") __arch_arm64 __arch_riscv64 -__log_level(4) __msg("stack depth 24") +__log_level(4) +__msg("subprog 0 (may_goto_interaction) main insns_self {{[0-9]+}} " + "insns_total {{[0-9]+}} stack 24")/* may_goto counter at -24 */ __xlated ("0: *(u64 *)(r10 -24) =" )/* may_goto timestamp at -16 */
@@ -708,7 +717,11 @@ __naked static void dummy_loop_callback(void) SEC("raw_tp") __arch_x86_64 -__log_level(4) __msg("stack depth 32+0") +__log_level(4) +__msg("subprog 0 (bpf_loop_interaction1) main insns_self {{[0-9]+}} " + "insns_total {{[0-9]+}} stack 32") +__msg("subprog 1 (dummy_loop_callback) static insns_self {{[0-9]+}} " + "insns_total {{[0-9]+}} stack 0") __xlated("2: r1 = 1") __xlated("3: r0 =")__xlated ("4: r0 = &(void __percpu *)(r0)" )
@@ -756,7 +769,11 @@ __naked int bpf_loop_interaction1(void) SEC("raw_tp") __arch_x86_64 -__log_level(4) __msg("stack depth 40+0") +__log_level(4) +__msg("subprog 0 (bpf_loop_interaction2) main insns_self {{[0-9]+}} " + "insns_total {{[0-9]+}} stack 40") +__msg("subprog 1 (dummy_loop_callback) static insns_self {{[0-9]+}} " + "insns_total {{[0-9]+}} stack 0")/* call bpf_get_smp_processor_id */ __xlated("2: r1 = 42")__xlated ("3: r0 =" )
@@ -800,7 +817,12 @@ __naked int bpf_loop_interaction2(void) SEC("raw_tp") __arch_x86_64 -__log_level(4) __msg("stack depth 512+0 max 512") +__log_level(4) +__msg("stack depth max 512") +__msg("subprog 0 (cumulative_stack_depth) main insns_self {{[0-9]+}} " + "insns_total {{[0-9]+}} stack 512") +__msg("subprog 1 (cumulative_stack_depth_subprog) static insns_self {{[0-9]+}} " + "insns_total {{[0-9]+}} stack 0")/* just to print xlated version when debugging */ __xlated ("r0 = &(void __percpu *)(r0)" ) __success
tools/testing/selftests/bpf/progs/verifier_global_subprogs.c +5 -1
@@ -52,7 +52,11 @@ __msg("('global_calls_good_only') is global and assumed valid.")/* eventually global_good() is transitively validated as well */ __msg("Validating global_good() func") __msg("('global_good') is safe for any args that match its prototype") -__msg("insns processed {{[0-9]+\\+[0-9]+\\+[0-9]+$}}") +__msg("subprog 0 (chained_global_func_calls_success) main insns_self 7 insns_total 7 stack") +__msg ("subprog {{[0-9]+}} (global_calls_good_only) global " + "insns_self 2 insns_total 2 stack") +__msg("subprog {{[0-9]+}} (global_good) global insns_self 5 insns_total 5 stack") +__msg("processed 14 insns")int chained_global_func_calls_success (void ) {int sum =0 ;
tools/testing/selftests/bpf/progs/verifier_private_stack.c +19 -3
@@ -86,7 +86,11 @@ __naked static void cumulative_stack_depth_subprog(void) SEC("kprobe") __description("Private stack, subtree > MAX_BPF_STACK") __success -__log_level(4) __msg("stack depth 512+32 max 512") +__log_level(4) __msg("stack depth max 512") +__msg ("subprog 0 (private_stack_nested_1) main insns_self {{[0-9]+}} " + "insns_total {{[0-9]+}} stack 512") +__msg ("subprog 1 (cumulative_stack_depth_subprog) static insns_self {{[0-9]+}} " + "insns_total {{[0-9]+}} stack 32") __arch_x86_64 /* private stack fp for the main prog */ __jited(" movabsq $0x{{.*}}, %r9")
@@ -331,7 +335,15 @@ SEC("fentry/bpf_fentry_test9") __description("Private stack, async callback, potential nesting") __success __retval(0) __load_if_JITed() -__log_level(4) __msg("stack depth 8+0+256+0 max 272") +__log_level(4) __msg("stack depth max 272") +__msg("subprog 0 (private_stack_async_callback_2) main insns_self {{[0-9]+}} " + "insns_total {{[0-9]+}} stack 8") +__msg("subprog 1 (timer_cb1) static insns_self {{[0-9]+}} " + "insns_total {{[0-9]+}} stack 0") +__msg("subprog 2 (subprog1) static insns_self {{[0-9]+}} " + "insns_total {{[0-9]+}} stack 256") +__msg("subprog 3 (subprog2) static insns_self {{[0-9]+}} " + "insns_total {{[0-9]+}} stack 0") __arch_x86_64 __jited(" subq $0x100, %rsp")__arch_arm64
@@ -355,7 +367,11 @@ int private_stack_async_callback_2(void) SEC("fentry/bpf_fentry_test9") __description("private stack, max stack depth is private stack") __success -__log_level(4) __msg("stack depth 8+256+0 max 256") +__log_level(4) __msg("stack depth max 256") +__msg ("subprog 0 (private_stack_max_depth) main insns_self {{[0-9]+}} " + "insns_total {{[0-9]+}} stack 8") +__msg("subprog 1 (subprog1) static insns_self {{[0-9]+}} insns_total {{[0-9]+}} stack 256") +__msg("subprog 2 (subprog2) static insns_self {{[0-9]+}} insns_total {{[0-9]+}} stack 0")int private_stack_max_depth (void ) {int x =0 ;
tools/testing/selftests/bpf/progs/verifier_var_off.c +6 -2
@@ -198,7 +198,9 @@ __success/* Check that the maximum stack depth is correctly maintained according to the * maximum possible variable offset. */ -__log_level(4) __msg("stack depth 16") +__log_level(4) +__msg ("subprog 0 (stack_write_priv_vs_unpriv) main insns_self {{[0-9]+}} " + "insns_total {{[0-9]+}} stack 16") __failure_unpriv/* Variable stack access is rejected for unprivileged. */
@@ -238,7 +240,9 @@ __success/* Check that the maximum stack depth is correctly maintained according to the * maximum possible variable offset. */ -__log_level(4) __msg("stack depth 16") +__log_level(4) +__msg("subprog 0 (stack_write_followed_by_read) main insns_self {{[0-9]+}} " + "insns_total {{[0-9]+}} stack 16") __failure_unpriv __msg_unpriv("R2 variable stack access prohibited for !root")__retval (0 )
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH bpf-next v7 3/6] bpf: Show more useful info in stack depth stats
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The array func_info_aux is not updated when a subprogram is removed during dead code elimination, leading to desynchronized indices and mismatched linkage/properties output. This problem wasn't introduced by this patch, but it exposes a severe preexisting bug where subprogram metadata becomes misaligned. --
--- Patch [3]: [PATCH bpf-next v7 3/6] bpf: Show more useful info in stack depth stats --- commit f4f742e1d07651cd7baebbdb7ebb72f0898a6722
Author: Kumar Kartikeya Dwivedi <[email protected]>
bpf: Show more useful info in stack depth stats
This patch updates how stack depth statistics are reported in the verifier. It keeps the combined maximum stack depth on its own line and introduces a uniform record for each subprogram, classifying them as main, global, or static. It also prints self and inclusive instruction counts along with stack depth.
Quoted 16 lines
kernel/bpf/verifier.c +0
-8@@ -18832,15 +18832,20 @@ 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,"insns processed %d" , env->subprog_info[0 ].insns_total); -for (i =1 ; i < subprog_cnt; i++) -if (bpf_subprog_is_global (env, i)) -verbose (env,"+%d" , env->subprog_info[i].insns_total);
kernel/bpf/verifier.c static void print_verification_stats(struct bpf_verifier_env *env) · line 18843
Quoted 10 lines
kernel/bpf/verifier.c +9
-1-verbose (env,"\n" ); +verbose (env,"stack depth max %d\n" , env->max_stack_depth); +for (i =0 ; i < subprog_cnt; i++) { +const char *name = env->subprog_info[i].name; +const char *kind; + +if (!name || !name[0 ]) + name ="<unknown>" ; + kind = i ==0 ?"main" : +bpf_subprog_is_global (env, i) ?"global" :"static" ;
[Severity: High]
This isn't a bug introduced by this patch, but this use of bpf_subprog_is_global() exposes a pre-existing issue where subprogram metadata becomes misaligned.
If a subprogram is removed during dead code elimination, adjust_subprog_starts_after_remove() shifts func_info but fails to shift func_info_aux:
kernel/bpf/fixups.c:adjust_subprog_starts_after_remove() {
if (aux->func_info) {
move = aux->func_info_cnt - j;
memmove(aux->func_info + i,
aux->func_info + j,
sizeof(*aux->func_info) * move);
aux->func_info_cnt -= j - i;
/* func_info->insn_off is set after all code rewrites,
* in adjust_btf_func() - no need to adjust
*/
}
}This causes func_info_aux to become permanently desynchronized with the actual subprogram sequence.
Because bpf_subprog_is_global() relies on aux[subprog].linkage from this un-shifted array:
kernel/bpf/verifier.c:bpf_subprog_is_global() {
struct bpf_func_info_aux *aux = env->prog->aux->func_info_aux;
return aux && aux[subprog].linkage == BTF_FUNC_GLOBAL;
}Could this lead to mismatched linkage and properties output here?
More importantly, could this also allow bpf_check_attach_target() to misread the unreliable flag and permit a freplace extension to attach to heavily optimized static functions?
kernel/bpf/verifier.c:bpf_check_attach_target() {
...
conservative = aux->func_info_aux[subprog].unreliable;
...
}Quoted 6 lines
kernel/bpf/verifier.c +5
-0+verbose (env,"subprog %d (%s) %s insns_self %d insns_total %d stack %d\n" , + i, name, kind, env->subprog_info[i].insns_self, + env->subprog_info[i].insns_total, + env->subprog_info[i].stack_depth); + } }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: [PATCH bpf-next v7 3/6] bpf: Show more useful info in stack depth stats
In reply to Kumar Kartikeya DwivediQuoted 14 lines · Kumar Kartikeya Dwivedi
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.
Quoted 6 lines
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]>---
...
tools/testing/selftests/bpf/progs/verifier_basic_stack.c __naked void stack_out_of_bounds(void) · line 32
Quoted 12 lines
tools/testing/selftests/bpf/progs/verifier_basic_stack.c +3
-1@@ -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")....
Kumar Kartikeya Dwivedi
maintainerPATCH v7 4/6 selftests/bpf: Adjust veristat stack depth parsing
In reply to Kumar Kartikeya DwivediThe verifier now reports instruction and stack depth statistics using uniform "subprog <id> (<name>) <kind>" records. Subprogram 0 is classified as main, while other records are global or static. Each record carries insns_self, insns_total, and stack depth.
Teach veristat to parse the new records while retaining support for the legacy one-line stack depth format used by older kernels. Skip both instruction counts and match only through the stack value so fields can still be appended without breaking parsing.
Increase the bounded backward scan so it can include all 256 per-subprogram records.
Zero-initialize the legacy stack buffer because logs using the new format do not populate it before the trailing tokenizer loop. This makes the loop see an empty string instead of reading uninitialized data.
--- tools/testing/selftests/bpf/veristat.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
tools/testing/selftests/bpf/veristat.c +12 -4
@@ -993,13 +993,15 @@ static void free_verif_stats(struct verif_stats *stats, size_t stat_cnt)static char verif_log_buf[64 *1024 ]; -#define MAX_PARSED_LOG_LINES 100 +/* Keep room for all 256 subprogram records and trailing statistics. */ +#define MAX_PARSED_LOG_LINES 300static int parse_verif_log (char *const buf,size_t buf_sz,struct verif_stats *s) {const char *cur; -int pos, lines, sub_stack, cnt =0 ; -char *state =NULL , *token, stack[512 ]; +long sub_stack; +int pos, lines, cnt =0 ; +char *state =NULL , *token, stack[512 ] = {}; buf[buf_sz -1 ] ='\0' ;
@@ -1025,11 +1027,17 @@ static int parse_verif_log(char * const buf, size_t buf_sz, struct verif_stats * &s->stats[MARK_READ_MAX_LEN]))continue ; +if (sscanf (cur,"stack depth max %ld" , &s->stats[MAX_STACK ]) ==1 ) +continue ; +if (sscanf (cur,"subprog %*d %*s %*s insns_self %*d insns_total %*d stack %ld" , &sub_stack) ==1 ) { + s->stats[STACK ] += sub_stack; +continue ; + }if (2 ==sscanf (cur,"stack depth %511s max %ld" , stack, &s->stats[MAX_STACK ]))continue ; }while ((token =strtok_r (cnt++ ?NULL : stack,"+" , &state))) { -if (sscanf (token,"%d" , &sub_stack) ==0 ) +if (sscanf (token,"%ld" , &sub_stack) ==0 )break ; s->stats[STACK ] += sub_stack; }
Signature · 1 line
2.53.0
Re: [PATCH bpf-next v7 4/6] selftests/bpf: Adjust veristat stack depth parsing
Quoted 13 lines · Kumar Kartikeya Dwivedi
The verifier now reports instruction and stack depth statistics using uniform "subprog <id> (<name>) <kind>" records. Subprogram 0 is classified as main, while other records are global or static. Each record carries
insns_self,insns_total, and stack depth.Teach veristat to parse the new records while retaining support for the legacy one-line stack depth format used by older kernels. Skip both instruction counts and match only through the stack value so fields can still be appended without breaking parsing.
Increase the bounded backward scan so it can include all 256 per-subprogram records.
Quoted 6 lines
Zero-initialize the legacy stack buffer because logs using the new format do not populate it before the trailing tokenizer loop. This makes the loop see an empty string instead of reading uninitialized data.
Signed-off-by Kumar Kartikeya Dwivedi <[email protected]>---
tools/testing/selftests/bpf/veristat.c static int parse_verif_log(char * const buf, size_t buf_sz, struct verif_stats * · line 1035
Quoted 10 lines
tools/testing/selftests/bpf/veristat.c +6
-0@@ -1025,11 +1027,17 @@ static int parse_verif_log(char * const buf, size_t buf_sz, struct verif_stats * &s->stats[MARK_READ_MAX_LEN]))continue ; +if (sscanf (cur,"stack depth max %ld" , &s->stats[MAX_STACK ]) ==1 ) +continue ; +if (sscanf (cur,"subprog %*d %*s %*s insns_self %*d insns_total %*d stack %ld" , &sub_stack) ==1 ) { + s->stats[STACK ] += sub_stack; +continue ; + }
Nit: a comment about why two different formats are matched would be helpful.
Quoted 9 lines
tools/testing/selftests/bpf/veristat.c +1
-1if (2 ==sscanf (cur,"stack depth %511s max %ld" , stack, &s->stats[MAX_STACK ]))continue ; }while ((token =strtok_r (cnt++ ?NULL : stack,"+" , &state))) { -if (sscanf (token,"%d" , &sub_stack) ==0 ) +if (sscanf (token,"%ld" , &sub_stack) ==0 )break ; s->stats[STACK ] += sub_stack; }
Kumar Kartikeya Dwivedi
maintainerPATCH v7 5/6 selftests/bpf: Test stack depth stats without BTF subprog names
In reply to Kumar Kartikeya DwivediTest the per-program insns_self, insns_total, and stack depth statistics emitted when BTF function info does not provide subprogram names. Check that the subprog 0 main record and static-subprogram records use <unknown>.
Make VERBOSE_ACCEPT request verifier statistics so the raw-insn test can validate the output without a test-specific log level.
--- tools/testing/selftests/bpf/test_verifier.c | 2 +- tools/testing/selftests/bpf/verifier/calls.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/test_verifier.c +1 -1
@@ -1560,7 +1560,7 @@ static void do_test_single(struct bpf_test *test, bool unpriv, opts.expected_attach_type = test->expected_attach_type;if (expected_ret ==VERBOSE_ACCEPT ) - opts.log_level =2 ; + opts.log_level =2 |4 ;else if (verbose) opts.log_level = verif_log_level |4 ;/* force stats */ else
tools/testing/selftests/bpf/verifier/calls.c +11 -1
@@ -1091,7 +1091,17 @@/* stack_main=32, stack_A=256, stack_B=64 * and max(main+A, main+A+B) < 512 */ - .result = ACCEPT, + .result = VERBOSE_ACCEPT, + .errstr ="stack depth max 352\t" +"subprog 0 (<unknown>) main insns_self \t" +" insns_total \t" +" stack 32\t" +"subprog 1 (<unknown>) static insns_self \t" +" insns_total \t" +" stack 256\t" +"subprog 2 (<unknown>) static insns_self \t" +" insns_total \t" +" stack 64" , }, { "calls: stack depth check using three frames. test2",
Signature · 1 line
2.53.0
Re: [PATCH bpf-next v7 5/6] selftests/bpf: Test stack depth stats without BTF subprog names
Quoted 9 lines · Kumar Kartikeya Dwivedi
Test the per-program
insns_self,insns_total, and stack depth statistics emitted when BTF function info does not provide subprogram names. Check that the subprog 0 main record and static-subprogram records use <unknown>.Make
VERBOSE_ACCEPTrequest verifier statistics so the raw-insn test can validate the output without a test-specific log level.Signed-off-by Kumar Kartikeya Dwivedi <[email protected]>---
...
Kumar Kartikeya Dwivedi
maintainerPATCH v7 6/6 selftests/bpf: Test subprogram instruction statistics
In reply to Kumar Kartikeya DwivediAdd small verifier programs with deterministic instruction streams to exercise per-subprogram self and inclusive instruction accounting. Use assembly for normal call chains and straight-line callback bodies containing only moves, calls, and returns or exits, so control-flow pruning does not make the expected counts unstable. Pass callback arguments as explicit assembly operands so the compiler keeps their registers live across the asm block.
Cover asynchronous callback attribution separately: main verification-root totals include all callback exploration, while static and callback totals remain local to their synchronous paths.
--- .../selftests/bpf/prog_tests/verifier.c | 2 + .../bpf/progs/verifier_subprog_insn_stats.c | 228 ++++++++++++++++++ 2 files changed, 230 insertions(+) create mode 100644 tools/testing/selftests/bpf/progs/verifier_subprog_insn_stats.c
tools/testing/selftests/bpf/prog_tests/verifier.c +2 -0
@@ -100,6 +100,7 @@#include "verifier_stack_arg_order.skel.h" #include "verifier_stack_ptr.skel.h" #include "verifier_store_release.skel.h" +#include "verifier_subprog_insn_stats.skel.h" #include "verifier_subprog_precision.skel.h" #include "verifier_subprog_topo.skel.h" #include "verifier_subreg.skel.h"
@@ -255,6 +256,7 @@ void test_verifier_stack_arg(void) { RUN(verifier_stack_arg); }void test_verifier_stack_arg_order (void ) {RUN (verifier_stack_arg_order); }void test_verifier_stack_ptr (void ) {RUN (verifier_stack_ptr); }void test_verifier_store_release (void ) {RUN (verifier_store_release); } +void test_verifier_subprog_insn_stats (void ) {RUN (verifier_subprog_insn_stats); }void test_verifier_subprog_precision (void ) {RUN (verifier_subprog_precision); }void test_verifier_subprog_topo (void ) {RUN (verifier_subprog_topo); }void test_verifier_subreg (void ) {RUN (verifier_subreg); }
tools/testing/selftests/bpf/progs/verifier_subprog_insn_stats.c new file +228 -0
228 lines not on this page · raw message
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH bpf-next v7 6/6] selftests/bpf: Test subprogram instruction statistics
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The expected verifier logs for `stats_async_schedule`, `stats_async_outer`, and…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The expected verifier logs for stats_async_schedule, stats_async_outer, and stats_async_nested_schedule mandate exactly 7 instructions and stack 0. However, because these are standard C functions (lacking __naked) that use inline assembly with __clobber_common (which clobbers all caller-saved registers r0-r5), the compiler must allocate callee-saved registers (e.g., r6, r7) for their input operands. This forces the emission of prologue and epilogue stack spills, guaranteeing a non-zero stack depth and a higher instruction count. The rigid __msg assertions will fail at runtime. --
--- Patch [6]: [PATCH bpf-next v7 6/6] selftests/bpf: Test subprogram instruction statistics --- commit af1dc26c02b580a6a5ab3fdfc1f191d5895df8f8
Author: Kumar Kartikeya Dwivedi <[email protected]>
selftests/bpf: Test subprogram instruction statistics
Add small verifier programs with deterministic instruction streams to exercise per-subprogram self and inclusive instruction accounting. Use assembly for normal call chains and straight-line callback bodies containing only moves, calls, and returns or exits.
Quoted 5 lines
tools/testing/selftests/bpf/progs/verifier_subprog_insn_stats.c new file +0
-0
[ ... ]
Quoted 16 lines
tools/testing/selftests/bpf/progs/verifier_subprog_insn_stats.c new file +16
-0+__noinline __used +static __u64 stats_async_schedule(struct bpf_map *map, __u32 *key, +struct timer_value *value,void *ctx) +{ + asmvolatile ( +"r1 = %[timer];" +"r2 = %[stats_async_leaf];" +"call %[bpf_timer_set_callback];" + : + : [timer] "r" (value), + __imm_ptr(stats_async_leaf), +__imm (bpf_timer_set_callback) + : __clobber_common + ); +return 0 ; +}
tools/testing/selftests/bpf/progs/verifier_subprog_insn_stats.c line 135
Quoted 10 lines
tools/testing/selftests/bpf/progs/verifier_subprog_insn_stats.c new file +10
-0+ +SEC("?raw_tp") +__success __log_level(4) +/* +* self: 9 + 7 + 2 = 18 +* totals: leaf 2, scheduler 7, main root 18 +*/ +__msg("subprog 0 (stats_async_direct) main insns_self 9 insns_total 18 stack 0") +__msg ("subprog {{[0-9]+}} (stats_async_schedule) static insns_self 7 " +"insns_total 7 stack 0" )
[Severity: Medium]
Since stats_async_schedule() is a standard C function (lacking the __naked attribute) and the inline assembly uses __clobber_common (clobbering r0-r5), won't the compiler be forced to allocate callee-saved registers (like r6 or r7) for the input operands?
If the compiler emits prologue and epilogue stack spills for these registers, it would result in a non-zero stack depth and a higher instruction count, causing the expected "stack 0" and "insns_self 7" verifier log assertions to fail at runtime.
[ ... ]
Quoted 34 lines
tools/testing/selftests/bpf/progs/verifier_subprog_insn_stats.c new file +34
-0+__noinline __used +static int stats_async_outer(void *map, __u32 *key, struct bpf_timer *timer) +{ + asmvolatile ( +"r1 = %[timer];" +"r2 = %[stats_async_nested_leaf];" +"call %[bpf_timer_set_callback];" + : + : [timer] "r" (timer), + __imm_ptr(stats_async_nested_leaf), +__imm (bpf_timer_set_callback) + : __clobber_common + ); +return 0 ; +} + +__noinline __used +static __u64 stats_async_nested_schedule(struct bpf_map *map, __u32 *key, +struct timer_value *value,void *ctx) +{ + asmvolatile ( +"r1 = %[timer];" +"r2 = %[stats_async_outer];" +"call %[bpf_timer_set_callback];" + : + : [timer] "r" (value), + __imm_ptr(stats_async_outer), +__imm (bpf_timer_set_callback) + : __clobber_common + ); +return 0 ; +} + +SEC ("?raw_tp" )
tools/testing/selftests/bpf/progs/verifier_subprog_insn_stats.c line 206
Quoted 10 lines
tools/testing/selftests/bpf/progs/verifier_subprog_insn_stats.c new file +10
-0+__success __log_level(4) +/* + * self: 9 + 7 + 7 + 2 = 25 + * totals: leaf 2, outer 7, scheduler 7, main root 25 + */ +__msg("subprog 0 (stats_async_nested) main insns_self 9 insns_total 25 stack 0") +__msg("subprog {{[0-9]+}} (stats_async_nested_schedule) static insns_self 7 " + "insns_total 7 stack 0") +__msg ("subprog {{[0-9]+}} (stats_async_outer) static insns_self 7 " +"insns_total 7 stack 0" )
[Severity: Medium]
Will these assertions fail for the same reason?
Like stats_async_schedule(), both stats_async_outer() and stats_async_nested_schedule() lack __naked and use __clobber_common, which will likely cause compiler-emitted stack spills and exceed the expected "stack 0" and "insns_self 7" values.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
Re: [PATCH bpf-next v7 6/6] selftests/bpf: Test subprogram instruction statistics
In reply to Kumar Kartikeya DwivediQuoted 7 lines · Kumar Kartikeya Dwivedi
Add small verifier programs with deterministic instruction streams to exercise per-subprogram self and inclusive instruction accounting. Use assembly for normal call chains and straight-line callback bodies containing only moves, calls, and returns or exits, so control-flow pruning does not make the expected counts unstable. Pass callback arguments as explicit assembly operands so the compiler keeps their registers live across the asm block.
Quoted 6 lines
Cover asynchronous callback attribution separately: main verification-root totals include all callback exploration, while static and callback totals remain local to their synchronous paths.
Signed-off-by Kumar Kartikeya Dwivedi <[email protected]>---
...