From: Tom Zanussi <tom.zanussi@linux.intel.com>
To: ast@plumgrid.com, rostedt@goodmis.org
Cc: masami.hiramatsu.pt@hitachi.com, namhyung@kernel.org,
peterz@infradead.org, linux-kernel@vger.kernel.org,
Tom Zanussi <tom.zanussi@linux.intel.com>
Subject: [RFC][PATCH 06/10] tracing: Add kprobe/uprobe support for TRACE_EVENT eBPF progs
Date: Fri, 12 Feb 2016 10:11:24 -0600 [thread overview]
Message-ID: <a8f73d820817f266725156664e6eaac5b0e0f406.1455291671.git.tom.zanussi@linux.intel.com> (raw)
In-Reply-To: <cover.1455291671.git.tom.zanussi@linux.intel.com>
In-Reply-To: <cover.1455291671.git.tom.zanussi@linux.intel.com>
Add a call at the end of kprobe/kretprobe/uprobe probe functions for
BPF_PROG_TYPE_TRACE_EVENT programs. These new calls are made after
the trace event fields have been stored into the trace buffer, where
they can then be accessed by the eBPF program.
The existing BPF_PROG_TYPE_KPROBE calls at the beginning remain, but
the prog type needs to be checked to see whether it's a kprobe or a
trace event prog.
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
---
kernel/trace/trace_kprobe.c | 20 ++++++++++++++++++--
kernel/trace/trace_uprobe.c | 11 ++++++++++-
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index c995644..34231f1 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -19,6 +19,8 @@
#include <linux/module.h>
#include <linux/uaccess.h>
+#include <linux/filter.h>
+#include <linux/bpf.h>
#include "trace_probe.h"
@@ -1129,7 +1131,8 @@ kprobe_perf_func(struct trace_kprobe *tk, struct pt_regs *regs)
int size, __size, dsize;
int rctx;
- if (prog && !trace_call_bpf(prog, regs))
+ if (prog && prog->type == BPF_PROG_TYPE_KPROBE &&
+ !trace_call_bpf(prog, regs))
return;
head = this_cpu_ptr(call->perf_events);
@@ -1148,6 +1151,12 @@ kprobe_perf_func(struct trace_kprobe *tk, struct pt_regs *regs)
entry->ip = (unsigned long)tk->rp.kp.addr;
memset(&entry[1], 0, dsize);
store_trace_args(sizeof(*entry), &tk->tp, regs, (u8 *)&entry[1], dsize);
+ if (prog && prog->type == BPF_PROG_TYPE_TRACE_EVENT) {
+ struct trace_event_context ctx = { call, entry };
+
+ if (!trace_call_bpf(prog, &ctx))
+ return;
+ }
perf_trace_buf_submit(entry, size, rctx, 0, 1, regs, head, NULL);
}
NOKPROBE_SYMBOL(kprobe_perf_func);
@@ -1164,7 +1173,8 @@ kretprobe_perf_func(struct trace_kprobe *tk, struct kretprobe_instance *ri,
int size, __size, dsize;
int rctx;
- if (prog && !trace_call_bpf(prog, regs))
+ if (prog && prog->type == BPF_PROG_TYPE_KPROBE &&
+ !trace_call_bpf(prog, regs))
return;
head = this_cpu_ptr(call->perf_events);
@@ -1183,6 +1193,12 @@ kretprobe_perf_func(struct trace_kprobe *tk, struct kretprobe_instance *ri,
entry->func = (unsigned long)tk->rp.kp.addr;
entry->ret_ip = (unsigned long)ri->ret_addr;
store_trace_args(sizeof(*entry), &tk->tp, regs, (u8 *)&entry[1], dsize);
+ if (prog && prog->type == BPF_PROG_TYPE_TRACE_EVENT) {
+ struct trace_event_context ctx = { call, entry };
+
+ if (!trace_call_bpf(prog, &ctx))
+ return;
+ }
perf_trace_buf_submit(entry, size, rctx, 0, 1, regs, head, NULL);
}
NOKPROBE_SYMBOL(kretprobe_perf_func);
diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index d2f6d0b..990bc71 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -23,6 +23,8 @@
#include <linux/uprobes.h>
#include <linux/namei.h>
#include <linux/string.h>
+#include <linux/filter.h>
+#include <linux/bpf.h>
#include "trace_probe.h"
@@ -1116,7 +1118,8 @@ static void __uprobe_perf_func(struct trace_uprobe *tu,
int size, esize;
int rctx;
- if (prog && !trace_call_bpf(prog, regs))
+ if (prog && prog->type == BPF_PROG_TYPE_KPROBE &&
+ trace_call_bpf(prog, regs))
return;
esize = SIZEOF_TRACE_ENTRY(is_ret_probe(tu));
@@ -1152,6 +1155,12 @@ static void __uprobe_perf_func(struct trace_uprobe *tu,
memset(data + len, 0, size - esize - len);
}
+ if (prog && prog->type == BPF_PROG_TYPE_TRACE_EVENT) {
+ struct trace_event_context ctx = { call, entry };
+
+ if (!trace_call_bpf(prog, &ctx))
+ return;
+ }
perf_trace_buf_submit(entry, size, rctx, 0, 1, regs, head, NULL);
out:
preempt_enable();
--
1.9.3
next prev parent reply other threads:[~2016-02-12 16:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-12 16:11 [RFC][PATCH 00/10] Add trace event support to eBPF Tom Zanussi
2016-02-12 16:11 ` [RFC][PATCH 01/10] tracing: Move some constants to ring_buffer.h Tom Zanussi
2016-02-12 16:11 ` [RFC][PATCH 02/10] eBPF: Add BPF_PROG_TYPE_TRACE_EVENT prog type Tom Zanussi
2016-02-12 16:11 ` [RFC][PATCH 03/10] tracing: Add an 'accessor' function to ftrace_event_field Tom Zanussi
2016-02-12 16:11 ` [RFC][PATCH 04/10] tracing: Add trace event accessor functions Tom Zanussi
2016-02-12 16:11 ` [RFC][PATCH 05/10] eBPF/tracing: Add eBPF trace event field access helpers Tom Zanussi
2016-02-12 16:11 ` Tom Zanussi [this message]
2016-02-12 16:11 ` [RFC][PATCH 07/10] tracing: Add eBPF program support to static trace events Tom Zanussi
2016-02-12 16:11 ` [RFC][PATCH 08/10] samples/bpf: Add support for trace events to the eBPF loading code Tom Zanussi
2016-02-12 16:11 ` [RFC][PATCH 09/10] samples/bpf: Add readcounts-by-pid example Tom Zanussi
2016-02-12 16:11 ` [RFC][PATCH 10/10] samples/bpf: Add kprobe-event-fields example Tom Zanussi
2016-02-14 0:02 ` [RFC][PATCH 00/10] Add trace event support to eBPF Alexei Starovoitov
2016-02-16 22:35 ` Tom Zanussi
2016-02-17 4:51 ` Alexei Starovoitov
2016-02-18 21:27 ` Tom Zanussi
2016-02-18 22:40 ` Daniel Borkmann
2016-02-19 4:16 ` 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=a8f73d820817f266725156664e6eaac5b0e0f406.1455291671.git.tom.zanussi@linux.intel.com \
--to=tom.zanussi@linux.intel.com \
--cc=ast@plumgrid.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.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
all inboxes | Powered by JetHome®