public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Jiri Olsa <jolsa@redhat.com>
Cc: mingo@kernel.org, linux-kernel@vger.kernel.org,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] perf ftrace: Factor regs retrieval for function tracer
Date: Thu, 18 Dec 2014 15:20:27 +0100	[thread overview]
Message-ID: <20141218142027.GE30905@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <20141218140847.GA18898@krava.brq.redhat.com>

On Thu, Dec 18, 2014 at 03:08:47PM +0100, Jiri Olsa wrote:
> diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
> index 6fa484de2ba1..54bffedd28b6 100644
> --- a/kernel/trace/trace_event_perf.c
> +++ b/kernel/trace/trace_event_perf.c
> @@ -304,7 +304,7 @@ perf_ftrace_function_call(unsigned long ip, unsigned long parent_ip,
>  {
>  	struct ftrace_entry *entry;
>  	struct hlist_head *head;
> -	struct pt_regs regs;
> +	struct pt_regs **regsp, *regs = pt_regs;
>  	int rctx;
>  
>  	head = this_cpu_ptr(event_function.perf_events);
> @@ -316,16 +316,24 @@ perf_ftrace_function_call(unsigned long ip, unsigned long parent_ip,
>  
>  	BUILD_BUG_ON(ENTRY_SIZE > PERF_MAX_TRACE_SIZE);
>  
> -	perf_fetch_caller_regs(&regs);
> +	/*
> +	 * The ftrace_ops is registered with SAVE_REGS_IF_SUPPORTED,
> +	 * so if we got pt_regs defined, we don't need to retrieve
> +	 * regs buffer through perf_trace_buf_prepare.
> +	 */
> +	regsp = pt_regs ? NULL : &regs;
>  
> -	entry = perf_trace_buf_prepare(ENTRY_SIZE, TRACE_FN, NULL, &rctx);
> +	entry = perf_trace_buf_prepare(ENTRY_SIZE, TRACE_FN, regsp, &rctx);
>  	if (!entry)
>  		return;
>  
> +	if (regsp)
> +		perf_fetch_caller_regs(regs);
> +


Would not something like:

	struct pt_regs *regs;

	entry = perf_trace_buf_prepare(ENTRY_SIZE, TRACE_FN, &regs, &rctx);
	if (!pt_regs) {
		perf_fetch_caller_regs(regs);
		pt_regs = regs;
	}

Be simpler?

  reply	other threads:[~2014-12-18 14:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-16 11:50 [PATCH] perf: Avoid horrible stack usage Peter Zijlstra
2014-12-17 14:31 ` Jiri Olsa
2014-12-17 15:35   ` Peter Zijlstra
2014-12-17 15:45     ` Jiri Olsa
2014-12-18 14:08       ` [PATCH] perf ftrace: Factor regs retrieval for function tracer Jiri Olsa
2014-12-18 14:20         ` Peter Zijlstra [this message]
2014-12-18 14:28           ` Jiri Olsa
2014-12-18 15:10             ` Peter Zijlstra
2015-01-14 19:19 ` [tip:perf/core] perf: Avoid horrible stack usage tip-bot for Peter Zijlstra (Intel)

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=20141218142027.GE30905@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=torvalds@linux-foundation.org \
    /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