diff options
author | AKASHI Takahiro <takahiro.akashi@linaro.org> | 2014-05-20 07:31:04 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2014-05-21 03:10:32 -0400 |
commit | eed542d6962ba33a689b4007a389f466e407bd74 (patch) | |
tree | d7ecb07cb30a0d4f20497fa6ef90d3829b4c701a | |
parent | d6d211db37e75de2ddc3a4f979038c40df7cc79c (diff) |
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.org
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | arch/arm/include/asm/ftrace.h | 10 | ||||
-rw-r--r-- | arch/blackfin/include/asm/ftrace.h | 11 | ||||
-rw-r--r-- | arch/parisc/include/asm/ftrace.h | 10 | ||||
-rw-r--r-- | arch/sh/include/asm/ftrace.h | 10 | ||||
-rw-r--r-- | arch/xtensa/include/asm/ftrace.h | 14 | ||||
-rw-r--r-- | include/linux/ftrace.h | 34 |
6 files changed, 26 insertions, 63 deletions
diff --git a/arch/arm/include/asm/ftrace.h b/arch/arm/include/asm/ftrace.h index f89515adac60..eb577f4f5f70 100644 --- a/arch/arm/include/asm/ftrace.h +++ b/arch/arm/include/asm/ftrace.h | |||
@@ -52,15 +52,7 @@ extern inline void *return_address(unsigned int level) | |||
52 | 52 | ||
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | #define HAVE_ARCH_CALLER_ADDR | 55 | #define ftrace_return_addr(n) return_address(n) |
56 | |||
57 | #define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0)) | ||
58 | #define CALLER_ADDR1 ((unsigned long)return_address(1)) | ||
59 | #define CALLER_ADDR2 ((unsigned long)return_address(2)) | ||
60 | #define CALLER_ADDR3 ((unsigned long)return_address(3)) | ||
61 | #define CALLER_ADDR4 ((unsigned long)return_address(4)) | ||
62 | #define CALLER_ADDR5 ((unsigned long)return_address(5)) | ||
63 | #define CALLER_ADDR6 ((unsigned long)return_address(6)) | ||
64 | 56 | ||
65 | #endif /* ifndef __ASSEMBLY__ */ | 57 | #endif /* ifndef __ASSEMBLY__ */ |
66 | 58 | ||
diff --git a/arch/blackfin/include/asm/ftrace.h b/arch/blackfin/include/asm/ftrace.h index 8a029505d7b7..2f1c3c2657ad 100644 --- a/arch/blackfin/include/asm/ftrace.h +++ b/arch/blackfin/include/asm/ftrace.h | |||
@@ -66,16 +66,7 @@ extern inline void *return_address(unsigned int level) | |||
66 | 66 | ||
67 | #endif /* CONFIG_FRAME_POINTER */ | 67 | #endif /* CONFIG_FRAME_POINTER */ |
68 | 68 | ||
69 | #define HAVE_ARCH_CALLER_ADDR | 69 | #define ftrace_return_address(n) return_address(n) |
70 | |||
71 | /* inline function or macro may lead to unexpected result */ | ||
72 | #define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0)) | ||
73 | #define CALLER_ADDR1 ((unsigned long)return_address(1)) | ||
74 | #define CALLER_ADDR2 ((unsigned long)return_address(2)) | ||
75 | #define CALLER_ADDR3 ((unsigned long)return_address(3)) | ||
76 | #define CALLER_ADDR4 ((unsigned long)return_address(4)) | ||
77 | #define CALLER_ADDR5 ((unsigned long)return_address(5)) | ||
78 | #define CALLER_ADDR6 ((unsigned long)return_address(6)) | ||
79 | 70 | ||
80 | #endif /* __ASSEMBLY__ */ | 71 | #endif /* __ASSEMBLY__ */ |
81 | 72 | ||
diff --git a/arch/parisc/include/asm/ftrace.h b/arch/parisc/include/asm/ftrace.h index 72c0fafaa039..544ed8ef87eb 100644 --- a/arch/parisc/include/asm/ftrace.h +++ b/arch/parisc/include/asm/ftrace.h | |||
@@ -24,15 +24,7 @@ extern void return_to_handler(void); | |||
24 | 24 | ||
25 | extern unsigned long return_address(unsigned int); | 25 | extern unsigned long return_address(unsigned int); |
26 | 26 | ||
27 | #define HAVE_ARCH_CALLER_ADDR | 27 | #define ftrace_return_address(n) return_address(n) |
28 | |||
29 | #define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0)) | ||
30 | #define CALLER_ADDR1 return_address(1) | ||
31 | #define CALLER_ADDR2 return_address(2) | ||
32 | #define CALLER_ADDR3 return_address(3) | ||
33 | #define CALLER_ADDR4 return_address(4) | ||
34 | #define CALLER_ADDR5 return_address(5) | ||
35 | #define CALLER_ADDR6 return_address(6) | ||
36 | 28 | ||
37 | #endif /* __ASSEMBLY__ */ | 29 | #endif /* __ASSEMBLY__ */ |
38 | 30 | ||
diff --git a/arch/sh/include/asm/ftrace.h b/arch/sh/include/asm/ftrace.h index 13e9966464c2..e79fb6ebaa42 100644 --- a/arch/sh/include/asm/ftrace.h +++ b/arch/sh/include/asm/ftrace.h | |||
@@ -40,15 +40,7 @@ static inline unsigned long ftrace_call_adjust(unsigned long addr) | |||
40 | /* arch/sh/kernel/return_address.c */ | 40 | /* arch/sh/kernel/return_address.c */ |
41 | extern void *return_address(unsigned int); | 41 | extern void *return_address(unsigned int); |
42 | 42 | ||
43 | #define HAVE_ARCH_CALLER_ADDR | 43 | #define ftrace_return_address(n) return_address(n) |
44 | |||
45 | #define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0)) | ||
46 | #define CALLER_ADDR1 ((unsigned long)return_address(1)) | ||
47 | #define CALLER_ADDR2 ((unsigned long)return_address(2)) | ||
48 | #define CALLER_ADDR3 ((unsigned long)return_address(3)) | ||
49 | #define CALLER_ADDR4 ((unsigned long)return_address(4)) | ||
50 | #define CALLER_ADDR5 ((unsigned long)return_address(5)) | ||
51 | #define CALLER_ADDR6 ((unsigned long)return_address(6)) | ||
52 | 44 | ||
53 | #endif /* __ASSEMBLY__ */ | 45 | #endif /* __ASSEMBLY__ */ |
54 | 46 | ||
diff --git a/arch/xtensa/include/asm/ftrace.h b/arch/xtensa/include/asm/ftrace.h index 736b9d214d80..6c6d9a9f185f 100644 --- a/arch/xtensa/include/asm/ftrace.h +++ b/arch/xtensa/include/asm/ftrace.h | |||
@@ -12,24 +12,18 @@ | |||
12 | 12 | ||
13 | #include <asm/processor.h> | 13 | #include <asm/processor.h> |
14 | 14 | ||
15 | #define HAVE_ARCH_CALLER_ADDR | ||
16 | #ifndef __ASSEMBLY__ | 15 | #ifndef __ASSEMBLY__ |
17 | #define CALLER_ADDR0 ({ unsigned long a0, a1; \ | 16 | #define ftrace_return_address0 ({ unsigned long a0, a1; \ |
18 | __asm__ __volatile__ ( \ | 17 | __asm__ __volatile__ ( \ |
19 | "mov %0, a0\n" \ | 18 | "mov %0, a0\n" \ |
20 | "mov %1, a1\n" \ | 19 | "mov %1, a1\n" \ |
21 | : "=r"(a0), "=r"(a1)); \ | 20 | : "=r"(a0), "=r"(a1)); \ |
22 | MAKE_PC_FROM_RA(a0, a1); }) | 21 | MAKE_PC_FROM_RA(a0, a1); }) |
22 | |||
23 | #ifdef CONFIG_FRAME_POINTER | 23 | #ifdef CONFIG_FRAME_POINTER |
24 | extern unsigned long return_address(unsigned level); | 24 | extern unsigned long return_address(unsigned level); |
25 | #define CALLER_ADDR1 return_address(1) | 25 | #define ftrace_return_address(n) return_address(n) |
26 | #define CALLER_ADDR2 return_address(2) | 26 | #endif |
27 | #define CALLER_ADDR3 return_address(3) | ||
28 | #else /* CONFIG_FRAME_POINTER */ | ||
29 | #define CALLER_ADDR1 (0) | ||
30 | #define CALLER_ADDR2 (0) | ||
31 | #define CALLER_ADDR3 (0) | ||
32 | #endif /* CONFIG_FRAME_POINTER */ | ||
33 | #endif /* __ASSEMBLY__ */ | 27 | #endif /* __ASSEMBLY__ */ |
34 | 28 | ||
35 | #ifdef CONFIG_FUNCTION_TRACER | 29 | #ifdef CONFIG_FUNCTION_TRACER |
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index ae9504b4b67d..2018751cad9e 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h | |||
@@ -616,25 +616,27 @@ static inline void __ftrace_enabled_restore(int enabled) | |||
616 | #endif | 616 | #endif |
617 | } | 617 | } |
618 | 618 | ||
619 | #ifndef HAVE_ARCH_CALLER_ADDR | 619 | /* All archs should have this, but we define it for consistency */ |
620 | #ifndef ftrace_return_address0 | ||
621 | # define ftrace_return_address0 __builtin_return_address(0) | ||
622 | #endif | ||
623 | |||
624 | /* Archs may use other ways for ADDR1 and beyond */ | ||
625 | #ifndef ftrace_return_address | ||
620 | # ifdef CONFIG_FRAME_POINTER | 626 | # ifdef CONFIG_FRAME_POINTER |
621 | # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0)) | 627 | # define ftrace_return_address(n) __builtin_return_address(n) |
622 | # define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1)) | ||
623 | # define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2)) | ||
624 | # define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3)) | ||
625 | # define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4)) | ||
626 | # define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5)) | ||
627 | # define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6)) | ||
628 | # else | 628 | # else |
629 | # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0)) | 629 | # define ftrace_return_address(n) 0UL |
630 | # define CALLER_ADDR1 0UL | ||
631 | # define CALLER_ADDR2 0UL | ||
632 | # define CALLER_ADDR3 0UL | ||
633 | # define CALLER_ADDR4 0UL | ||
634 | # define CALLER_ADDR5 0UL | ||
635 | # define CALLER_ADDR6 0UL | ||
636 | # endif | 630 | # endif |
637 | #endif /* ifndef HAVE_ARCH_CALLER_ADDR */ | 631 | #endif |
632 | |||
633 | #define CALLER_ADDR0 ((unsigned long)ftrace_return_address0) | ||
634 | #define CALLER_ADDR1 ((unsigned long)ftrace_return_address(1)) | ||
635 | #define CALLER_ADDR2 ((unsigned long)ftrace_return_address(2)) | ||
636 | #define CALLER_ADDR3 ((unsigned long)ftrace_return_address(3)) | ||
637 | #define CALLER_ADDR4 ((unsigned long)ftrace_return_address(4)) | ||
638 | #define CALLER_ADDR5 ((unsigned long)ftrace_return_address(5)) | ||
639 | #define CALLER_ADDR6 ((unsigned long)ftrace_return_address(6)) | ||
638 | 640 | ||
639 | #ifdef CONFIG_IRQSOFF_TRACER | 641 | #ifdef CONFIG_IRQSOFF_TRACER |
640 | extern void time_hardirqs_on(unsigned long a0, unsigned long a1); | 642 | extern void time_hardirqs_on(unsigned long a0, unsigned long a1); |