aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorWu Zhangjin <wuzhangjin@gmail.com>2009-11-20 07:34:35 -0500
committerRalf Baechle <ralf@linux-mips.org>2009-12-16 20:57:25 -0500
commite17ff5fec65a0213416efbe7ceae5f2f9887dda2 (patch)
tree9f315fcacb075e4e1828fd9e0bd2133e11ec47b2 /arch
parent29c5d3462f7c8f17bb9e0a29f0a299036468074d (diff)
MIPS: Tracing: Add dynamic function graph tracer for MIPS
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. (NOTE: This not work with 32bit! need to ensure why!) Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Nicholas Mc Guire <der.herr@hofr.at> Cc: zhangfx@lemote.com Cc: Wu Zhangjin <wuzhangjin@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: linux-kernel@vger.kernel.org Cc: linux-mips@linux-mips.org Patchwork: http://patchwork.linux-mips.org/patch/678/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/mips/kernel/ftrace.c21
-rw-r--r--arch/mips/kernel/mcount.S14
2 files changed, 33 insertions, 2 deletions
diff --git a/arch/mips/kernel/ftrace.c b/arch/mips/kernel/ftrace.c
index 65a3f8a89927..e981a497c98f 100644
--- a/arch/mips/kernel/ftrace.c
+++ b/arch/mips/kernel/ftrace.c
@@ -115,6 +115,27 @@ int __init ftrace_dyn_arch_init(void *data)
115 115
116#ifdef CONFIG_FUNCTION_GRAPH_TRACER 116#ifdef CONFIG_FUNCTION_GRAPH_TRACER
117 117
118#ifdef CONFIG_DYNAMIC_FTRACE
119
120extern void ftrace_graph_call(void);
121#define JMP 0x08000000 /* jump to target directly */
122#define CALL_FTRACE_GRAPH_CALLER \
123 jump_insn_encode(JMP, (unsigned long)(&ftrace_graph_caller))
124#define FTRACE_GRAPH_CALL_IP ((unsigned long)(&ftrace_graph_call))
125
126int ftrace_enable_ftrace_graph_caller(void)
127{
128 return ftrace_modify_code(FTRACE_GRAPH_CALL_IP,
129 CALL_FTRACE_GRAPH_CALLER);
130}
131
132int ftrace_disable_ftrace_graph_caller(void)
133{
134 return ftrace_modify_code(FTRACE_GRAPH_CALL_IP, ftrace_nop);
135}
136
137#endif /* !CONFIG_DYNAMIC_FTRACE */
138
118#define S_RA_SP (0xafbf << 16) /* s{d,w} ra, offset(sp) */ 139#define S_RA_SP (0xafbf << 16) /* s{d,w} ra, offset(sp) */
119#define S_R_SP (0xafb0 << 16) /* s{d,w} R, offset(sp) */ 140#define S_R_SP (0xafb0 << 16) /* s{d,w} R, offset(sp) */
120#define OFFSET_MASK 0xffff /* stack offset range: 0 ~ PT_SIZE */ 141#define OFFSET_MASK 0xffff /* stack offset range: 0 ~ PT_SIZE */
diff --git a/arch/mips/kernel/mcount.S b/arch/mips/kernel/mcount.S
index b50e38d828c4..98d469032506 100644
--- a/arch/mips/kernel/mcount.S
+++ b/arch/mips/kernel/mcount.S
@@ -77,6 +77,13 @@ ftrace_call:
77 nop /* a placeholder for the call to a real tracing function */ 77 nop /* a placeholder for the call to a real tracing function */
78 move a1, AT /* arg2: the caller's next ip, parent */ 78 move a1, AT /* arg2: the caller's next ip, parent */
79 79
80#ifdef CONFIG_FUNCTION_GRAPH_TRACER
81 .globl ftrace_graph_call
82ftrace_graph_call:
83 nop
84 nop
85#endif
86
80 MCOUNT_RESTORE_REGS 87 MCOUNT_RESTORE_REGS
81 .globl ftrace_stub 88 .globl ftrace_stub
82ftrace_stub: 89ftrace_stub:
@@ -124,10 +131,13 @@ ftrace_stub:
124#ifdef CONFIG_FUNCTION_GRAPH_TRACER 131#ifdef CONFIG_FUNCTION_GRAPH_TRACER
125 132
126NESTED(ftrace_graph_caller, PT_SIZE, ra) 133NESTED(ftrace_graph_caller, PT_SIZE, ra)
134#ifdef CONFIG_DYNAMIC_FTRACE
135 PTR_L a1, PT_R31(sp) /* load the original ra from the stack */
136#else
127 MCOUNT_SAVE_REGS 137 MCOUNT_SAVE_REGS
128
129 PTR_LA a0, PT_R1(sp) /* arg1: &AT -> a0 */
130 move a1, ra /* arg2: next ip, selfaddr */ 138 move a1, ra /* arg2: next ip, selfaddr */
139#endif
140 PTR_LA a0, PT_R1(sp) /* arg1: &AT -> a0 */
131 jal prepare_ftrace_return 141 jal prepare_ftrace_return
132 move a2, fp /* arg3: frame pointer */ 142 move a2, fp /* arg3: frame pointer */
133 143