* [PATCH 1/1] fentry: x86, cleanup function_hook uses
@ 2017-03-15 13:44 Jiri Slaby
2017-03-15 15:40 ` Steven Rostedt
0 siblings, 1 reply; 7+ messages in thread
From: Jiri Slaby @ 2017-03-15 13:44 UTC (permalink / raw)
To: mingo
Cc: linux-kernel, Jiri Slaby, Thomas Gleixner, H. Peter Anvin, x86,
Steven Rostedt, Frederic Weisbecker
Let's define fentry_hook depending on CC_USING_FENTRY and use that
macro over the users. This saves some #ifdef's in the assembly and
headers.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: <x86@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
---
arch/x86/include/asm/ftrace.h | 11 +++++------
arch/x86/include/asm/function_hook.h | 14 ++++++++++++++
arch/x86/kernel/mcount_64.S | 10 ++--------
3 files changed, 21 insertions(+), 14 deletions(-)
create mode 100644 arch/x86/include/asm/function_hook.h
diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h
index eccd0ac6bc38..2bfbc6b7b45f 100644
--- a/arch/x86/include/asm/ftrace.h
+++ b/arch/x86/include/asm/ftrace.h
@@ -2,12 +2,13 @@
#define _ASM_X86_FTRACE_H
#ifdef CONFIG_FUNCTION_TRACER
-#ifdef CC_USING_FENTRY
-# define MCOUNT_ADDR ((unsigned long)(__fentry__))
-#else
-# define MCOUNT_ADDR ((unsigned long)(mcount))
+#ifndef CC_USING_FENTRY
# define HAVE_FUNCTION_GRAPH_FP_TEST
#endif
+
+#include <asm/function_hook.h>
+
+#define MCOUNT_ADDR ((unsigned long)(function_hook))
#define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */
#ifdef CONFIG_DYNAMIC_FTRACE
@@ -17,9 +18,7 @@
#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
#ifndef __ASSEMBLY__
-extern void mcount(void);
extern atomic_t modifying_ftrace_code;
-extern void __fentry__(void);
static inline unsigned long ftrace_call_adjust(unsigned long addr)
{
diff --git a/arch/x86/include/asm/function_hook.h b/arch/x86/include/asm/function_hook.h
new file mode 100644
index 000000000000..9cc6c62efc8e
--- /dev/null
+++ b/arch/x86/include/asm/function_hook.h
@@ -0,0 +1,14 @@
+#ifndef ASM_FENTRY_H
+#define ASM_FENTRY_H
+
+#ifdef CC_USING_FENTRY
+# define function_hook __fentry__
+#else
+# define function_hook mcount
+#endif
+
+#ifndef __ASSEMBLY__
+extern void function_hook(void);
+#endif /* __ASSEMBLY__ */
+
+#endif /* ASM_FENTRY_H */
diff --git a/arch/x86/kernel/mcount_64.S b/arch/x86/kernel/mcount_64.S
index 7b0d3da52fb4..fb27f2f44513 100644
--- a/arch/x86/kernel/mcount_64.S
+++ b/arch/x86/kernel/mcount_64.S
@@ -7,6 +7,7 @@
#include <linux/linkage.h>
#include <asm/ptrace.h>
#include <asm/ftrace.h>
+#include <asm/function_hook.h>
#include <asm/export.h>
@@ -16,14 +17,6 @@
#ifdef CONFIG_FUNCTION_TRACER
-#ifdef CC_USING_FENTRY
-# define function_hook __fentry__
-EXPORT_SYMBOL(__fentry__)
-#else
-# define function_hook mcount
-EXPORT_SYMBOL(mcount)
-#endif
-
/* All cases save the original rbp (8 bytes) */
#ifdef CONFIG_FRAME_POINTER
# ifdef CC_USING_FENTRY
@@ -297,6 +290,7 @@ trace:
jmp fgraph_trace
END(function_hook)
#endif /* CONFIG_DYNAMIC_FTRACE */
+EXPORT_SYMBOL(function_hook)
#endif /* CONFIG_FUNCTION_TRACER */
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
--
2.12.0
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH 1/1] fentry: x86, cleanup function_hook uses
2017-03-15 13:44 [PATCH 1/1] fentry: x86, cleanup function_hook uses Jiri Slaby
@ 2017-03-15 15:40 ` Steven Rostedt
2017-03-15 15:49 ` Jiri Slaby
0 siblings, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2017-03-15 15:40 UTC (permalink / raw)
To: Jiri Slaby
Cc: mingo, linux-kernel, Thomas Gleixner, H. Peter Anvin, x86,
Frederic Weisbecker
On Wed, 15 Mar 2017 14:44:36 +0100
Jiri Slaby <jslaby@suse.cz> wrote:
> @@ -16,14 +17,6 @@
>
> #ifdef CONFIG_FUNCTION_TRACER
>
> -#ifdef CC_USING_FENTRY
> -# define function_hook __fentry__
> -EXPORT_SYMBOL(__fentry__)
There's a reason the export symbols are here.
> -#else
> -# define function_hook mcount
> -EXPORT_SYMBOL(mcount)
> -#endif
> -
> /* All cases save the original rbp (8 bytes) */
> #ifdef CONFIG_FRAME_POINTER
> # ifdef CC_USING_FENTRY
> @@ -297,6 +290,7 @@ trace:
> jmp fgraph_trace
> END(function_hook)
> #endif /* CONFIG_DYNAMIC_FTRACE */
> +EXPORT_SYMBOL(function_hook)
Under certain configs, this will fail the build. EXPORT_SYMBOL() does
not take the function_hook as a macro nicely. See commit 5de0a8c0c24033.
-- Steve
> #endif /* CONFIG_FUNCTION_TRACER */
>
> #ifdef CONFIG_FUNCTION_GRAPH_TRACER
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/1] fentry: x86, cleanup function_hook uses
2017-03-15 15:40 ` Steven Rostedt
@ 2017-03-15 15:49 ` Jiri Slaby
2017-03-15 15:58 ` Steven Rostedt
0 siblings, 1 reply; 7+ messages in thread
From: Jiri Slaby @ 2017-03-15 15:49 UTC (permalink / raw)
To: Steven Rostedt
Cc: mingo, linux-kernel, Thomas Gleixner, H. Peter Anvin, x86,
Frederic Weisbecker
On 03/15/2017, 04:40 PM, Steven Rostedt wrote:
>> -#else
>> -# define function_hook mcount
>> -EXPORT_SYMBOL(mcount)
>> -#endif
>> -
>> /* All cases save the original rbp (8 bytes) */
>> #ifdef CONFIG_FRAME_POINTER
>> # ifdef CC_USING_FENTRY
>> @@ -297,6 +290,7 @@ trace:
>> jmp fgraph_trace
>> END(function_hook)
>> #endif /* CONFIG_DYNAMIC_FTRACE */
>> +EXPORT_SYMBOL(function_hook)
>
> Under certain configs, this will fail the build. EXPORT_SYMBOL() does
> not take the function_hook as a macro nicely. See commit 5de0a8c0c24033.
Ok, thanks, forget about it then. I had the patch in my tree since Feb 3
2014, so I can finally drop it...
--
js
suse labs
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/1] fentry: x86, cleanup function_hook uses
2017-03-15 15:49 ` Jiri Slaby
@ 2017-03-15 15:58 ` Steven Rostedt
2017-03-15 16:08 ` Jiri Slaby
0 siblings, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2017-03-15 15:58 UTC (permalink / raw)
To: Jiri Slaby
Cc: mingo, linux-kernel, Thomas Gleixner, H. Peter Anvin, x86,
Frederic Weisbecker
On Wed, 15 Mar 2017 16:49:54 +0100
Jiri Slaby <jslaby@suse.cz> wrote:
> On 03/15/2017, 04:40 PM, Steven Rostedt wrote:
> >> -#else
> >> -# define function_hook mcount
> >> -EXPORT_SYMBOL(mcount)
> >> -#endif
> >> -
> >> /* All cases save the original rbp (8 bytes) */
> >> #ifdef CONFIG_FRAME_POINTER
> >> # ifdef CC_USING_FENTRY
> >> @@ -297,6 +290,7 @@ trace:
> >> jmp fgraph_trace
> >> END(function_hook)
> >> #endif /* CONFIG_DYNAMIC_FTRACE */
> >> +EXPORT_SYMBOL(function_hook)
> >
> > Under certain configs, this will fail the build. EXPORT_SYMBOL() does
> > not take the function_hook as a macro nicely. See commit 5de0a8c0c24033.
>
> Ok, thanks, forget about it then. I had the patch in my tree since Feb 3
> 2014, so I can finally drop it...
>
>
Great, cause I'm currently cleaning up that code too, and this would
cause conflicts ;-)
-- Steve
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/1] fentry: x86, cleanup function_hook uses
2017-03-15 15:58 ` Steven Rostedt
@ 2017-03-15 16:08 ` Jiri Slaby
0 siblings, 0 replies; 7+ messages in thread
From: Jiri Slaby @ 2017-03-15 16:08 UTC (permalink / raw)
To: Steven Rostedt
Cc: mingo, linux-kernel, Thomas Gleixner, H. Peter Anvin, x86,
Frederic Weisbecker
On 03/15/2017, 04:58 PM, Steven Rostedt wrote:
> Great, cause I'm currently cleaning up that code too, and this would
> cause conflicts ;-)
Then I should hide right after I send out v2 of the macros cleanup
series in a couple of minutes, right ;)?
https://patchwork.kernel.org/patch/9579623/
--
js
suse labs
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/1] fentry: x86, cleanup function_hook uses
@ 2015-10-06 12:40 Jiri Slaby
2015-10-20 19:02 ` Steven Rostedt
0 siblings, 1 reply; 7+ messages in thread
From: Jiri Slaby @ 2015-10-06 12:40 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Jiri Slaby, Thomas Gleixner, H. Peter Anvin, x86,
Steven Rostedt, Frederic Weisbecker
Let's define fentry_hook depending on CC_USING_FENTRY and use that
macro all over. This saves some #ifdef's here and there.
We do not use the old macro function_hook since it is too generic.
Hence we introduce fentry_hook which corresponds to what it is.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: <x86@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
---
arch/x86/include/asm/fentry.h | 14 ++++++++++++++
arch/x86/include/asm/ftrace.h | 11 ++++-------
arch/x86/kernel/mcount_64.S | 15 +++++----------
arch/x86/kernel/x8664_ksyms_64.c | 8 ++------
4 files changed, 25 insertions(+), 23 deletions(-)
create mode 100644 arch/x86/include/asm/fentry.h
diff --git a/arch/x86/include/asm/fentry.h b/arch/x86/include/asm/fentry.h
new file mode 100644
index 000000000000..febe8d272f0f
--- /dev/null
+++ b/arch/x86/include/asm/fentry.h
@@ -0,0 +1,14 @@
+#ifndef ASM_FENTRY_H
+#define ASM_FENTRY_H
+
+#ifdef CC_USING_FENTRY
+# define fentry_hook __fentry__
+#else
+# define fentry_hook mcount
+#endif
+
+#ifndef __ASSEMBLY__
+extern void fentry_hook(void);
+#endif /* __ASSEMBLY__ */
+
+#endif /* ASM_FENTRY_H */
diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h
index 24938852db30..dc235b3659da 100644
--- a/arch/x86/include/asm/ftrace.h
+++ b/arch/x86/include/asm/ftrace.h
@@ -2,11 +2,10 @@
#define _ASM_X86_FTRACE_H
#ifdef CONFIG_FUNCTION_TRACER
-#ifdef CC_USING_FENTRY
-# define MCOUNT_ADDR ((unsigned long)(__fentry__))
-#else
-# define MCOUNT_ADDR ((unsigned long)(mcount))
-#endif
+
+#include <asm/fentry.h>
+
+#define MCOUNT_ADDR ((unsigned long)(fentry_hook))
#define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */
#ifdef CONFIG_DYNAMIC_FTRACE
@@ -14,9 +13,7 @@
#endif
#ifndef __ASSEMBLY__
-extern void mcount(void);
extern atomic_t modifying_ftrace_code;
-extern void __fentry__(void);
static inline unsigned long ftrace_call_adjust(unsigned long addr)
{
diff --git a/arch/x86/kernel/mcount_64.S b/arch/x86/kernel/mcount_64.S
index 94ea120fa21f..ac8d5296d6ec 100644
--- a/arch/x86/kernel/mcount_64.S
+++ b/arch/x86/kernel/mcount_64.S
@@ -6,6 +6,7 @@
#include <linux/linkage.h>
#include <asm/ptrace.h>
+#include <asm/fentry.h>
#include <asm/ftrace.h>
@@ -15,12 +16,6 @@
#ifdef CONFIG_FUNCTION_TRACER
-#ifdef CC_USING_FENTRY
-# define function_hook __fentry__
-#else
-# define function_hook mcount
-#endif
-
/* All cases save the original rbp (8 bytes) */
#ifdef CONFIG_FRAME_POINTER
# ifdef CC_USING_FENTRY
@@ -147,9 +142,9 @@
#ifdef CONFIG_DYNAMIC_FTRACE
-ENTRY(function_hook)
+ENTRY(fentry_hook)
retq
-END(function_hook)
+END(fentry_hook)
ENTRY(ftrace_caller)
/* save_mcount_regs fills in first two parameters */
@@ -258,7 +253,7 @@ END(ftrace_regs_caller)
#else /* ! CONFIG_DYNAMIC_FTRACE */
-ENTRY(function_hook)
+ENTRY(fentry_hook)
cmpq $ftrace_stub, ftrace_trace_function
jnz trace
@@ -283,7 +278,7 @@ trace:
restore_mcount_regs
jmp fgraph_trace
-END(function_hook)
+END(fentry_hook)
#endif /* CONFIG_DYNAMIC_FTRACE */
#endif /* CONFIG_FUNCTION_TRACER */
diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
index a0695be19864..5607abc110c7 100644
--- a/arch/x86/kernel/x8664_ksyms_64.c
+++ b/arch/x86/kernel/x8664_ksyms_64.c
@@ -10,15 +10,11 @@
#include <asm/pgtable.h>
#include <asm/uaccess.h>
#include <asm/desc.h>
-#include <asm/ftrace.h>
+#include <asm/fentry.h>
#ifdef CONFIG_FUNCTION_TRACER
/* mcount and __fentry__ are defined in assembly */
-#ifdef CC_USING_FENTRY
-EXPORT_SYMBOL(__fentry__);
-#else
-EXPORT_SYMBOL(mcount);
-#endif
+EXPORT_SYMBOL(fentry_hook);
#endif
EXPORT_SYMBOL(__get_user_1);
--
2.6.1
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH 1/1] fentry: x86, cleanup function_hook uses
2015-10-06 12:40 Jiri Slaby
@ 2015-10-20 19:02 ` Steven Rostedt
0 siblings, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2015-10-20 19:02 UTC (permalink / raw)
To: Jiri Slaby
Cc: Ingo Molnar, linux-kernel, Thomas Gleixner, H. Peter Anvin, x86,
Frederic Weisbecker
On Tue, 6 Oct 2015 14:40:21 +0200
Jiri Slaby <jslaby@suse.cz> wrote:
> Let's define fentry_hook depending on CC_USING_FENTRY and use that
> macro all over. This saves some #ifdef's here and there.
>
> We do not use the old macro function_hook since it is too generic.
> Hence we introduce fentry_hook which corresponds to what it is.
Actually, I think I like function_hook better that fentry_hook, because
mcount is not an fentry.
What else do you think could be used as "function_hook"?
-- Steve
>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: <x86@kernel.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Ingo Molnar <mingo@redhat.com>
> ---
> arch/x86/include/asm/fentry.h | 14 ++++++++++++++
> arch/x86/include/asm/ftrace.h | 11 ++++-------
> arch/x86/kernel/mcount_64.S | 15 +++++----------
> arch/x86/kernel/x8664_ksyms_64.c | 8 ++------
> 4 files changed, 25 insertions(+), 23 deletions(-)
> create mode 100644 arch/x86/include/asm/fentry.h
>
> diff --git a/arch/x86/include/asm/fentry.h b/arch/x86/include/asm/fentry.h
> new file mode 100644
> index 000000000000..febe8d272f0f
> --- /dev/null
> +++ b/arch/x86/include/asm/fentry.h
> @@ -0,0 +1,14 @@
> +#ifndef ASM_FENTRY_H
> +#define ASM_FENTRY_H
> +
> +#ifdef CC_USING_FENTRY
> +# define fentry_hook __fentry__
> +#else
> +# define fentry_hook mcount
> +#endif
> +
> +#ifndef __ASSEMBLY__
> +extern void fentry_hook(void);
> +#endif /* __ASSEMBLY__ */
> +
> +#endif /* ASM_FENTRY_H */
> diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h
> index 24938852db30..dc235b3659da 100644
> --- a/arch/x86/include/asm/ftrace.h
> +++ b/arch/x86/include/asm/ftrace.h
> @@ -2,11 +2,10 @@
> #define _ASM_X86_FTRACE_H
>
> #ifdef CONFIG_FUNCTION_TRACER
> -#ifdef CC_USING_FENTRY
> -# define MCOUNT_ADDR ((unsigned long)(__fentry__))
> -#else
> -# define MCOUNT_ADDR ((unsigned long)(mcount))
> -#endif
> +
> +#include <asm/fentry.h>
> +
> +#define MCOUNT_ADDR ((unsigned long)(fentry_hook))
> #define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */
>
> #ifdef CONFIG_DYNAMIC_FTRACE
> @@ -14,9 +13,7 @@
> #endif
>
> #ifndef __ASSEMBLY__
> -extern void mcount(void);
> extern atomic_t modifying_ftrace_code;
> -extern void __fentry__(void);
>
> static inline unsigned long ftrace_call_adjust(unsigned long addr)
> {
> diff --git a/arch/x86/kernel/mcount_64.S b/arch/x86/kernel/mcount_64.S
> index 94ea120fa21f..ac8d5296d6ec 100644
> --- a/arch/x86/kernel/mcount_64.S
> +++ b/arch/x86/kernel/mcount_64.S
> @@ -6,6 +6,7 @@
>
> #include <linux/linkage.h>
> #include <asm/ptrace.h>
> +#include <asm/fentry.h>
> #include <asm/ftrace.h>
>
>
> @@ -15,12 +16,6 @@
>
> #ifdef CONFIG_FUNCTION_TRACER
>
> -#ifdef CC_USING_FENTRY
> -# define function_hook __fentry__
> -#else
> -# define function_hook mcount
> -#endif
> -
> /* All cases save the original rbp (8 bytes) */
> #ifdef CONFIG_FRAME_POINTER
> # ifdef CC_USING_FENTRY
> @@ -147,9 +142,9 @@
>
> #ifdef CONFIG_DYNAMIC_FTRACE
>
> -ENTRY(function_hook)
> +ENTRY(fentry_hook)
> retq
> -END(function_hook)
> +END(fentry_hook)
>
> ENTRY(ftrace_caller)
> /* save_mcount_regs fills in first two parameters */
> @@ -258,7 +253,7 @@ END(ftrace_regs_caller)
>
> #else /* ! CONFIG_DYNAMIC_FTRACE */
>
> -ENTRY(function_hook)
> +ENTRY(fentry_hook)
> cmpq $ftrace_stub, ftrace_trace_function
> jnz trace
>
> @@ -283,7 +278,7 @@ trace:
> restore_mcount_regs
>
> jmp fgraph_trace
> -END(function_hook)
> +END(fentry_hook)
> #endif /* CONFIG_DYNAMIC_FTRACE */
> #endif /* CONFIG_FUNCTION_TRACER */
>
> diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
> index a0695be19864..5607abc110c7 100644
> --- a/arch/x86/kernel/x8664_ksyms_64.c
> +++ b/arch/x86/kernel/x8664_ksyms_64.c
> @@ -10,15 +10,11 @@
> #include <asm/pgtable.h>
> #include <asm/uaccess.h>
> #include <asm/desc.h>
> -#include <asm/ftrace.h>
> +#include <asm/fentry.h>
>
> #ifdef CONFIG_FUNCTION_TRACER
> /* mcount and __fentry__ are defined in assembly */
> -#ifdef CC_USING_FENTRY
> -EXPORT_SYMBOL(__fentry__);
> -#else
> -EXPORT_SYMBOL(mcount);
> -#endif
> +EXPORT_SYMBOL(fentry_hook);
> #endif
>
> EXPORT_SYMBOL(__get_user_1);
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-03-15 16:09 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-15 13:44 [PATCH 1/1] fentry: x86, cleanup function_hook uses Jiri Slaby
2017-03-15 15:40 ` Steven Rostedt
2017-03-15 15:49 ` Jiri Slaby
2017-03-15 15:58 ` Steven Rostedt
2017-03-15 16:08 ` Jiri Slaby
-- strict thread matches above, loose matches on Subject: below --
2015-10-06 12:40 Jiri Slaby
2015-10-20 19:02 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®