diff options
author | Wu Zhangjin <wuzhangjin@gmail.com> | 2009-11-20 07:34:29 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2009-12-16 20:57:21 -0500 |
commit | d2bb0762993e11363d8343127516b8fe88f9006f (patch) | |
tree | f210c4c4b0234a776977e6d2b749384e1d3699c1 /arch/mips/kernel/mcount.S | |
parent | 8922f79ee56e9dab6fc144defc0bc901ff0a7f8a (diff) |
MIPS: Tracing: Add static function tracer support for MIPS
If -pg of gcc is enabled with CONFIG_FUNCTION_TRACER=y. a calling to
_mcount will be inserted into each kernel function. so, there is a
possibility to trace the kernel functions in _mcount.
This patch add the MIPS specific _mcount support for static function
tracing. by default, ftrace_trace_function is initialized as
ftrace_stub(an empty function), so, the default _mcount will introduce
very little overhead. after enabling ftrace in user-space, it will jump
to a real tracing function and do static function tracing for us.
and -ffunction-sections is incompatible with -pg, so, disable it when
ftracer is enabled.
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
Reviewed-by: 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/672/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/kernel/mcount.S')
-rw-r--r-- | arch/mips/kernel/mcount.S | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/arch/mips/kernel/mcount.S b/arch/mips/kernel/mcount.S new file mode 100644 index 000000000000..cebcc3c11305 --- /dev/null +++ b/arch/mips/kernel/mcount.S | |||
@@ -0,0 +1,83 @@ | |||
1 | /* | ||
2 | * MIPS specific _mcount support | ||
3 | * | ||
4 | * This file is subject to the terms and conditions of the GNU General Public | ||
5 | * License. See the file "COPYING" in the main directory of this archive for | ||
6 | * more details. | ||
7 | * | ||
8 | * Copyright (C) 2009 Lemote Inc. & DSLab, Lanzhou University, China | ||
9 | * Author: Wu Zhangjin <wuzj@lemote.com> | ||
10 | */ | ||
11 | |||
12 | #include <asm/regdef.h> | ||
13 | #include <asm/stackframe.h> | ||
14 | #include <asm/ftrace.h> | ||
15 | |||
16 | .text | ||
17 | .set noreorder | ||
18 | .set noat | ||
19 | |||
20 | .macro MCOUNT_SAVE_REGS | ||
21 | PTR_SUBU sp, PT_SIZE | ||
22 | PTR_S ra, PT_R31(sp) | ||
23 | PTR_S AT, PT_R1(sp) | ||
24 | PTR_S a0, PT_R4(sp) | ||
25 | PTR_S a1, PT_R5(sp) | ||
26 | PTR_S a2, PT_R6(sp) | ||
27 | PTR_S a3, PT_R7(sp) | ||
28 | #ifdef CONFIG_64BIT | ||
29 | PTR_S a4, PT_R8(sp) | ||
30 | PTR_S a5, PT_R9(sp) | ||
31 | PTR_S a6, PT_R10(sp) | ||
32 | PTR_S a7, PT_R11(sp) | ||
33 | #endif | ||
34 | .endm | ||
35 | |||
36 | .macro MCOUNT_RESTORE_REGS | ||
37 | PTR_L ra, PT_R31(sp) | ||
38 | PTR_L AT, PT_R1(sp) | ||
39 | PTR_L a0, PT_R4(sp) | ||
40 | PTR_L a1, PT_R5(sp) | ||
41 | PTR_L a2, PT_R6(sp) | ||
42 | PTR_L a3, PT_R7(sp) | ||
43 | #ifdef CONFIG_64BIT | ||
44 | PTR_L a4, PT_R8(sp) | ||
45 | PTR_L a5, PT_R9(sp) | ||
46 | PTR_L a6, PT_R10(sp) | ||
47 | PTR_L a7, PT_R11(sp) | ||
48 | #endif | ||
49 | #ifdef CONFIG_64BIT | ||
50 | PTR_ADDIU sp, PT_SIZE | ||
51 | #else | ||
52 | PTR_ADDIU sp, (PT_SIZE + 8) | ||
53 | #endif | ||
54 | .endm | ||
55 | |||
56 | .macro RETURN_BACK | ||
57 | jr ra | ||
58 | move ra, AT | ||
59 | .endm | ||
60 | |||
61 | NESTED(_mcount, PT_SIZE, ra) | ||
62 | PTR_LA t0, ftrace_stub | ||
63 | PTR_L t1, ftrace_trace_function /* Prepare t1 for (1) */ | ||
64 | bne t0, t1, static_trace | ||
65 | nop | ||
66 | b ftrace_stub | ||
67 | nop | ||
68 | |||
69 | static_trace: | ||
70 | MCOUNT_SAVE_REGS | ||
71 | |||
72 | move a0, ra /* arg1: next ip, selfaddr */ | ||
73 | jalr t1 /* (1) call *ftrace_trace_function */ | ||
74 | move a1, AT /* arg2: the caller's next ip, parent */ | ||
75 | |||
76 | MCOUNT_RESTORE_REGS | ||
77 | .globl ftrace_stub | ||
78 | ftrace_stub: | ||
79 | RETURN_BACK | ||
80 | END(_mcount) | ||
81 | |||
82 | .set at | ||
83 | .set reorder | ||