csky/ftrace: Add dynamic function tracer (include graph tracer)
Subsystems (3)
[email protected]
maintainerPATCH 1/1 csky/ftrace: Add dynamic function tracer (include graph tracer)
From: Guo Ren <[email protected]>
Support dynamic ftrace including dynamic graph tracer. Gcc-csky with -pg will produce call site in every function prologue and we can use these call site to hook trace function.
gcc with -pg origin call site:
push lr
jbsr _mcount
nop
nop
nop
nop
If the (callee - caller)'s offset is in range of bsr instruction, we'll modify code with:
push lr
bsr _mcount
nop
nop
nop
nop
Else if the (callee - caller)'s offset is out of bsr instrunction, we'll modify code with:
push lr movih r26, ... ori r26, ... jsr r26
(r26 is reserved for jsr link reg in csky abiv2 spec.)
Signed-off-by Guo Ren <[email protected]>
--- arch/csky/Kconfig | 3 +- arch/csky/abiv2/mcount.S | 43 +++++++++++- arch/csky/include/asm/ftrace.h | 18 ++++- arch/csky/kernel/ftrace.c | 148 ++++++++++++++++++++++++++++++++++++++++- scripts/recordmcount.pl | 3 + 5 files changed, 209 insertions(+), 6 deletions(-)
arch/csky/Kconfig +2 -1
@@ -28,14 +28,15 @@ config CSKY select GENERIC_SCHED_CLOCK select GENERIC_SMP_IDLE_THREAD select HAVE_ARCH_TRACEHOOK + select HAVE_DYNAMIC_FTRACE select HAVE_FUNCTION_TRACER select HAVE_FUNCTION_GRAPH_TRACER + select HAVE_FTRACE_MCOUNT_RECORD select HAVE_GENERIC_DMA_COHERENT select HAVE_KERNEL_GZIP select HAVE_KERNEL_LZO select HAVE_KERNEL_LZMA select HAVE_PERF_EVENTS - select HAVE_C_RECORDMCOUNT select HAVE_DMA_API_DEBUG select HAVE_DMA_CONTIGUOUS select MAY_HAVE_SPARSE_IRQ
arch/csky/abiv2/mcount.S +41 -2
71 lines not on this page · raw message
arch/csky/include/asm/ftrace.h +17 -1
@@ -4,10 +4,26 @@#ifndef __ASM_CSKY_FTRACE_H#define __ASM_CSKY_FTRACE_H -#define MCOUNT_INSN_SIZE 4 +#define MCOUNT_INSN_SIZE 14#define HAVE_FUNCTION_GRAPH_FP_TEST #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR +#define MCOUNT_ADDR ((unsigned long)_mcount) + +#ifndef __ASSEMBLY__ + +extern void _mcount (unsigned long ); + +extern void ftrace_graph_call (void ); + +static inline unsigned long ftrace_call_adjust (unsigned long addr) +{ +return addr; +} + +struct dyn_arch_ftrace { +}; +#endif /* !__ASSEMBLY__ */ #endif /* __ASM_CSKY_FTRACE_H */
arch/csky/kernel/ftrace.c +146 -2
160 lines not on this page · raw message
scripts/recordmcount.pl +3 -0
@@ -397,6 +397,9 @@ if ($arch eq "x86_64") { } elsif ($arch eq "nds32") { $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_NDS32_HI20_RELA\\s+_mcount\$"; $alignment = 2; +} elsif ($arch eq "csky") { + $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_CKCORE_PCREL_JSR_IMM26BY2\\s+_mcount\$"; + $alignment = 2; } else { die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD"; }
Signature · 1 line
2.7.4