Re: [PATCH] perf/ftrace : Fix repetitious traces when specify a target task

From: Peter Zijlstra
Date: Tue Oct 10 2017 - 07:33:38 EST


On Tue, Oct 10, 2017 at 09:19:39AM +0800, Cheng Jian wrote:
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index baa134c..5682ead 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -7988,12 +7988,16 @@ void perf_tp_event(u16 event_type, u64 count, void *record, int entry_size,
>
> /* Use the given event instead of the hlist */
> if (event) {
> - if (perf_tp_event_match(event, &data, regs))
> + if (perf_tp_event_match(event, &data, regs)) {
> perf_swevent_event(event, count, &data, regs);
> + goto out;
> + }
> } else {
> hlist_for_each_entry_rcu(event, head, hlist_entry) {
> - if (perf_tp_event_match(event, &data, regs))
> + if (perf_tp_event_match(event, &data, regs)) {
> perf_swevent_event(event, count, &data, regs);
> + goto out;
> + }
> }
> }
>
> @@ -8015,13 +8019,15 @@ void perf_tp_event(u16 event_type, u64 count, void *record, int entry_size,
> continue;
> if (event->attr.config != entry->type)
> continue;
> - if (perf_tp_event_match(event, &data, regs))
> + if (perf_tp_event_match(event, &data, regs)) {
> perf_swevent_event(event, count, &data, regs);
> + break;
> + }
> }
> unlock:
> rcu_read_unlock();
> }
> -
> +out:
> perf_swevent_put_recursion_context(rctx);
> }
> EXPORT_SYMBOL_GPL(perf_tp_event);

No, this _cannot_ be right. The whole point of the @task argument was to
deliver the event multiple times -- maybe not to the same event, but it
needs to be delivered multiple times in some cases. Therefore this is
broken.

But now you've got me looking at 75e8387685f6, which also looks
completely insane.