]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
bpf: Print breakdown of insns processed by subprogs
authorPaul Chaignon <paul.chaignon@gmail.com>
Thu, 30 Apr 2026 08:44:28 +0000 (10:44 +0200)
committerKumar Kartikeya Dwivedi <memxor@gmail.com>
Thu, 30 Apr 2026 11:18:44 +0000 (13:18 +0200)
commitf603e84ab7918db6470c0b06b46ece7fbdb71e9a
tree0055d3a6b38298a8517847667ed39a2501e366cd
parent9f5b3ffc3f1dac7204e32eeeff84bc5cc55c393e
bpf: Print breakdown of insns processed by subprogs

When using global functions (i.e. subprogs), the verifier performs
function-by-function verification. In that case, the sum of the
instructions processed in each global function and in the main program
counts towards the 1 million instructions limit. Only that sum is
reported in the verifier logs.

While starting to use global functions in Cilium (finally!), we found it
can be useful to have the breakdown per global function, to understand
exactly where the budget is currently spent. This patch implements this
breakdown, under BPF_LOG_STATS, as done for the stack depths.

When iterating over subprogs, we need to skip the hidden subprogs at the
end because they don't have a corresponding func_info_aux entry and
calling bpf_subprog_is_global() would result in an OOB access.

Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
Link: https://lore.kernel.org/bpf/5590f9c67e614ec9054d0c7e74e87cc690a52c56.1777538384.git.paul.chaignon@gmail.com
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
include/linux/bpf_verifier.h
kernel/bpf/verifier.c