Commit eed542d6 authored by AKASHI Takahiro's avatar AKASHI Takahiro Committed by Steven Rostedt

ftrace: Make CALLER_ADDRx macros more generic

Most archs with HAVE_ARCH_CALLER_ADDR have pretty much the same
definitions of CALLER_ADDRx(n). Instead of duplicating the code for all
the archs, define a ftrace_return_address0() and
ftrace_return_address(n) that can be overwritten by the archs if they
need to do something different. Instead of 7 macros in every arch, we
now only have at most 2 (and actually only 1 as
ftrace_return_address0() should be the same for all archs).

The CALLER_ADDRx(n) will now be defined in linux/ftrace.h and use the
ftrace_return_address*(n?) macros. This removes a lot of the duplicate
code.

Link: http://lkml.kernel.org/p/1400585464-30333-1-git-send-email-takahiro.akashi@linaro.orgSigned-off-by: default avatarAKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent d6d211db
...@@ -52,15 +52,7 @@ extern inline void *return_address(unsigned int level) ...@@ -52,15 +52,7 @@ extern inline void *return_address(unsigned int level)
#endif #endif
#define HAVE_ARCH_CALLER_ADDR #define ftrace_return_addr(n) return_address(n)
#define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
#define CALLER_ADDR1 ((unsigned long)return_address(1))
#define CALLER_ADDR2 ((unsigned long)return_address(2))
#define CALLER_ADDR3 ((unsigned long)return_address(3))
#define CALLER_ADDR4 ((unsigned long)return_address(4))
#define CALLER_ADDR5 ((unsigned long)return_address(5))
#define CALLER_ADDR6 ((unsigned long)return_address(6))
#endif /* ifndef __ASSEMBLY__ */ #endif /* ifndef __ASSEMBLY__ */
......
...@@ -66,16 +66,7 @@ extern inline void *return_address(unsigned int level) ...@@ -66,16 +66,7 @@ extern inline void *return_address(unsigned int level)
#endif /* CONFIG_FRAME_POINTER */ #endif /* CONFIG_FRAME_POINTER */
#define HAVE_ARCH_CALLER_ADDR #define ftrace_return_address(n) return_address(n)
/* inline function or macro may lead to unexpected result */
#define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
#define CALLER_ADDR1 ((unsigned long)return_address(1))
#define CALLER_ADDR2 ((unsigned long)return_address(2))
#define CALLER_ADDR3 ((unsigned long)return_address(3))
#define CALLER_ADDR4 ((unsigned long)return_address(4))
#define CALLER_ADDR5 ((unsigned long)return_address(5))
#define CALLER_ADDR6 ((unsigned long)return_address(6))
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
......
...@@ -24,15 +24,7 @@ extern void return_to_handler(void); ...@@ -24,15 +24,7 @@ extern void return_to_handler(void);
extern unsigned long return_address(unsigned int); extern unsigned long return_address(unsigned int);
#define HAVE_ARCH_CALLER_ADDR #define ftrace_return_address(n) return_address(n)
#define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
#define CALLER_ADDR1 return_address(1)
#define CALLER_ADDR2 return_address(2)
#define CALLER_ADDR3 return_address(3)
#define CALLER_ADDR4 return_address(4)
#define CALLER_ADDR5 return_address(5)
#define CALLER_ADDR6 return_address(6)
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
......
...@@ -40,15 +40,7 @@ static inline unsigned long ftrace_call_adjust(unsigned long addr) ...@@ -40,15 +40,7 @@ static inline unsigned long ftrace_call_adjust(unsigned long addr)
/* arch/sh/kernel/return_address.c */ /* arch/sh/kernel/return_address.c */
extern void *return_address(unsigned int); extern void *return_address(unsigned int);
#define HAVE_ARCH_CALLER_ADDR #define ftrace_return_address(n) return_address(n)
#define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
#define CALLER_ADDR1 ((unsigned long)return_address(1))
#define CALLER_ADDR2 ((unsigned long)return_address(2))
#define CALLER_ADDR3 ((unsigned long)return_address(3))
#define CALLER_ADDR4 ((unsigned long)return_address(4))
#define CALLER_ADDR5 ((unsigned long)return_address(5))
#define CALLER_ADDR6 ((unsigned long)return_address(6))
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
......
...@@ -12,24 +12,18 @@ ...@@ -12,24 +12,18 @@
#include <asm/processor.h> #include <asm/processor.h>
#define HAVE_ARCH_CALLER_ADDR
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#define CALLER_ADDR0 ({ unsigned long a0, a1; \ #define ftrace_return_address0 ({ unsigned long a0, a1; \
__asm__ __volatile__ ( \ __asm__ __volatile__ ( \
"mov %0, a0\n" \ "mov %0, a0\n" \
"mov %1, a1\n" \ "mov %1, a1\n" \
: "=r"(a0), "=r"(a1)); \ : "=r"(a0), "=r"(a1)); \
MAKE_PC_FROM_RA(a0, a1); }) MAKE_PC_FROM_RA(a0, a1); })
#ifdef CONFIG_FRAME_POINTER #ifdef CONFIG_FRAME_POINTER
extern unsigned long return_address(unsigned level); extern unsigned long return_address(unsigned level);
#define CALLER_ADDR1 return_address(1) #define ftrace_return_address(n) return_address(n)
#define CALLER_ADDR2 return_address(2) #endif
#define CALLER_ADDR3 return_address(3)
#else /* CONFIG_FRAME_POINTER */
#define CALLER_ADDR1 (0)
#define CALLER_ADDR2 (0)
#define CALLER_ADDR3 (0)
#endif /* CONFIG_FRAME_POINTER */
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
#ifdef CONFIG_FUNCTION_TRACER #ifdef CONFIG_FUNCTION_TRACER
......
...@@ -616,25 +616,27 @@ static inline void __ftrace_enabled_restore(int enabled) ...@@ -616,25 +616,27 @@ static inline void __ftrace_enabled_restore(int enabled)
#endif #endif
} }
#ifndef HAVE_ARCH_CALLER_ADDR /* All archs should have this, but we define it for consistency */
#ifndef ftrace_return_address0
# define ftrace_return_address0 __builtin_return_address(0)
#endif
/* Archs may use other ways for ADDR1 and beyond */
#ifndef ftrace_return_address
# ifdef CONFIG_FRAME_POINTER # ifdef CONFIG_FRAME_POINTER
# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0)) # define ftrace_return_address(n) __builtin_return_address(n)
# 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 # else
# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0)) # define ftrace_return_address(n) 0UL
# 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
#endif /* ifndef HAVE_ARCH_CALLER_ADDR */ #endif
#define CALLER_ADDR0 ((unsigned long)ftrace_return_address0)
#define CALLER_ADDR1 ((unsigned long)ftrace_return_address(1))
#define CALLER_ADDR2 ((unsigned long)ftrace_return_address(2))
#define CALLER_ADDR3 ((unsigned long)ftrace_return_address(3))
#define CALLER_ADDR4 ((unsigned long)ftrace_return_address(4))
#define CALLER_ADDR5 ((unsigned long)ftrace_return_address(5))
#define CALLER_ADDR6 ((unsigned long)ftrace_return_address(6))
#ifdef CONFIG_IRQSOFF_TRACER #ifdef CONFIG_IRQSOFF_TRACER
extern void time_hardirqs_on(unsigned long a0, unsigned long a1); extern void time_hardirqs_on(unsigned long a0, unsigned long a1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment