From: Song Liu <songliubraving@fb.com>
To: <linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>
Cc: Song Liu <songliubraving@fb.com>, <peterz@infradead.org>,
<acme@kernel.org>, <ast@kernel.org>, <daniel@iogearbox.net>,
<kernel-team@fb.com>, <dsahern@gmail.com>
Subject: [PATCH v7 perf, bpf-next 5/8] perf, bpf: emit PERF_RECORD_KSYMBOL for BPF program load/unload
Date: Thu, 10 Jan 2019 16:19:30 -0800 [thread overview]
Message-ID: <20190111001933.4153792-6-songliubraving@fb.com> (raw)
In-Reply-To: <20190111001933.4153792-1-songliubraving@fb.com>
This patch enables emitting PERF_RECORD_KSYMBOL for BPF program load and
unload. A PERF_RECORD_KSYMBOL is issued for each BPF sub program.
Signed-off-by: Song Liu <songliubraving@fb.com>
---
kernel/events/core.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 8a8fa1b066ff..023821605b8d 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7798,6 +7798,30 @@ static int perf_event_bpf_get_name(char *name, int len, void *data)
return 0;
}
+static void perf_event_bpf_emit_ksymbols(struct bpf_prog *prog,
+ enum perf_bpf_event_type type)
+{
+ bool unregister = type == PERF_BPF_EVENT_PROG_UNLOAD;
+ int i;
+
+ if (prog->aux->func_cnt == 0) {
+ perf_event_ksymbol(PERF_RECORD_KSYMBOL_TYPE_BPF,
+ (u64)(unsigned long)prog->bpf_func,
+ prog->jited_len, unregister,
+ perf_event_bpf_get_name, prog);
+ } else {
+ for (i = 0; i < prog->aux->func_cnt; i++) {
+ struct bpf_prog *subprog = prog->aux->func[i];
+
+ perf_event_ksymbol(
+ PERF_RECORD_KSYMBOL_TYPE_BPF,
+ (u64)(unsigned long)subprog->bpf_func,
+ subprog->jited_len, unregister,
+ perf_event_bpf_get_name, subprog);
+ }
+ }
+}
+
void perf_event_bpf_event(struct bpf_prog *prog,
enum perf_bpf_event_type type,
u16 flags)
@@ -7808,6 +7832,16 @@ void perf_event_bpf_event(struct bpf_prog *prog,
type >= PERF_BPF_EVENT_MAX)
return;
+ switch (type) {
+ case PERF_BPF_EVENT_PROG_LOAD:
+ case PERF_BPF_EVENT_PROG_UNLOAD:
+ if (atomic_read(&nr_ksymbol_events))
+ perf_event_bpf_emit_ksymbols(prog, type);
+ break;
+ default:
+ break;
+ }
+
if (!atomic_read(&nr_bpf_events))
return;
--
2.17.1
next prev parent reply other threads:[~2019-01-11 0:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-11 0:19 [PATCH v7 perf, bpf-next 0/8] reveal invisible bpf programs Song Liu
2019-01-11 0:19 ` [PATCH v7 perf, bpf-next 1/8] perf, bpf: Introduce PERF_RECORD_KSYMBOL Song Liu
2019-01-11 0:19 ` [PATCH v7 perf, bpf-next 2/8] sync tools/include/uapi/linux/perf_event.h Song Liu
2019-01-11 0:19 ` [PATCH v7 perf, bpf-next 3/8] perf, bpf: introduce PERF_RECORD_BPF_EVENT Song Liu
2019-01-11 0:19 ` [PATCH v7 perf, bpf-next 4/8] sync tools/include/uapi/linux/perf_event.h Song Liu
2019-01-11 0:19 ` Song Liu [this message]
2019-01-11 0:19 ` [PATCH v7 perf, bpf-next 6/8] perf util: handle PERF_RECORD_KSYMBOL Song Liu
2019-01-14 17:11 ` Arnaldo Carvalho de Melo
2019-01-15 17:56 ` Arnaldo Carvalho de Melo
2019-01-15 19:58 ` Song Liu
2019-01-11 0:19 ` [PATCH v7 perf, bpf-next 7/8] perf util: handle PERF_RECORD_BPF_EVENT Song Liu
2019-01-14 17:12 ` Arnaldo Carvalho de Melo
2019-01-11 0:19 ` [PATCH v7 perf, bpf-next 8/8] perf tools: synthesize PERF_RECORD_* for loaded BPF programs Song Liu
2019-01-11 18:44 ` Arnaldo Carvalho de Melo
2019-01-11 19:23 ` Song Liu
2019-01-11 16:26 ` [PATCH v7 perf, bpf-next 0/8] reveal invisible bpf programs Arnaldo Carvalho de Melo
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=20190111001933.4153792-6-songliubraving@fb.com \
--to=songliubraving@fb.com \
--cc=acme@kernel.org \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=dsahern@gmail.com \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.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).