-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Wu Zhangjin
authored and
Ralf Baechle
committed
Dec 17, 2009
1 parent
8922f79
commit d2bb076
Showing
6 changed files
with
121 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,24 @@ | ||
/* empty */ | ||
/* | ||
* This file is subject to the terms and conditions of the GNU General Public | ||
* License. See the file "COPYING" in the main directory of this archive for | ||
* more details. | ||
* | ||
* Copyright (C) 2009 DSLab, Lanzhou University, China | ||
* Author: Wu Zhangjin <wuzj@lemote.com> | ||
*/ | ||
|
||
#ifndef _ASM_MIPS_FTRACE_H | ||
#define _ASM_MIPS_FTRACE_H | ||
|
||
#ifdef CONFIG_FUNCTION_TRACER | ||
|
||
#define MCOUNT_ADDR ((unsigned long)(_mcount)) | ||
#define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */ | ||
|
||
#ifndef __ASSEMBLY__ | ||
extern void _mcount(void); | ||
#define mcount _mcount | ||
|
||
#endif /* __ASSEMBLY__ */ | ||
#endif /* CONFIG_FUNCTION_TRACER */ | ||
#endif /* _ASM_MIPS_FTRACE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* MIPS specific _mcount support | ||
* | ||
* This file is subject to the terms and conditions of the GNU General Public | ||
* License. See the file "COPYING" in the main directory of this archive for | ||
* more details. | ||
* | ||
* Copyright (C) 2009 Lemote Inc. & DSLab, Lanzhou University, China | ||
* Author: Wu Zhangjin <wuzj@lemote.com> | ||
*/ | ||
|
||
#include <asm/regdef.h> | ||
#include <asm/stackframe.h> | ||
#include <asm/ftrace.h> | ||
|
||
.text | ||
.set noreorder | ||
.set noat | ||
|
||
.macro MCOUNT_SAVE_REGS | ||
PTR_SUBU sp, PT_SIZE | ||
PTR_S ra, PT_R31(sp) | ||
PTR_S AT, PT_R1(sp) | ||
PTR_S a0, PT_R4(sp) | ||
PTR_S a1, PT_R5(sp) | ||
PTR_S a2, PT_R6(sp) | ||
PTR_S a3, PT_R7(sp) | ||
#ifdef CONFIG_64BIT | ||
PTR_S a4, PT_R8(sp) | ||
PTR_S a5, PT_R9(sp) | ||
PTR_S a6, PT_R10(sp) | ||
PTR_S a7, PT_R11(sp) | ||
#endif | ||
.endm | ||
|
||
.macro MCOUNT_RESTORE_REGS | ||
PTR_L ra, PT_R31(sp) | ||
PTR_L AT, PT_R1(sp) | ||
PTR_L a0, PT_R4(sp) | ||
PTR_L a1, PT_R5(sp) | ||
PTR_L a2, PT_R6(sp) | ||
PTR_L a3, PT_R7(sp) | ||
#ifdef CONFIG_64BIT | ||
PTR_L a4, PT_R8(sp) | ||
PTR_L a5, PT_R9(sp) | ||
PTR_L a6, PT_R10(sp) | ||
PTR_L a7, PT_R11(sp) | ||
#endif | ||
#ifdef CONFIG_64BIT | ||
PTR_ADDIU sp, PT_SIZE | ||
#else | ||
PTR_ADDIU sp, (PT_SIZE + 8) | ||
#endif | ||
.endm | ||
|
||
.macro RETURN_BACK | ||
jr ra | ||
move ra, AT | ||
.endm | ||
|
||
NESTED(_mcount, PT_SIZE, ra) | ||
PTR_LA t0, ftrace_stub | ||
PTR_L t1, ftrace_trace_function /* Prepare t1 for (1) */ | ||
bne t0, t1, static_trace | ||
nop | ||
b ftrace_stub | ||
nop | ||
|
||
static_trace: | ||
MCOUNT_SAVE_REGS | ||
|
||
move a0, ra /* arg1: next ip, selfaddr */ | ||
jalr t1 /* (1) call *ftrace_trace_function */ | ||
move a1, AT /* arg2: the caller's next ip, parent */ | ||
|
||
MCOUNT_RESTORE_REGS | ||
.globl ftrace_stub | ||
ftrace_stub: | ||
RETURN_BACK | ||
END(_mcount) | ||
|
||
.set at | ||
.set reorder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters