From: jinshan.xiong@gmail.com
To: linux-kernel@vger.kernel.org, rostedt@goodmis.org, mingo@redhat.com
Cc: yhs@fb.com, jinshan.xiong@uber.com,
Jinshan Xiong <jinshan.xiong@gmail.com>
Subject: [PATCH] staging: tracing/kprobe: filter kprobe based perf event
Date: Tue, 17 Sep 2019 22:24:06 -0700 [thread overview]
Message-ID: <20190918052406.21385-1-jinshan.xiong@gmail.com> (raw)
From: Jinshan Xiong <jinshan.xiong@gmail.com>
Invoking bpf program only if kprobe based perf_event has been added into
the percpu list. This is essential to make event tracing for cgroup to work
properly.
Signed-off-by: Jinshan Xiong <jinshan.xiong@gmail.com>
---
kernel/trace/trace_kprobe.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 9d483ad9bb6c..40ef0f1945f7 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -1171,11 +1171,18 @@ static int
kprobe_perf_func(struct trace_kprobe *tk, struct pt_regs *regs)
{
struct trace_event_call *call = trace_probe_event_call(&tk->tp);
+ struct hlist_head *head = this_cpu_ptr(call->perf_events);
struct kprobe_trace_entry_head *entry;
- struct hlist_head *head;
int size, __size, dsize;
int rctx;
+ /*
+ * If head is empty, the process currently running on this cpu is not
+ * interested by kprobe perf PMU.
+ */
+ if (hlist_empty(head))
+ return 0;
+
if (bpf_prog_array_valid(call)) {
unsigned long orig_ip = instruction_pointer(regs);
int ret;
@@ -1193,10 +1200,6 @@ kprobe_perf_func(struct trace_kprobe *tk, struct pt_regs *regs)
return 0;
}
- head = this_cpu_ptr(call->perf_events);
- if (hlist_empty(head))
- return 0;
-
dsize = __get_data_size(&tk->tp, regs);
__size = sizeof(*entry) + tk->tp.size + dsize;
size = ALIGN(__size + sizeof(u32), sizeof(u64));
next reply other threads:[~2019-09-18 5:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-18 5:24 jinshan.xiong [this message]
2019-09-18 5:51 ` [PATCH] staging: tracing/kprobe: filter kprobe based perf event Yonghong Song
2019-09-18 14:32 ` Alexei Starovoitov
[not found] ` <CA+-8EHRk6aAuDQ=S9O7h6T2fhyz2z+zQduN2yiDNWMOWt2-t_A@mail.gmail.com>
2019-09-18 20:22 ` Alexei Starovoitov
2019-09-19 2:41 ` Jinshan Xiong
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=20190918052406.21385-1-jinshan.xiong@gmail.com \
--to=jinshan.xiong@gmail.com \
--cc=jinshan.xiong@uber.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=yhs@fb.com \
/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).