From: Jiri Olsa <jolsa@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: rostedt@goodmis.org, mingo@kernel.org,
linux-kernel@vger.kernel.org, jolsa@kernel.org,
zhouchengming1@huawei.com
Subject: Re: [PATCH 2/4] perf/ftrace: Fix function trace events
Date: Wed, 11 Oct 2017 13:59:54 +0200 [thread overview]
Message-ID: <20171011115954.GA7940@krava> (raw)
In-Reply-To: <20171011080224.257804988@infradead.org>
On Wed, Oct 11, 2017 at 09:45:30AM +0200, Peter Zijlstra wrote:
SNIP
> void perf_trace_del(struct perf_event *p_event, int flags)
> {
> struct trace_event_call *tp_event = p_event->tp_event;
> - hlist_del_rcu(&p_event->hlist_entry);
> - tp_event->class->reg(tp_event, TRACE_REG_PERF_DEL, p_event);
> +
> + /*
> + * If TRACE_REG_PERF_DEL returns false; no custom action was performed
> + * and we need to take the default action of dequeueing our event from
> + * the right per-cpu hlist.
> + */
> + if (!tp_event->class->reg(tp_event, TRACE_REG_PERF_DEL, p_event))
> + hlist_del_rcu(&p_event->hlist_entry);
> }
>
> void *perf_trace_buf_alloc(int size, struct pt_regs **regs, int *rctxp)
> @@ -307,14 +321,24 @@ perf_ftrace_function_call(unsigned long
> struct ftrace_ops *ops, struct pt_regs *pt_regs)
> {
> struct ftrace_entry *entry;
> - struct hlist_head *head;
> + struct perf_event *event;
> + struct hlist_head head;
> struct pt_regs regs;
> int rctx;
>
> - head = this_cpu_ptr(event_function.perf_events);
> - if (hlist_empty(head))
> + if ((unsigned long)ops->private != smp_processor_id())
> return;
>
> + event = container_of(ops, struct perf_event, ftrace_ops);
> +
> + /*
> + * @event->hlist entry is NULL (per INIT_HLIST_NODE), and all
> + * the perf code does is hlist_for_each_entry_rcu(), so we can
> + * get away with simply setting the @head.first pointer in order
> + * to create a singular list.
> + */
> + head.first = &event->hlist_entry;
> +
> #define ENTRY_SIZE (ALIGN(sizeof(struct ftrace_entry) + sizeof(u32), \
> sizeof(u64)) - sizeof(u32))
>
> @@ -330,7 +354,7 @@ perf_ftrace_function_call(unsigned long
> entry->ip = ip;
> entry->parent_ip = parent_ip;
> perf_trace_buf_submit(entry, ENTRY_SIZE, rctx, TRACE_FN,
> - 1, ®s, head, NULL);
> + 1, ®s, &head, NULL);
nice idea.. I'll test it
jirka
next prev parent reply other threads:[~2017-10-11 11:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-11 7:45 [PATCH 0/4] perf/ftrace: Sanitize perf function-trace interaction Peter Zijlstra
2017-10-11 7:45 ` [PATCH 1/4] perf/ftrace: Revert ("perf/ftrace: Fix double traces of perf on ftrace:function") Peter Zijlstra
2017-10-11 12:57 ` Steven Rostedt
2017-10-11 7:45 ` [PATCH 2/4] perf/ftrace: Fix function trace events Peter Zijlstra
2017-10-11 9:02 ` zhouchengming
2017-10-11 16:40 ` Peter Zijlstra
2017-10-11 11:59 ` Jiri Olsa [this message]
2017-10-11 13:04 ` Steven Rostedt
2017-10-11 14:23 ` Jiri Olsa
2017-10-13 7:17 ` Peter Zijlstra
2017-10-16 22:15 ` Steven Rostedt
2017-10-11 7:45 ` [PATCH 3/4] perf/ftrace: Small cleanup Peter Zijlstra
2017-10-11 7:45 ` [PATCH 4/4] ftrace: Kill FTRACE_OPS_FL_PER_CPU Peter Zijlstra
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=20171011115954.GA7940@krava \
--to=jolsa@redhat.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=zhouchengming1@huawei.com \
/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