Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [v2 PATCH 5/5] tracing, MIPS: Fix set_graph_function of function graph tracer
@ 2011-01-21 17:29 Wu Zhangjin
  2011-01-21 17:35 ` Sergei Shtylyov
  0 siblings, 1 reply; 3+ messages in thread
From: Wu Zhangjin @ 2011-01-21 17:29 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Steven Rostedt, Sergei Shtylyov, linux-mips, Wu Zhangjin

trace.func should be set to the recorded ip of the mcount calling site
in the __mcount_loc section to filter the function entries configured
through the tracing/set_graph_function interface, but before, this is
set to the self_ra(the return address of mcount), which has made
set_graph_function not work as expected.

This fixes it via calculating the right recorded ip in the __mcount_loc
section and assign it to trace.func.

Reported-by: Zhiping Zhong <xzhong86@163.com>
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
---
 arch/mips/kernel/ftrace.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/mips/kernel/ftrace.c b/arch/mips/kernel/ftrace.c
index bc91e4a..be3fa7a 100644
--- a/arch/mips/kernel/ftrace.c
+++ b/arch/mips/kernel/ftrace.c
@@ -257,7 +257,7 @@ void prepare_ftrace_return(unsigned long *parent_ra_addr, unsigned long self_ra,
 	struct ftrace_graph_ent trace;
 	unsigned long return_hooker = (unsigned long)
 	    &return_to_handler;
-	int faulted;
+	int faulted, insns;
 
 	if (unlikely(atomic_read(&current->tracing_graph_pause)))
 		return;
@@ -304,7 +304,14 @@ void prepare_ftrace_return(unsigned long *parent_ra_addr, unsigned long self_ra,
 		return;
 	}
 
-	trace.func = self_ra;
+	/*
+	 * Get the recorded ip of the current mcount calling site in the
+	 * __mcount_loc section, which will be used to filter the function
+	 * entries configured through the tracing/set_graph_function interface.
+	 */
+
+	insns = (in_kernel_space(self_ra)) ? 2 : MCOUNT_OFFSET_INSNS + 1;
+	trace.func = self_ra - (MCOUNT_INSN_SIZE * insns);
 
 	/* Only trace if the calling function expects to */
 	if (!ftrace_graph_entry(&trace)) {
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [v2 PATCH 5/5] tracing, MIPS: Fix set_graph_function of function graph tracer
  2011-01-21 17:29 [v2 PATCH 5/5] tracing, MIPS: Fix set_graph_function of function graph tracer Wu Zhangjin
@ 2011-01-21 17:35 ` Sergei Shtylyov
  2011-01-21 18:00   ` wu zhangjin
  0 siblings, 1 reply; 3+ messages in thread
From: Sergei Shtylyov @ 2011-01-21 17:35 UTC (permalink / raw)
  To: Wu Zhangjin; +Cc: Ralf Baechle, Steven Rostedt, linux-mips

Hello.

Wu Zhangjin wrote:

> trace.func should be set to the recorded ip of the mcount calling site
> in the __mcount_loc section to filter the function entries configured
> through the tracing/set_graph_function interface, but before, this is
> set to the self_ra(the return address of mcount), which has made
> set_graph_function not work as expected.

> This fixes it via calculating the right recorded ip in the __mcount_loc
> section and assign it to trace.func.

> Reported-by: Zhiping Zhong <xzhong86@163.com>
> Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
> ---
>  arch/mips/kernel/ftrace.c |   11 +++++++++--
>  1 files changed, 9 insertions(+), 2 deletions(-)

> diff --git a/arch/mips/kernel/ftrace.c b/arch/mips/kernel/ftrace.c
> index bc91e4a..be3fa7a 100644
> --- a/arch/mips/kernel/ftrace.c
> +++ b/arch/mips/kernel/ftrace.c
[...]
> @@ -304,7 +304,14 @@ void prepare_ftrace_return(unsigned long *parent_ra_addr, unsigned long self_ra,
>  		return;
>  	}
>  
> -	trace.func = self_ra;
> +	/*
> +	 * Get the recorded ip of the current mcount calling site in the
> +	 * __mcount_loc section, which will be used to filter the function
> +	 * entries configured through the tracing/set_graph_function interface.
> +	 */
> +
> +	insns = (in_kernel_space(self_ra)) ? 2 : MCOUNT_OFFSET_INSNS + 1;

    You're still keeping the parens around the function call. Why? :-)

WBR, Sergei

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [v2 PATCH 5/5] tracing, MIPS: Fix set_graph_function of function graph tracer
  2011-01-21 17:35 ` Sergei Shtylyov
@ 2011-01-21 18:00   ` wu zhangjin
  0 siblings, 0 replies; 3+ messages in thread
From: wu zhangjin @ 2011-01-21 18:00 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: Ralf Baechle, Steven Rostedt, linux-mips

On Sat, Jan 22, 2011 at 1:35 AM, Sergei Shtylyov <sshtylyov@mvista.com> wrote:
>> +
>> +       insns = (in_kernel_space(self_ra)) ? 2 : MCOUNT_OFFSET_INSNS + 1;
>
>   You're still keeping the parens around the function call. Why? :-)

I even didn't notice there was parens there, may be parens mania, new
one will be out immediately ;-)

>
> WBR, Sergei
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-01-21 18:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-21 17:29 [v2 PATCH 5/5] tracing, MIPS: Fix set_graph_function of function graph tracer Wu Zhangjin
2011-01-21 17:35 ` Sergei Shtylyov
2011-01-21 18:00   ` wu zhangjin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox