Skip to content

Commit

Permalink
tracing: make CALLER_ADDRx overwriteable
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Ingo Molnar <[email protected]>
Reviewed-by: KOSAKI Motohiro <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
  • Loading branch information
Uwe Kleine-Koenig authored and Steven Rostedt committed Mar 2, 2009
1 parent 96ccd21 commit c79a61f
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 20 deletions.
1 change: 1 addition & 0 deletions arch/alpha/include/asm/ftrace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* empty */
1 change: 1 addition & 0 deletions arch/avr32/include/asm/ftrace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* empty */
1 change: 1 addition & 0 deletions arch/blackfin/include/asm/ftrace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* empty */
1 change: 1 addition & 0 deletions arch/cris/include/asm/ftrace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* empty */
1 change: 1 addition & 0 deletions arch/h8300/include/asm/ftrace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* empty */
1 change: 1 addition & 0 deletions arch/m68k/include/asm/ftrace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* empty */
1 change: 1 addition & 0 deletions arch/mips/include/asm/ftrace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* empty */
1 change: 1 addition & 0 deletions arch/parisc/include/asm/ftrace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* empty */
1 change: 1 addition & 0 deletions arch/um/include/asm/ftrace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* empty */
1 change: 1 addition & 0 deletions arch/xtensa/include/asm/ftrace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* empty */
1 change: 1 addition & 0 deletions include/asm-frv/ftrace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* empty */
1 change: 1 addition & 0 deletions include/asm-m32r/ftrace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* empty */
1 change: 1 addition & 0 deletions include/asm-mn10300/ftrace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* empty */
41 changes: 21 additions & 20 deletions include/linux/ftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <linux/bitops.h>
#include <linux/sched.h>

#include <asm/ftrace.h>

#ifdef CONFIG_FUNCTION_TRACER

extern int ftrace_enabled;
Expand Down Expand Up @@ -103,8 +105,6 @@ struct ftrace_func_command {
};

#ifdef CONFIG_DYNAMIC_FTRACE
/* asm/ftrace.h must be defined for archs supporting dynamic ftrace */
#include <asm/ftrace.h>

int ftrace_arch_code_modify_prepare(void);
int ftrace_arch_code_modify_post_process(void);
Expand Down Expand Up @@ -282,24 +282,25 @@ static inline void __ftrace_enabled_restore(int enabled)
#endif
}

#ifdef CONFIG_FRAME_POINTER
/* TODO: need to fix this for ARM */
# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
# define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1))
# define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2))
# define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3))
# define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4))
# define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5))
# define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6))
#else
# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
# define CALLER_ADDR1 0UL
# define CALLER_ADDR2 0UL
# define CALLER_ADDR3 0UL
# define CALLER_ADDR4 0UL
# define CALLER_ADDR5 0UL
# define CALLER_ADDR6 0UL
#endif
#ifndef HAVE_ARCH_CALLER_ADDR
# ifdef CONFIG_FRAME_POINTER
# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
# define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1))
# define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2))
# define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3))
# define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4))
# define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5))
# define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6))
# else
# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
# define CALLER_ADDR1 0UL
# define CALLER_ADDR2 0UL
# define CALLER_ADDR3 0UL
# define CALLER_ADDR4 0UL
# define CALLER_ADDR5 0UL
# define CALLER_ADDR6 0UL
# endif
#endif /* ifndef HAVE_ARCH_CALLER_ADDR */

#ifdef CONFIG_IRQSOFF_TRACER
extern void time_hardirqs_on(unsigned long a0, unsigned long a1);
Expand Down

0 comments on commit c79a61f

Please sign in to comment.