Return bpf program run_time_ns and run_cnt via bpf_prog_info
Unified · Split
| @@ -2813,6 +2813,8 @@ struct bpf_prog_info { · 2812 unmodified lines | ||
| 2813 | 2813 | __u32 jited_line_info_rec_size; |
| 2814 | 2814 | __u32 nr_prog_tags; |
| 2815 | 2815 | __aligned_u64 prog_tags; |
| 2816 | + __u64 run_time_ns; | |
| 2817 | + __u64 run_cnt; | |
| 2816 | 2818 | } __attribute__((aligned(8))); |
| 2817 | 2819 | |
| 2818 | 2820 | struct bpf_map_info { |
| @@ -2152,6 +2152,7 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog, · 2151 unmodified lines | ||
| 2152 | 2152 | struct bpf_prog_info __user *uinfo = u64_to_user_ptr(attr->info.info); |
| 2153 | 2153 | struct bpf_prog_info info = {}; |
| 2154 | 2154 | u32 info_len = attr->info.info_len; |
| 2155 | + struct bpf_prog_stats stats; | |
| 2155 | 2156 | char __user *uinsns; |
| 2156 | 2157 | u32 ulen; |
| 2157 | 2158 | int err; |
| @@ -2191,6 +2192,10 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog, · 33 unmodified lines | ||
| 2191 | 2192 | if (err) |
| 2192 | 2193 | return err; |
| 2193 | 2194 | |
| 2195 | + bpf_prog_get_stats(prog, &stats); | |
| 2196 | + info.run_time_ns = stats.nsecs; | |
| 2197 | + info.run_cnt = stats.cnt; | |
| 2198 | + | |
| 2194 | 2199 | if (!capable(CAP_SYS_ADMIN)) { |
| 2195 | 2200 | info.jited_prog_len = 0; |
| 2196 | 2201 | info.xlated_prog_len = 0; |