Skip to content

Commit a8fb260

Browse files
Steven Rostedtrostedt
authored andcommitted
perf/tracing: Fix regression of perf losing kprobe events
With the addition of the code to shrink the kernel tracepoint infrastructure, we lost kprobes being traced by perf. The reason is that I tested if the "tp_event->class->perf_probe" existed before enabling it. This prevents "ftrace only" events (like the function trace events) from being enabled by perf. Unfortunately, kprobe events do not use perf_probe. This causes kprobes to be missed by perf. To fix this, we add the test to see if "tp_event->class->reg" exists as well as perf_probe. Normal trace events have only "perf_probe" but no "reg" function, and kprobes and syscalls have the "reg" but no "perf_probe". The ftrace unique events do not have either, so this is a valid test. If a kprobe or syscall is not to be probed by perf, the "reg" function is called anyway, and will return a failure and prevent perf from probing it. Reported-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Tested-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent d110077 commit a8fb260

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎kernel/trace/trace_event_perf.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ int perf_trace_init(struct perf_event *p_event)
9696
mutex_lock(&event_mutex);
9797
list_for_each_entry(tp_event, &ftrace_events, list) {
9898
if (tp_event->event.type == event_id &&
99-
tp_event->class && tp_event->class->perf_probe &&
99+
tp_event->class &&
100+
(tp_event->class->perf_probe ||
101+
tp_event->class->reg) &&
100102
try_module_get(tp_event->mod)) {
101103
ret = perf_trace_event_init(tp_event, p_event);
102104
break;

0 commit comments

Comments
 (0)