From: Song Liu <songliubraving@fb.com>
To: <bpf@vger.kernel.org>, <netdev@vger.kernel.org>
Cc: <ast@kernel.org>, <daniel@iogearbox.net>, <kernel-team@fb.com>,
Song Liu <songliubraving@fb.com>
Subject: [PATCH v9 bpf-next 2/3] libbpf: add support for command BPF_ENABLE_STATS
Date: Thu, 30 Apr 2020 00:15:05 -0700 [thread overview]
Message-ID: <20200430071506.1408910-3-songliubraving@fb.com> (raw)
In-Reply-To: <20200430071506.1408910-1-songliubraving@fb.com>
bpf_enable_stats() is added to enable given stats.
Signed-off-by: Song Liu <songliubraving@fb.com>
---
tools/lib/bpf/bpf.c | 10 ++++++++++
tools/lib/bpf/bpf.h | 1 +
tools/lib/bpf/libbpf.map | 1 +
3 files changed, 12 insertions(+)
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
index 8f2f0958d446..43322f0d6c7f 100644
--- a/tools/lib/bpf/bpf.c
+++ b/tools/lib/bpf/bpf.c
@@ -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));
+}
diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h
index 335b457b3a25..1901b2777854 100644
--- a/tools/lib/bpf/bpf.h
+++ b/tools/lib/bpf/bpf.h
@@ -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" */
diff --git a/tools/lib/bpf/libbpf.map b/tools/lib/bpf/libbpf.map
index 7cd49aa38005..e03bd4db827e 100644
--- a/tools/lib/bpf/libbpf.map
+++ b/tools/lib/bpf/libbpf.map
@@ -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;
--
2.24.1
next prev parent reply other threads:[~2020-04-30 7:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-30 7:15 [PATCH v9 bpf-next 0/3] bpf: sharing bpf runtime stats with Song Liu
2020-04-30 7:15 ` [PATCH v9 bpf-next 1/3] bpf: sharing bpf runtime stats with BPF_ENABLE_STATS Song Liu
2020-04-30 7:15 ` Song Liu [this message]
2020-05-02 20:00 ` [PATCH v9 bpf-next 2/3] libbpf: add support for command BPF_ENABLE_STATS Alexei Starovoitov
2020-05-04 17:45 ` Song Liu
2020-05-04 18:32 ` Andrii Nakryiko
2020-05-10 1:03 ` Alexei Starovoitov
2020-06-21 3:07 ` Andrii Nakryiko
2020-04-30 7:15 ` [PATCH v9 bpf-next 3/3] bpf: add selftest for BPF_ENABLE_STATS Song Liu
2020-04-30 18:16 ` Andrii Nakryiko
2020-05-01 17:56 ` [PATCH v9 bpf-next 0/3] bpf: sharing bpf runtime stats with Alexei Starovoitov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200430071506.1408910-3-songliubraving@fb.com \
--to=songliubraving@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).