Skip to contentSkip to conversation

tracing, MIPS: Fix set_graph_function of function graph tracer

PATCH Superseded Wu Zhangjin 2 participants 3 messages Jan 21, 2011

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 5/5 tracing, MIPS: Fix set_graph_function of function graph tracer

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.

---
 arch/mips/kernel/ftrace.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
arch/mips/kernel/ftrace.c +9 -2
index bc91e4a..be3fa7a 100644
@@ -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)) {
Signature · 1 line
1.7.1
#1 lore raw

Hello.

Quoted 19 lines · 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.

---
 arch/mips/kernel/ftrace.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
arch/mips/kernel/ftrace.c +0 -0
index bc91e4a..be3fa7a 100644

[...]

arch/mips/kernel/ftrace.c void prepare_ftrace_return(unsigned long *parent_ra_addr, unsigned long self_ra, · line 313

Quoted 12 lines
arch/mips/kernel/ftrace.c +7 -1
@@ -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

#2 lore raw
Quoted 4 lines · Sergei Shtylyov
Quoted 2 lines

+
+       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 ;-)

Quoted 3 lines

WBR, Sergei