libbpf: Add support for command BPF_ENABLE_STATS
authorSong Liu <songliubraving@fb.com>
Thu, 30 Apr 2020 07:15:05 +0000 (00:15 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 1 May 2020 17:36:32 +0000 (10:36 -0700)
bpf_enable_stats() is added to enable given stats.

Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200430071506.1408910-3-songliubraving@fb.com
tools/lib/bpf/bpf.c
tools/lib/bpf/bpf.h
tools/lib/bpf/libbpf.map

index 8f2f0958d446a449f67ae396e4f57c2cca63ebdf..43322f0d6c7f1c546c02bbb947cc6c9ed6193e6b 100644 (file)
@@ -841,3 +841,13 @@ int bpf_task_fd_query(int pid, int fd, __u32 flags, char *buf, __u32 *buf_len,
 
        return err;
 }
+
+int bpf_enable_stats(enum bpf_stats_type type)
+{
+       union bpf_attr attr;
+
+       memset(&attr, 0, sizeof(attr));
+       attr.enable_stats.type = type;
+
+       return sys_bpf(BPF_ENABLE_STATS, &attr, sizeof(attr));
+}
index 335b457b3a25d08bba5f3776840e5ba7d0fef128..1901b2777854ac5091c6a1d079ff48dc8ff8b71b 100644 (file)
@@ -231,6 +231,7 @@ LIBBPF_API int bpf_load_btf(void *btf, __u32 btf_size, char *log_buf,
 LIBBPF_API int bpf_task_fd_query(int pid, int fd, __u32 flags, char *buf,
                                 __u32 *buf_len, __u32 *prog_id, __u32 *fd_type,
                                 __u64 *probe_offset, __u64 *probe_addr);
+LIBBPF_API int bpf_enable_stats(enum bpf_stats_type type);
 
 #ifdef __cplusplus
 } /* extern "C" */
index 7cd49aa380057ee167eaaa34a2daf7c95a9f062e..e03bd4db827e57dcd6ded5915d0050b5f89c69cb 100644 (file)
@@ -257,6 +257,7 @@ LIBBPF_0.0.8 {
 
 LIBBPF_0.0.9 {
        global:
+               bpf_enable_stats;
                bpf_link_get_fd_by_id;
                bpf_link_get_next_id;
 } LIBBPF_0.0.8;