From: Wu Zhangjin <wuzhangjin@gmail.com>
To: linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Cc: Wu Zhangjin <wuzhangjin@gmail.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
rostedt@goodmis.org, Thomas Gleixner <tglx@linutronix.de>,
Ralf Baechle <ralf@linux-mips.org>,
Richard Sandiford <rdsandiford@googlemail.com>,
Nicholas Mc Guire <der.herr@hofr.at>,
David Daney <ddaney@caviumnetworks.com>,
Adam Nemet <anemet@caviumnetworks.com>,
Patrik Kluba <kpajko79@gmail.com>
Subject: [PATCH -v6 13/13] tracing: add dynamic function graph tracer for MIPS
Date: Mon, 26 Oct 2009 23:13:30 +0800 [thread overview]
Message-ID: <ee544ea8570821c0ff73fa155bfd8484bd6f1a74.1256569489.git.wuzhangjin@gmail.com> (raw)
In-Reply-To: <60dd7085d4df145318582d0a829887b4abf6e6c1.1256569489.git.wuzhangjin@gmail.com>
In-Reply-To: <cover.1256569489.git.wuzhangjin@gmail.com>
This patch make function graph tracer work with dynamic function tracer.
To share the source code of dynamic function tracer(MCOUNT_SAVE_REGS),
and avoid restoring the whole saved registers, we need to restore the ra
register from the stack.
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
---
arch/mips/kernel/ftrace.c | 21 +++++++++++++++++++++
arch/mips/kernel/mcount.S | 14 ++++++++++++--
2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/arch/mips/kernel/ftrace.c b/arch/mips/kernel/ftrace.c
index 4cf11f5..1c02e65 100644
--- a/arch/mips/kernel/ftrace.c
+++ b/arch/mips/kernel/ftrace.c
@@ -79,6 +79,27 @@ int __init ftrace_dyn_arch_init(void *data)
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+#ifdef CONFIG_DYNAMIC_FTRACE
+
+extern void ftrace_graph_call(void);
+#define JMP 0x08000000 /* jump to target directly */
+#define CALL_FTRACE_GRAPH_CALLER \
+ jump_insn_encode(JMP, (unsigned long)(&ftrace_graph_caller))
+#define FTRACE_GRAPH_CALL_IP ((unsigned long)(&ftrace_graph_call))
+
+int ftrace_enable_ftrace_graph_caller(void)
+{
+ return ftrace_modify_code(FTRACE_GRAPH_CALL_IP,
+ CALL_FTRACE_GRAPH_CALLER);
+}
+
+int ftrace_disable_ftrace_graph_caller(void)
+{
+ return ftrace_modify_code(FTRACE_GRAPH_CALL_IP, ftrace_nop);
+}
+
+#endif /* !CONFIG_DYNAMIC_FTRACE */
+
#define S_RA (0x2fbf << 16) /* 32bit: afbf, 64bit: ffbf */
#define MOV_FP_SP 0x03a0f021 /* 32bit: 0x03a0f021, 64bit: 0x03a0f02d */
#define STACK_OFFSET_MASK 0xfff /* stack offset range: 0 ~ PT_SIZE(304) */
diff --git a/arch/mips/kernel/mcount.S b/arch/mips/kernel/mcount.S
index a9ba888..260719d 100644
--- a/arch/mips/kernel/mcount.S
+++ b/arch/mips/kernel/mcount.S
@@ -82,6 +82,13 @@ ftrace_call:
nop /* a placeholder for the call to a real tracing function */
nop /* Do not touch me, I'm in the dealy slot of "jal func" */
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+ .globl ftrace_graph_call
+ftrace_graph_call:
+ nop
+ nop
+#endif
+
MCOUNT_RESTORE_REGS
.globl ftrace_stub
ftrace_stub:
@@ -129,10 +136,13 @@ ftrace_stub:
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
NESTED(ftrace_graph_caller, PT_SIZE, ra)
+#ifdef CONFIG_DYNAMIC_FTRACE
+ PTR_L a1, PT_R31(sp) /* load the original ra from the stack */
+#else
MCOUNT_SAVE_REGS
-
- PTR_LA a0, PT_R1(sp) /* arg1: &AT -> a0 */
move a1, ra /* arg2: next ip, selfaddr */
+#endif
+ PTR_LA a0, PT_R1(sp) /* arg1: &AT -> a0 */
PTR_SUBU a1, MCOUNT_INSN_SIZE
move a2, fp /* arg3: frame pointer */
jal prepare_ftrace_return
--
1.6.2.1
next prev parent reply other threads:[~2009-10-26 15:16 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-26 15:13 [PATCH -v6 00/13] ftrace for MIPS Wu Zhangjin
2009-10-26 15:13 ` [PATCH -v6 01/13] tracing: convert trace_clock_local() as weak function Wu Zhangjin
2009-10-26 15:13 ` [PATCH -v6 02/13] tracing: add mips_timecounter_read() for MIPS Wu Zhangjin
2009-10-26 15:13 ` [PATCH -v6 03/13] tracing: add MIPS specific trace_clock_local() Wu Zhangjin
2009-10-26 15:13 ` [PATCH -v6 04/13] tracing: add static function tracer support for MIPS Wu Zhangjin
2009-10-26 15:13 ` [PATCH -v6 05/13] tracing: enable HAVE_FUNCTION_TRACE_MCOUNT_TEST " Wu Zhangjin
2009-10-26 15:13 ` [PATCH -v6 06/13] tracing: add an endian argument to scripts/recordmcount.pl Wu Zhangjin
2009-10-26 15:13 ` [PATCH -v6 07/13] tracing: add dynamic function tracer support for MIPS Wu Zhangjin
2009-10-26 15:13 ` [PATCH -v6 08/13] tracing: add IRQENTRY_EXIT section " Wu Zhangjin
2009-10-26 15:13 ` [PATCH -v6 09/13] tracing: Add __arch_notrace for arch specific requirement Wu Zhangjin
2009-10-26 15:13 ` [PATCH -v6 10/13] tracing: not trace the timecounter_read* in kernel/time/clocksource.c Wu Zhangjin
2009-10-26 15:13 ` [PATCH -v6 11/13] tracing: not trace mips_timecounter_read() for MIPS Wu Zhangjin
2009-10-26 15:13 ` [PATCH -v6 12/13] tracing: add function graph tracer support " Wu Zhangjin
2009-10-26 15:13 ` Wu Zhangjin [this message]
2009-11-09 2:26 ` [PATCH -v6 08/13] tracing: add IRQENTRY_EXIT section " Frederic Weisbecker
2009-11-09 3:31 ` Wu Zhangjin
2009-11-09 3:31 ` Wu Zhangjin
2009-11-09 11:36 ` Frederic Weisbecker
2009-11-09 12:46 ` Steven Rostedt
2009-11-09 12:48 ` Steven Rostedt
2009-11-09 4:16 ` Wu Zhangjin
2009-10-26 16:06 ` [PATCH -v6 07/13] tracing: add dynamic function tracer support " Steven Rostedt
2009-10-26 16:35 ` Wu Zhangjin
2009-10-26 16:45 ` Steven Rostedt
2009-10-26 17:35 ` Wu Zhangjin
2009-10-26 15:41 ` [PATCH -v6 05/13] tracing: enable HAVE_FUNCTION_TRACE_MCOUNT_TEST " Sergei Shtylyov
2009-10-26 15:57 ` Steven Rostedt
2009-10-26 15:57 ` Steven Rostedt
2009-10-26 16:16 ` Wu Zhangjin
2009-11-09 4:15 ` [PATCH -v6 02/13] tracing: add mips_timecounter_read() " Wu Zhangjin
2009-11-09 4:15 ` Wu Zhangjin
2009-11-09 2:10 ` [PATCH -v6 01/13] tracing: convert trace_clock_local() as weak function Frederic Weisbecker
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=ee544ea8570821c0ff73fa155bfd8484bd6f1a74.1256569489.git.wuzhangjin@gmail.com \
--to=wuzhangjin@gmail.com \
--cc=anemet@caviumnetworks.com \
--cc=ddaney@caviumnetworks.com \
--cc=der.herr@hofr.at \
--cc=fweisbec@gmail.com \
--cc=kpajko79@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.org \
--cc=rdsandiford@googlemail.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.