aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace
diff options
context:
space:
mode:
authorWang Nan <wangnan0@huawei.com>2015-06-30 22:13:50 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-08-06 14:29:14 -0400
commit04a22fae4cbc1f7d3f7471e9b36359f98bd3f043 (patch)
tree56aaf8966290b8718c6792ec0df9095221fd8d8a /kernel/trace
parent098d2164e3441c252eaa28906d45e16b7bf1bd2b (diff)
tracing, perf: Implement BPF programs attached to uprobes
By copying BPF related operation to uprobe processing path, this patch allow users attach BPF programs to uprobes like what they are already doing on kprobes. After this patch, users are allowed to use PERF_EVENT_IOC_SET_BPF on a uprobe perf event. Which make it possible to profile user space programs and kernel events together using BPF. Because of this patch, CONFIG_BPF_EVENTS should be selected by CONFIG_UPROBE_EVENT to ensure trace_call_bpf() is compiled even if KPROBE_EVENT is not set. Signed-off-by: Wang Nan <wangnan0@huawei.com> Acked-by: Alexei Starovoitov <ast@plumgrid.com> Cc: Brendan Gregg <brendan.d.gregg@gmail.com> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: David Ahern <dsahern@gmail.com> Cc: He Kuang <hekuang@huawei.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kaixu Xia <xiakaixu@huawei.com> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Zefan Li <lizefan@huawei.com> Cc: pi3orama@163.com Link: http://lkml.kernel.org/r/1435716878-189507-3-git-send-email-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'kernel/trace')
-rw-r--r--kernel/trace/Kconfig2
-rw-r--r--kernel/trace/trace_uprobe.c5
2 files changed, 6 insertions, 1 deletions
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index 3b9a48ae153a..1153c43428f3 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -434,7 +434,7 @@ config UPROBE_EVENT
434 434
435config BPF_EVENTS 435config BPF_EVENTS
436 depends on BPF_SYSCALL 436 depends on BPF_SYSCALL
437 depends on KPROBE_EVENT 437 depends on KPROBE_EVENT || UPROBE_EVENT
438 bool 438 bool
439 default y 439 default y
440 help 440 help
diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index aa1ea7b36fa8..f97479f1ce35 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -1095,11 +1095,15 @@ static void __uprobe_perf_func(struct trace_uprobe *tu,
1095{ 1095{
1096 struct trace_event_call *call = &tu->tp.call; 1096 struct trace_event_call *call = &tu->tp.call;
1097 struct uprobe_trace_entry_head *entry; 1097 struct uprobe_trace_entry_head *entry;
1098 struct bpf_prog *prog = call->prog;
1098 struct hlist_head *head; 1099 struct hlist_head *head;
1099 void *data; 1100 void *data;
1100 int size, esize; 1101 int size, esize;
1101 int rctx; 1102 int rctx;
1102 1103
1104 if (prog && !trace_call_bpf(prog, regs))
1105 return;
1106
1103 esize = SIZEOF_TRACE_ENTRY(is_ret_probe(tu)); 1107 esize = SIZEOF_TRACE_ENTRY(is_ret_probe(tu));
1104 1108
1105 size = esize + tu->tp.size + dsize; 1109 size = esize + tu->tp.size + dsize;
@@ -1289,6 +1293,7 @@ static int register_uprobe_event(struct trace_uprobe *tu)
1289 return -ENODEV; 1293 return -ENODEV;
1290 } 1294 }
1291 1295
1296 call->flags = TRACE_EVENT_FL_UPROBE;
1292 call->class->reg = trace_uprobe_register; 1297 call->class->reg = trace_uprobe_register;
1293 call->data = tu; 1298 call->data = tu;
1294 ret = trace_add_event_call(call); 1299 ret = trace_add_event_call(call);