diff options
author | Alexei Starovoitov <ast@kernel.org> | 2019-02-25 17:28:40 -0500 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2019-02-27 11:22:50 -0500 |
commit | 5f8f8b93aeb8371c54af08bece2bd04bc2d48707 (patch) | |
tree | e4f26693f0c9c39b8ddde20b1187348401834000 /kernel/bpf/syscall.c | |
parent | 492ecee892c2a4ba6a14903d5d586ff750b7e805 (diff) |
bpf: expose program stats via bpf_prog_info
Return bpf program run_time_ns and run_cnt via bpf_prog_info
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'kernel/bpf/syscall.c')
-rw-r--r-- | kernel/bpf/syscall.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 31cf66fc3f5c..174581dfe225 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c | |||
@@ -2152,6 +2152,7 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog, | |||
2152 | struct bpf_prog_info __user *uinfo = u64_to_user_ptr(attr->info.info); | 2152 | struct bpf_prog_info __user *uinfo = u64_to_user_ptr(attr->info.info); |
2153 | struct bpf_prog_info info = {}; | 2153 | struct bpf_prog_info info = {}; |
2154 | u32 info_len = attr->info.info_len; | 2154 | u32 info_len = attr->info.info_len; |
2155 | struct bpf_prog_stats stats; | ||
2155 | char __user *uinsns; | 2156 | char __user *uinsns; |
2156 | u32 ulen; | 2157 | u32 ulen; |
2157 | int err; | 2158 | int err; |
@@ -2191,6 +2192,10 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog, | |||
2191 | if (err) | 2192 | if (err) |
2192 | return err; | 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 | if (!capable(CAP_SYS_ADMIN)) { | 2199 | if (!capable(CAP_SYS_ADMIN)) { |
2195 | info.jited_prog_len = 0; | 2200 | info.jited_prog_len = 0; |
2196 | info.xlated_prog_len = 0; | 2201 | info.xlated_prog_len = 0; |