From e17ff5fec65a0213416efbe7ceae5f2f9887dda2 Mon Sep 17 00:00:00 2001 From: Wu Zhangjin Date: Fri, 20 Nov 2009 20:34:35 +0800 Subject: 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 Cc: Steven Rostedt Cc: Nicholas Mc Guire Cc: zhangfx@lemote.com Cc: Wu Zhangjin Cc: Ingo Molnar Cc: Thomas Gleixner Cc: Frederic Weisbecker 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 --- arch/mips/kernel/ftrace.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'arch/mips/kernel/ftrace.c') diff --git a/arch/mips/kernel/ftrace.c b/arch/mips/kernel/ftrace.c index 65a3f8a8992..e981a497c98 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) #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_SP (0xafbf << 16) /* s{d,w} ra, offset(sp) */ #define S_R_SP (0xafb0 << 16) /* s{d,w} R, offset(sp) */ #define OFFSET_MASK 0xffff /* stack offset range: 0 ~ PT_SIZE */ -- cgit v1.2.3