Commit c79a61f55773d2519fd0525bf58385f7d20752d3

Authored by Uwe Kleine-Koenig
Committed by Steven Rostedt
1 parent 96ccd21cd1

tracing: make CALLER_ADDRx overwriteable

The current definition of CALLER_ADDRx isn't suitable for all platforms.
E.g. for ARM __builtin_return_address(N) doesn't work for N > 0 and
AFAIK for powerpc there are no frame pointers needed to have a working
__builtin_return_address.  This patch allows defining the CALLER_ADDRx
macros in <asm/ftrace.h> and let these take precedence.

Because now <asm/ftrace.h> is included unconditionally in
<linux/ftrace.h> all archs that don't already had this include get an
empty one for free.

Signed-off-by: Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@elte.hu>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>

Showing 14 changed files with 34 additions and 20 deletions Side-by-side Diff

arch/alpha/include/asm/ftrace.h
  1 +/* empty */
arch/avr32/include/asm/ftrace.h
  1 +/* empty */
arch/blackfin/include/asm/ftrace.h
  1 +/* empty */
arch/cris/include/asm/ftrace.h
  1 +/* empty */
arch/h8300/include/asm/ftrace.h
  1 +/* empty */
arch/m68k/include/asm/ftrace.h
  1 +/* empty */
arch/mips/include/asm/ftrace.h
  1 +/* empty */
arch/parisc/include/asm/ftrace.h
  1 +/* empty */
arch/um/include/asm/ftrace.h
  1 +/* empty */
arch/xtensa/include/asm/ftrace.h
  1 +/* empty */
include/asm-frv/ftrace.h
  1 +/* empty */
include/asm-m32r/ftrace.h
  1 +/* empty */
include/asm-mn10300/ftrace.h
  1 +/* empty */
include/linux/ftrace.h
... ... @@ -11,6 +11,8 @@
11 11 #include <linux/bitops.h>
12 12 #include <linux/sched.h>
13 13  
  14 +#include <asm/ftrace.h>
  15 +
14 16 #ifdef CONFIG_FUNCTION_TRACER
15 17  
16 18 extern int ftrace_enabled;
... ... @@ -103,8 +105,6 @@
103 105 };
104 106  
105 107 #ifdef CONFIG_DYNAMIC_FTRACE
106   -/* asm/ftrace.h must be defined for archs supporting dynamic ftrace */
107   -#include <asm/ftrace.h>
108 108  
109 109 int ftrace_arch_code_modify_prepare(void);
110 110 int ftrace_arch_code_modify_post_process(void);
... ... @@ -282,24 +282,25 @@
282 282 #endif
283 283 }
284 284  
285   -#ifdef CONFIG_FRAME_POINTER
286   -/* TODO: need to fix this for ARM */
287   -# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
288   -# define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1))
289   -# define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2))
290   -# define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3))
291   -# define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4))
292   -# define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5))
293   -# define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6))
294   -#else
295   -# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
296   -# define CALLER_ADDR1 0UL
297   -# define CALLER_ADDR2 0UL
298   -# define CALLER_ADDR3 0UL
299   -# define CALLER_ADDR4 0UL
300   -# define CALLER_ADDR5 0UL
301   -# define CALLER_ADDR6 0UL
302   -#endif
  285 +#ifndef HAVE_ARCH_CALLER_ADDR
  286 +# ifdef CONFIG_FRAME_POINTER
  287 +# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
  288 +# define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1))
  289 +# define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2))
  290 +# define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3))
  291 +# define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4))
  292 +# define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5))
  293 +# define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6))
  294 +# else
  295 +# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
  296 +# define CALLER_ADDR1 0UL
  297 +# define CALLER_ADDR2 0UL
  298 +# define CALLER_ADDR3 0UL
  299 +# define CALLER_ADDR4 0UL
  300 +# define CALLER_ADDR5 0UL
  301 +# define CALLER_ADDR6 0UL
  302 +# endif
  303 +#endif /* ifndef HAVE_ARCH_CALLER_ADDR */
303 304  
304 305 #ifdef CONFIG_IRQSOFF_TRACER
305 306 extern void time_hardirqs_on(unsigned long a0, unsigned long a1);