From: takahiro.akashi@linaro.org (AKASHI Takahiro)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v8 1/8] ftrace: make CALLER_ADDRx macros more generic
Date: Tue, 20 May 2014 20:29:33 +0900 [thread overview]
Message-ID: <537B3C9D.3060008@linaro.org> (raw)
In-Reply-To: <20140502151957.6978d870@gandalf.local.home>
Hi Will, Steven,
So sorry, I completely missed this message thread. I will submit a new patch (replacement of [1/8])
in the following e-mail.
-Takahiro AKASHI
On 05/03/2014 04:19 AM, Steven Rostedt wrote:
> On Wed, 30 Apr 2014 18:54:29 +0900
> AKASHI Takahiro <takahiro.akashi@linaro.org> wrote:
>
>> Most archs with HAVE_ARCH_CALLER_ADDR have the almost same definitions
>> of CALLER_ADDRx(n), and so put them into linux/ftrace.h.
>
> Please add a bit more to the change log. Like what you did. Something
> like:
>
> ----
> 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.
> -----
>
> Use that if you want :-)
>
>
>>
>> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
>> ---
>> 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(-)
>>
>> diff --git a/arch/arm/include/asm/ftrace.h b/arch/arm/include/asm/ftrace.h
>> index f89515a..eb577f4 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 8a02950..2f1c3c2 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 72c0faf..544ed8e 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 13e9966..e79fb6e 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 736b9d2..6c6d9a9 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)
>
> I would add a comment here that states:
>
> /*
> * #else !CONFIG_FRAME_POINTER
> *
> * Define CALLER_ADDRn (n > 0) to 0 is the default in linux/ftrace.h if
> * ftrace_return_address(n) and CONFIG_FRAME_POINTER are not defined.
> */
>
> Otherwise it looks like you are missing the #else statement.
>
>> +#endif
>> #endif /* __ASSEMBLY__ */
>>
>> #ifdef CONFIG_FUNCTION_TRACER
>> diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
>> index 9212b01..18f1ae7 100644
>> --- a/include/linux/ftrace.h
>> +++ b/include/linux/ftrace.h
>> @@ -614,25 +614,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 */
>
> The comment is a little confusing. I think it may be better stated as:
>
> /*
> * All archs should be able to use __builtin_return_address(0) but
> * we allow them to redefine 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 */
>
> How about:
>
> /* Not all archs can use __builtin_return_address(n) where n > 0 */
>
>> +#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))
>
> Other than that, it looks good. You can send me the patch and I'll add
> it to my 3.16 queue.
>
> Feel free to reply to this email with a v9. When I pull patches into
> git, it adds the link to the thread for the patch in LKML. To keep this
> entire thread, just reply to it.
>
> Thanks!
>
> -- Steve
>
>>
>> #ifdef CONFIG_IRQSOFF_TRACER
>> extern void time_hardirqs_on(unsigned long a0, unsigned long a1);
>
next prev parent reply other threads:[~2014-05-20 11:29 UTC|newest]
Thread overview: 119+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-24 7:08 [PATCH v2 0/6] arm64: Add ftrace support AKASHI Takahiro
2013-10-24 7:08 ` [PATCH v2 1/6] " AKASHI Takahiro
2013-10-24 7:08 ` [PATCH v2 2/6] arm64: ftrace: Add dynamic " AKASHI Takahiro
2013-10-24 7:08 ` [PATCH v2 3/6] arm64: ftrace: Add CALLER_ADDRx macros AKASHI Takahiro
2013-10-24 7:08 ` [PATCH v2 4/6] ftrace: Add arm64 support to recordmcount AKASHI Takahiro
2013-10-24 7:08 ` [PATCH v2 5/6] arm64: ftrace: Add system call tracepoint AKASHI Takahiro
2013-10-24 7:08 ` [PATCH v2 6/6] arm64: Add 'notrace' attribute to unwind_frame() for ftrace AKASHI Takahiro
2014-02-07 10:18 ` [PATCH v3 0/6] arm64: Add ftrace support AKASHI Takahiro
2014-02-07 10:18 ` [PATCH v3 1/6] " AKASHI Takahiro
2014-02-10 15:03 ` Arnd Bergmann
2014-02-10 15:19 ` Steven Rostedt
[not found] ` <CAB5YjtCr2KL_q1FF8kO_VKe+feg7f9qFRKtwf3xj2h0ENwuB5g@mail.gmail.com>
2014-02-12 11:03 ` Arnd Bergmann
2014-02-17 18:12 ` Will Deacon
2014-02-19 10:46 ` AKASHI Takahiro
2014-02-07 10:18 ` [PATCH v3 2/6] arm64: ftrace: Add dynamic " AKASHI Takahiro
2014-02-07 10:18 ` [PATCH v3 3/6] arm64: ftrace: Add CALLER_ADDRx macros AKASHI Takahiro
2014-02-07 10:18 ` [PATCH v3 4/6] ftrace: Add arm64 support to recordmcount AKASHI Takahiro
2014-02-07 10:18 ` [PATCH v3 5/6] arm64: ftrace: Add system call tracepoint AKASHI Takahiro
2014-02-17 19:29 ` Will Deacon
2014-02-19 10:48 ` AKASHI Takahiro
2014-02-07 10:18 ` [PATCH v3 6/6] arm64: Add 'notrace' attribute to unwind_frame() for ftrace AKASHI Takahiro
2014-02-10 14:21 ` [PATCH v3 0/6] arm64: Add ftrace support Kulkarni, Ganapatrao
2014-02-25 9:23 ` [PATCH v4 0/7] " AKASHI Takahiro
2014-02-25 9:23 ` [PATCH v4 1/7] " AKASHI Takahiro
2014-02-25 15:38 ` Kulkarni, Ganapatrao
2014-02-28 5:06 ` AKASHI Takahiro
2014-02-25 9:23 ` [PATCH v4 2/7] arm64: ftrace: Add dynamic " AKASHI Takahiro
2014-02-25 9:23 ` [PATCH v4 3/7] arm64: ftrace: Add CALLER_ADDRx macros AKASHI Takahiro
2014-02-25 9:23 ` [PATCH v4 4/7] ftrace: Add arm64 support to recordmcount AKASHI Takahiro
2014-02-25 9:23 ` [PATCH v4 5/7] arm64: ftrace: Add system call tracepoint AKASHI Takahiro
2014-02-25 9:23 ` [PATCH v4 6/7] arm64: Add 'notrace' attribute to unwind_frame() for ftrace AKASHI Takahiro
2014-02-25 9:23 ` [PATCH v4 7/7] arm64: add __ASSEMBLY__ in asm/insn.h AKASHI Takahiro
2014-02-28 5:18 ` [PATCH v5 0/7] arm64: Add ftrace support AKASHI Takahiro
2014-02-28 5:18 ` [PATCH v5 1/7] " AKASHI Takahiro
2014-02-28 5:18 ` [PATCH v5 2/7] arm64: ftrace: Add dynamic " AKASHI Takahiro
2014-02-28 5:18 ` [PATCH v5 3/7] arm64: ftrace: Add CALLER_ADDRx macros AKASHI Takahiro
2014-02-28 5:18 ` [PATCH v5 4/7] ftrace: Add arm64 support to recordmcount AKASHI Takahiro
2014-02-28 5:18 ` [PATCH v5 5/7] arm64: ftrace: Add system call tracepoint AKASHI Takahiro
2014-02-28 5:18 ` [PATCH v5 6/7] arm64: Add 'notrace' attribute to unwind_frame() for ftrace AKASHI Takahiro
2014-02-28 5:18 ` [PATCH v5 7/7] arm64: add __ASSEMBLY__ in asm/insn.h AKASHI Takahiro
2014-03-11 14:35 ` [PATCH v5 0/7] arm64: Add ftrace support Will Deacon
2014-03-12 1:47 ` AKASHI Takahiro
2014-03-12 1:58 ` Steven Rostedt
2014-03-12 2:02 ` Steven Rostedt
2014-03-13 10:13 ` [PATCH v6 " AKASHI Takahiro
2014-03-13 10:13 ` [PATCH v6 1/7] arm64: add __ASSEMBLY__ in asm/insn.h AKASHI Takahiro
2014-03-13 12:19 ` Will Deacon
2014-03-13 10:13 ` [PATCH v6 2/7] arm64: Add 'notrace' attribute to unwind_frame() for ftrace AKASHI Takahiro
2014-03-13 12:19 ` Will Deacon
2014-03-13 10:13 ` [PATCH v6 3/7] ftrace: Add arm64 support to recordmcount AKASHI Takahiro
2014-03-13 12:38 ` Will Deacon
2014-03-13 14:57 ` AKASHI Takahiro
2014-03-13 16:05 ` Will Deacon
2014-03-13 10:13 ` [PATCH v6 4/7] arm64: Add ftrace support AKASHI Takahiro
2014-03-13 17:08 ` Will Deacon
2014-03-13 18:27 ` Steven Rostedt
2014-03-13 18:37 ` Will Deacon
2014-03-13 18:49 ` Steven Rostedt
2014-03-14 4:45 ` AKASHI Takahiro
2014-03-14 10:07 ` Will Deacon
2014-03-14 16:13 ` AKASHI Takahiro
2014-03-13 10:13 ` [PATCH v6 5/7] arm64: ftrace: Add dynamic " AKASHI Takahiro
2014-03-13 18:10 ` Will Deacon
2014-03-13 18:33 ` Steven Rostedt
2014-03-14 5:28 ` AKASHI Takahiro
2014-03-14 5:26 ` AKASHI Takahiro
2014-03-13 10:13 ` [PATCH v6 6/7] arm64: ftrace: Add CALLER_ADDRx macros AKASHI Takahiro
2014-03-13 15:54 ` Will Deacon
2014-03-13 18:07 ` Steven Rostedt
2014-03-14 4:55 ` AKASHI Takahiro
2014-03-14 3:00 ` AKASHI Takahiro
2014-03-14 10:09 ` Will Deacon
2014-03-14 16:15 ` AKASHI Takahiro
2014-03-13 10:13 ` [PATCH v6 7/7] arm64: ftrace: Add system call tracepoint AKASHI Takahiro
2014-03-13 16:25 ` Will Deacon
2014-03-14 3:50 ` AKASHI Takahiro
2014-03-15 5:40 ` [PATCH v7 0/7] arm64: Add ftrace support AKASHI Takahiro
2014-03-15 5:40 ` [PATCH v7 1/7] arm64: add __ASSEMBLY__ in asm/insn.h AKASHI Takahiro
2014-03-15 5:40 ` [PATCH v7 2/7] arm64: Add 'notrace' attribute to unwind_frame() for ftrace AKASHI Takahiro
2014-03-15 5:40 ` [PATCH v7 3/7] ftrace: Add arm64 support to recordmcount AKASHI Takahiro
2014-04-16 13:31 ` Will Deacon
2014-04-30 9:54 ` [PATCH v8 0/8] arm64: Add ftrace support AKASHI Takahiro
2014-04-30 9:54 ` [PATCH v8 1/8] ftrace: make CALLER_ADDRx macros more generic AKASHI Takahiro
2014-05-02 18:13 ` Will Deacon
2014-05-02 19:02 ` Steven Rostedt
2014-05-02 19:03 ` Steven Rostedt
2014-05-02 19:19 ` Steven Rostedt
2014-05-12 15:58 ` Will Deacon
2014-05-12 16:05 ` Steven Rostedt
2014-05-12 16:12 ` Will Deacon
2014-05-12 17:23 ` Steven Rostedt
2014-05-20 11:29 ` AKASHI Takahiro [this message]
2014-05-20 11:31 ` [PATCH v8_1] " AKASHI Takahiro
2014-06-11 12:34 ` [PATCH v8 1/8] " Geert Uytterhoeven
2014-06-11 13:23 ` [PATCH] arm/ftrace: Fix function_return_addr() to function_return_address() Steven Rostedt
2014-06-11 13:38 ` Geert Uytterhoeven
2014-06-11 13:44 ` Steven Rostedt
2014-04-30 9:54 ` [PATCH v8 2/8] arm64: add __ASSEMBLY__ in asm/insn.h AKASHI Takahiro
2014-04-30 9:54 ` [PATCH v8 3/8] arm64: Add 'notrace' attribute to unwind_frame() for ftrace AKASHI Takahiro
2014-04-30 9:54 ` [PATCH v8 4/8] ftrace: Add arm64 support to recordmcount AKASHI Takahiro
2014-04-30 9:54 ` [PATCH v8 5/8] arm64: Add ftrace support AKASHI Takahiro
2014-05-28 20:19 ` Mark Brown
2014-05-29 8:07 ` Will Deacon
2014-05-29 9:47 ` Mark Brown
2014-04-30 9:54 ` [PATCH v8 6/8] arm64: ftrace: Add dynamic " AKASHI Takahiro
2014-04-30 9:54 ` [PATCH v8 7/8] arm64: ftrace: Add CALLER_ADDRx macros AKASHI Takahiro
2014-04-30 9:54 ` [PATCH v8 8/8] arm64: ftrace: Add system call tracepoint AKASHI Takahiro
2014-03-15 5:45 ` [PATCH v7 4/7] arm64: Add ftrace support AKASHI Takahiro
2014-04-16 13:45 ` Will Deacon
2014-03-15 5:45 ` [PATCH v7 5/7] arm64: ftrace: Add dynamic " AKASHI Takahiro
2014-04-16 13:48 ` Will Deacon
2014-03-15 5:45 ` [PATCH v7 6/7] arm64: ftrace: Add CALLER_ADDRx macros AKASHI Takahiro
2014-04-16 13:52 ` Will Deacon
2014-04-28 10:41 ` AKASHI Takahiro
2014-05-27 13:10 ` [for-next][PATCH] ftrace: Make CALLER_ADDRx macros more generic Steven Rostedt
2014-05-27 18:49 ` Will Deacon
2014-05-29 5:27 ` AKASHI Takahiro
2014-05-29 8:10 ` Will Deacon
2014-03-15 5:45 ` [PATCH v7 7/7] arm64: ftrace: Add system call tracepoint AKASHI Takahiro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=537B3C9D.3060008@linaro.org \
--to=takahiro.akashi@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).