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 07/10] tracing: Add eBPF program support to static trace events
Date: Fri, 12 Feb 2016 10:11:25 -0600 [thread overview]
Message-ID: <595b4f9d780c10fc0e0f401cc07a204c9129ee78.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>
Have perf_trace_*() and perf_syscall_enter()/exit() make calls to
trace_call_bpf() if there's a TRACE_EVENT program associated with a
trace event.
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
---
include/trace/perf.h | 10 ++++++++++
kernel/trace/trace_syscalls.c | 18 ++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/include/trace/perf.h b/include/trace/perf.h
index 26486fc..0d8069c 100644
--- a/include/trace/perf.h
+++ b/include/trace/perf.h
@@ -1,3 +1,5 @@
+#include <linux/filter.h>
+#include <linux/bpf.h>
#undef TRACE_SYSTEM_VAR
@@ -35,6 +37,7 @@ static notrace void \
perf_trace_##call(void *__data, proto) \
{ \
struct trace_event_call *event_call = __data; \
+ struct bpf_prog *prog = event_call->prog; \
struct trace_event_data_offsets_##call __maybe_unused __data_offsets;\
struct trace_event_raw_##call *entry; \
struct pt_regs *__regs; \
@@ -67,6 +70,13 @@ perf_trace_##call(void *__data, proto) \
\
{ assign; } \
\
+ if (prog && prog->type == BPF_PROG_TYPE_TRACE_EVENT) { \
+ struct trace_event_context ctx = { event_call, entry }; \
+ \
+ if (!trace_call_bpf(prog, &ctx)) \
+ return; \
+ } \
+ \
perf_trace_buf_submit(entry, __entry_size, rctx, __addr, \
__count, __regs, head, __task); \
}
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 50be560..feea899 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -6,6 +6,8 @@
#include <linux/module.h> /* for MODULE_NAME_LEN via KSYM_SYMBOL_LEN */
#include <linux/ftrace.h>
#include <linux/perf_event.h>
+#include <linux/filter.h>
+#include <linux/bpf.h>
#include <asm/syscall.h>
#include "trace_output.h"
@@ -562,6 +564,7 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id)
struct syscall_metadata *sys_data;
struct syscall_trace_enter *rec;
struct hlist_head *head;
+ struct bpf_prog *prog;
int syscall_nr;
int rctx;
int size;
@@ -576,6 +579,8 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id)
if (!sys_data)
return;
+ prog = sys_data->enter_event->prog;
+
head = this_cpu_ptr(sys_data->enter_event->perf_events);
if (hlist_empty(head))
return;
@@ -593,6 +598,11 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id)
rec->nr = syscall_nr;
syscall_get_arguments(current, regs, 0, sys_data->nb_args,
(unsigned long *)&rec->args);
+ if (prog && prog->type == BPF_PROG_TYPE_TRACE_EVENT) {
+ struct trace_event_context ctx = { sys_data->enter_event, rec };
+ if (!trace_call_bpf(prog, &ctx))
+ return;
+ }
perf_trace_buf_submit(rec, size, rctx, 0, 1, regs, head, NULL);
}
@@ -636,6 +646,7 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
struct syscall_metadata *sys_data;
struct syscall_trace_exit *rec;
struct hlist_head *head;
+ struct bpf_prog *prog;
int syscall_nr;
int rctx;
int size;
@@ -650,6 +661,8 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
if (!sys_data)
return;
+ prog = sys_data->enter_event->prog;
+
head = this_cpu_ptr(sys_data->exit_event->perf_events);
if (hlist_empty(head))
return;
@@ -665,6 +678,11 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
rec->nr = syscall_nr;
rec->ret = syscall_get_return_value(current, regs);
+ if (prog && prog->type == BPF_PROG_TYPE_TRACE_EVENT) {
+ struct trace_event_context ctx = { sys_data->exit_event, rec };
+ if (!trace_call_bpf(prog, &ctx))
+ return;
+ }
perf_trace_buf_submit(rec, size, rctx, 0, 1, regs, head, NULL);
}
--
1.9.3
next prev parent reply other threads:[~2016-02-12 16:13 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 ` [RFC][PATCH 06/10] tracing: Add kprobe/uprobe support for TRACE_EVENT eBPF progs Tom Zanussi
2016-02-12 16:11 ` Tom Zanussi [this message]
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=595b4f9d780c10fc0e0f401cc07a204c9129ee78.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®