perf/ftrace: Revert ("perf/ftrace: Fix double traces of perf on ftrace:function")
authorPeter Zijlstra <peterz@infradead.org>
Wed, 11 Oct 2017 07:45:29 +0000 (09:45 +0200)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Mon, 16 Oct 2017 22:11:02 +0000 (18:11 -0400)
Revert commit:

  75e8387685f6 ("perf/ftrace: Fix double traces of perf on ftrace:function")

The reason I instantly stumbled on that patch is that it only addresses the
ftrace situation and doesn't mention the other _5_ places that use this
interface. It doesn't explain why those don't have the problem and if not, why
their solution doesn't work for ftrace.

It doesn't, but this is just putting more duct tape on.

Link: http://lkml.kernel.org/r/20171011080224.200565770@infradead.org
Cc: Zhou Chengming <zhouchengming1@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
include/linux/perf_event.h
include/linux/trace_events.h
kernel/events/core.c
kernel/trace/trace_event_perf.c
kernel/trace/trace_kprobe.c
kernel/trace/trace_syscalls.c
kernel/trace/trace_uprobe.c

index 8e22f24ded6a3ad0e2accd96fe781be16c1987e4..569d1b54e201cf487cc0ce1b6e6d7490c0caee4c 100644 (file)
@@ -1184,7 +1184,7 @@ extern void perf_event_init(void);
 extern void perf_tp_event(u16 event_type, u64 count, void *record,
                          int entry_size, struct pt_regs *regs,
                          struct hlist_head *head, int rctx,
-                         struct task_struct *task, struct perf_event *event);
+                         struct task_struct *task);
 extern void perf_bp_event(struct perf_event *event, void *data);
 
 #ifndef perf_misc_flags
index 2e0f22298fe952748edbc68b35d5e3435335e53a..a6349b76fd39050983974753edc73bf710759134 100644 (file)
@@ -507,9 +507,9 @@ void perf_trace_run_bpf_submit(void *raw_data, int size, int rctx,
 static inline void
 perf_trace_buf_submit(void *raw_data, int size, int rctx, u16 type,
                       u64 count, struct pt_regs *regs, void *head,
-                      struct task_struct *task, struct perf_event *event)
+                      struct task_struct *task)
 {
-       perf_tp_event(type, count, raw_data, size, regs, head, rctx, task, event);
+       perf_tp_event(type, count, raw_data, size, regs, head, rctx, task);
 }
 #endif
 
index 6bc21e202ae40d36ceb9fa23d3c78785cad957da..b8db80c5513b1d90ffb9d81b2f127f13f6d87b7e 100644 (file)
@@ -7954,15 +7954,16 @@ void perf_trace_run_bpf_submit(void *raw_data, int size, int rctx,
                }
        }
        perf_tp_event(call->event.type, count, raw_data, size, regs, head,
-                     rctx, task, NULL);
+                     rctx, task);
 }
 EXPORT_SYMBOL_GPL(perf_trace_run_bpf_submit);
 
 void perf_tp_event(u16 event_type, u64 count, void *record, int entry_size,
                   struct pt_regs *regs, struct hlist_head *head, int rctx,
-                  struct task_struct *task, struct perf_event *event)
+                  struct task_struct *task)
 {
        struct perf_sample_data data;
+       struct perf_event *event;
 
        struct perf_raw_record raw = {
                .frag = {
@@ -7976,15 +7977,9 @@ void perf_tp_event(u16 event_type, u64 count, void *record, int entry_size,
 
        perf_trace_buf_update(record, event_type);
 
-       /* Use the given event instead of the hlist */
-       if (event) {
+       hlist_for_each_entry_rcu(event, head, hlist_entry) {
                if (perf_tp_event_match(event, &data, regs))
                        perf_swevent_event(event, count, &data, regs);
-       } else {
-               hlist_for_each_entry_rcu(event, head, hlist_entry) {
-                       if (perf_tp_event_match(event, &data, regs))
-                               perf_swevent_event(event, count, &data, regs);
-               }
        }
 
        /*
index 13ba2d3f6a91a147c8377041ee387ff457ab21c2..562fa69df5d3d3168db8a270b23c5b4864b6a79d 100644 (file)
@@ -306,7 +306,6 @@ static void
 perf_ftrace_function_call(unsigned long ip, unsigned long parent_ip,
                          struct ftrace_ops *ops, struct pt_regs *pt_regs)
 {
-       struct perf_event *event;
        struct ftrace_entry *entry;
        struct hlist_head *head;
        struct pt_regs regs;
@@ -330,9 +329,8 @@ perf_ftrace_function_call(unsigned long ip, unsigned long parent_ip,
 
        entry->ip = ip;
        entry->parent_ip = parent_ip;
-       event = container_of(ops, struct perf_event, ftrace_ops);
        perf_trace_buf_submit(entry, ENTRY_SIZE, rctx, TRACE_FN,
-                             1, &regs, head, NULL, event);
+                             1, &regs, head, NULL);
 
 #undef ENTRY_SIZE
 }
index af6134f2e59717c25922e433a3563cc32fb531b7..996902a526d46959d3669bdd77003765a6685851 100644 (file)
@@ -1200,7 +1200,7 @@ kprobe_perf_func(struct trace_kprobe *tk, struct pt_regs *regs)
        memset(&entry[1], 0, dsize);
        store_trace_args(sizeof(*entry), &tk->tp, regs, (u8 *)&entry[1], dsize);
        perf_trace_buf_submit(entry, size, rctx, call->event.type, 1, regs,
-                             head, NULL, NULL);
+                             head, NULL);
 }
 NOKPROBE_SYMBOL(kprobe_perf_func);
 
@@ -1236,7 +1236,7 @@ kretprobe_perf_func(struct trace_kprobe *tk, struct kretprobe_instance *ri,
        entry->ret_ip = (unsigned long)ri->ret_addr;
        store_trace_args(sizeof(*entry), &tk->tp, regs, (u8 *)&entry[1], dsize);
        perf_trace_buf_submit(entry, size, rctx, call->event.type, 1, regs,
-                             head, NULL, NULL);
+                             head, NULL);
 }
 NOKPROBE_SYMBOL(kretprobe_perf_func);
 #endif /* CONFIG_PERF_EVENTS */
index 696afe72d3b1445738feaa1031a4d7110363d6dd..934b0da72679e0c602d226eeba6ba10e8b94e1b7 100644 (file)
@@ -622,7 +622,7 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id)
 
        perf_trace_buf_submit(rec, size, rctx,
                              sys_data->enter_event->event.type, 1, regs,
-                             head, NULL, NULL);
+                             head, NULL);
 }
 
 static int perf_sysenter_enable(struct trace_event_call *call)
@@ -716,7 +716,7 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
        }
 
        perf_trace_buf_submit(rec, size, rctx, sys_data->exit_event->event.type,
-                             1, regs, head, NULL, NULL);
+                             1, regs, head, NULL);
 }
 
 static int perf_sysexit_enable(struct trace_event_call *call)
index b34965e62fb96bf5ec759b8009af6a573f65c255..402120ba45945ae8051190336f1454d45502f5c2 100644 (file)
@@ -1156,7 +1156,7 @@ static void __uprobe_perf_func(struct trace_uprobe *tu,
        }
 
        perf_trace_buf_submit(entry, size, rctx, call->event.type, 1, regs,
-                             head, NULL, NULL);
+                             head, NULL);
  out:
        preempt_enable();
 }