diff mbox

[for-next] ftrace: Make CALLER_ADDRx macros more generic

Message ID 20140527091019.54a8d2d6@gandalf.local.home (mailing list archive)
State New, archived
Headers show

Commit Message

Steven Rostedt May 27, 2014, 1:10 p.m. UTC
Will,

I made a separate branch called ftrace/arm64 as shown below. You can
pull that branch to base the rest of Akashi-san's patches on top of it.
The branch is based on top of v3.15-rc5.

-- Steve


  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
ftrace/arm64

Head SHA1: eed542d6962ba33a689b4007a389f466e407bd74


AKASHI Takahiro (1):
      ftrace: Make CALLER_ADDRx macros more generic

----
 arch/arm/include/asm/ftrace.h      | 10 +---------
 arch/blackfin/include/asm/ftrace.h | 11 +----------
 arch/parisc/include/asm/ftrace.h   | 10 +---------
 arch/sh/include/asm/ftrace.h       | 10 +---------
 arch/xtensa/include/asm/ftrace.h   | 14 ++++----------
 include/linux/ftrace.h             | 34 ++++++++++++++++++----------------
 6 files changed, 26 insertions(+), 63 deletions(-)
---------------------------
commit eed542d6962ba33a689b4007a389f466e407bd74
Author: AKASHI Takahiro <takahiro.akashi@linaro.org>
Date:   Tue May 20 20:31:04 2014 +0900

    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>

Comments

Will Deacon May 27, 2014, 6:49 p.m. UTC | #1
On Tue, May 27, 2014 at 02:10:19PM +0100, Steven Rostedt wrote:
> Will,
> 
> I made a separate branch called ftrace/arm64 as shown below. You can
> pull that branch to base the rest of Akashi-san's patches on top of it.
> The branch is based on top of v3.15-rc5.

Thanks Steve, I'll pull that in.

Akashi: please can you re-send your series, based on the branch below and
including the acks/reviewed-by tags you got for v6 of the patches?

Cheers,

Will

>   git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
> ftrace/arm64
> 
> Head SHA1: eed542d6962ba33a689b4007a389f466e407bd74
AKASHI Takahiro May 29, 2014, 5:27 a.m. UTC | #2
Hi Will

On 05/28/2014 03:49 AM, Will Deacon wrote:
> On Tue, May 27, 2014 at 02:10:19PM +0100, Steven Rostedt wrote:
>> Will,
>>
>> I made a separate branch called ftrace/arm64 as shown below. You can
>> pull that branch to base the rest of Akashi-san's patches on top of it.
>> The branch is based on top of v3.15-rc5.
>
> Thanks Steve, I'll pull that in.
>
> Akashi: please can you re-send your series, based on the branch below and
> including the acks/reviewed-by tags you got for v6 of the patches?

Sorry again to have missed your e-mail :-)
I'm sure that you can successfully apply all my patch series, without any
modification, from:
     v6 arm64: prerequisites for audit and ftrace
     v8 arm64: Add ftrace support
except for the patch, "[v8 1/8] ftrace: make CALLER_ADDRx macros more generic,"
which was replaced by a new version and already appears in Steven's repo.

Thank you,
-Takahiro AKASHI

> Cheers,
>
> Will
>
>>    git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
>> ftrace/arm64
>>
>> Head SHA1: eed542d6962ba33a689b4007a389f466e407bd74
Will Deacon May 29, 2014, 8:10 a.m. UTC | #3
On Thu, May 29, 2014 at 06:27:31AM +0100, AKASHI Takahiro wrote:
> Hi Will

Hi Akashi,

> On 05/28/2014 03:49 AM, Will Deacon wrote:
> > On Tue, May 27, 2014 at 02:10:19PM +0100, Steven Rostedt wrote:
> >> Will,
> >>
> >> I made a separate branch called ftrace/arm64 as shown below. You can
> >> pull that branch to base the rest of Akashi-san's patches on top of it.
> >> The branch is based on top of v3.15-rc5.
> >
> > Thanks Steve, I'll pull that in.
> >
> > Akashi: please can you re-send your series, based on the branch below and
> > including the acks/reviewed-by tags you got for v6 of the patches?
> 
> Sorry again to have missed your e-mail :-)

You should fix your filters!

> I'm sure that you can successfully apply all my patch series, without any
> modification, from:
>      v6 arm64: prerequisites for audit and ftrace
>      v8 arm64: Add ftrace support
> except for the patch, "[v8 1/8] ftrace: make CALLER_ADDRx macros more generic,"
> which was replaced by a new version and already appears in Steven's repo.

Yeah, you're right, I've managed to pick patches 2-8 from that posting --
thanks.

Will
diff mbox

Patch

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)
 
 #endif
 
-#define HAVE_ARCH_CALLER_ADDR
-
-#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))
+#define ftrace_return_addr(n) return_address(n)
 
 #endif /* ifndef __ASSEMBLY__ */
 
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)
 
 #endif /* CONFIG_FRAME_POINTER */
 
-#define HAVE_ARCH_CALLER_ADDR
-
-/* 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))
+#define ftrace_return_address(n) return_address(n)
 
 #endif /* __ASSEMBLY__ */
 
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);
 
 extern unsigned long return_address(unsigned int);
 
-#define HAVE_ARCH_CALLER_ADDR
-
-#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)
+#define ftrace_return_address(n) return_address(n)
 
 #endif /* __ASSEMBLY__ */
 
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)
 /* arch/sh/kernel/return_address.c */
 extern void *return_address(unsigned int);
 
-#define HAVE_ARCH_CALLER_ADDR
-
-#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))
+#define ftrace_return_address(n) return_address(n)
 
 #endif /* __ASSEMBLY__ */
 
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 @@ 
 
 #include <asm/processor.h>
 
-#define HAVE_ARCH_CALLER_ADDR
 #ifndef __ASSEMBLY__
-#define CALLER_ADDR0 ({ unsigned long a0, a1; \
+#define ftrace_return_address0 ({ unsigned long a0, a1; \
 		__asm__ __volatile__ ( \
 			"mov %0, a0\n" \
 			"mov %1, a1\n" \
 			: "=r"(a0), "=r"(a1)); \
 		MAKE_PC_FROM_RA(a0, a1); })
+
 #ifdef CONFIG_FRAME_POINTER
 extern unsigned long return_address(unsigned level);
-#define CALLER_ADDR1 return_address(1)
-#define CALLER_ADDR2 return_address(2)
-#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 */
+#define ftrace_return_address(n) return_address(n)
+#endif
 #endif /* __ASSEMBLY__ */
 
 #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)
 #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
-#  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))
+#  define ftrace_return_address(n) __builtin_return_address(n)
 # 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
+#  define ftrace_return_address(n) 0UL
 # 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
   extern void time_hardirqs_on(unsigned long a0, unsigned long a1);