This stat is currently printed in the verifier log and not stored anywhere. To ease consumption of this data, add a field to bpf_prog_aux so it can be exposed via BPF_OBJ_GET_INFO_BY_FD and fdinfo.
Unified · Split
| @@ -887,6 +887,7 @@ struct bpf_prog_aux { · 886 unmodified lines | ||
| 887 | 887 | struct bpf_prog *prog; |
| 888 | 888 | struct user_struct *user; |
| 889 | 889 | u64 load_time; /* ns since boottime */ |
| 890 | + u32 verified_insns; | |
| 890 | 891 | struct bpf_map *cgroup_storage[MAX_BPF_CGROUP_STORAGE_TYPE]; |
| 891 | 892 | char name[BPF_OBJ_NAME_LEN]; |
| 892 | 893 | #ifdef CONFIG_SECURITY |
| @@ -5620,6 +5620,7 @@ struct bpf_prog_info { · 5619 unmodified lines | ||
| 5620 | 5620 | __u64 run_time_ns; |
| 5621 | 5621 | __u64 run_cnt; |
| 5622 | 5622 | __u64 recursion_misses; |
| 5623 | + __u32 verified_insns; | |
| 5623 | 5624 | } __attribute__((aligned(8))); |
| 5624 | 5625 | |
| 5625 | 5626 | struct bpf_map_info { |
| @@ -1848,7 +1848,8 @@ static void bpf_prog_show_fdinfo(struct seq_file *m, struct file *filp) · 1847 unmodified lines | ||
| 1848 | 1848 | "prog_id:\t%u\n" |
| 1849 | 1849 | "run_time_ns:\t%llu\n" |
| 1850 | 1850 | "run_cnt:\t%llu\n" |
| 1851 | − "recursion_misses:\t%llu\n", | |
| 1851 | + "recursion_misses:\t%llu\n" | |
| 1852 | + "verified_insns:\t%u\n", | |
| 1852 | 1853 | prog->type, |
| 1853 | 1854 | prog->jited, |
| 1854 | 1855 | prog_tag, |
| @@ -1856,7 +1857,8 @@ static void bpf_prog_show_fdinfo(struct seq_file *m, struct file *filp) · 1 unmodified line | ||
| 1856 | 1857 | prog->aux->id, |
| 1857 | 1858 | stats.nsecs, |
| 1858 | 1859 | stats.cnt, |
| 1859 | − stats.misses); | |
| 1860 | + stats.misses, | |
| 1861 | + prog->aux->verified_insns); | |
| 1860 | 1862 | } |
| 1861 | 1863 | #endif |
| 1862 | 1864 | |
| @@ -3625,6 +3627,8 @@ static int bpf_prog_get_info_by_fd(struct file *file, · 1762 unmodified lines | ||
| 3625 | 3627 | info.run_cnt = stats.cnt; |
| 3626 | 3628 | info.recursion_misses = stats.misses; |
| 3627 | 3629 | |
| 3630 | + info.verified_insns = prog->aux->verified_insns; | |
| 3631 | + | |
| 3628 | 3632 | if (!bpf_capable()) { |
| 3629 | 3633 | info.jited_prog_len = 0; |
| 3630 | 3634 | info.xlated_prog_len = 0; |
| @@ -14033,6 +14033,7 @@ skip_full_check: · 14032 unmodified lines | ||
| 14033 | 14033 | |
| 14034 | 14034 | env->verification_time = ktime_get_ns() - start_time; |
| 14035 | 14035 | print_verification_stats(env); |
| 14036 | + env->prog->aux->verified_insns = env->insn_processed; | |
| 14036 | 14037 | |
| 14037 | 14038 | if (log->level && bpf_verifier_log_full(log)) |
| 14038 | 14039 | ret = -ENOSPC; |
| @@ -5620,6 +5620,7 @@ struct bpf_prog_info { · 5619 unmodified lines | ||
| 5620 | 5620 | __u64 run_time_ns; |
| 5621 | 5621 | __u64 run_cnt; |
| 5622 | 5622 | __u64 recursion_misses; |
| 5623 | + __u32 verified_insns; | |
| 5623 | 5624 | } __attribute__((aligned(8))); |
| 5624 | 5625 | |
| 5625 | 5626 | struct bpf_map_info { |