Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1601409 > unrolled thread

[PATCH 1/1] fentry: x86, cleanup function_hook uses

Started byJiri Slaby <jslaby@suse.cz>
First post2017-03-15 14:50 +0100
Last post2017-03-15 17:00 +0100
Articles 5 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/1] fentry: x86, cleanup function_hook uses Jiri Slaby <jslaby@suse.cz> - 2017-03-15 14:50 +0100
    Re: [PATCH 1/1] fentry: x86, cleanup function_hook uses Steven Rostedt <rostedt@goodmis.org> - 2017-03-15 16:50 +0100
      Re: [PATCH 1/1] fentry: x86, cleanup function_hook uses Steven Rostedt <rostedt@goodmis.org> - 2017-03-15 17:00 +0100
        Re: [PATCH 1/1] fentry: x86, cleanup function_hook uses Jiri Slaby <jslaby@suse.cz> - 2017-03-15 17:20 +0100
      Re: [PATCH 1/1] fentry: x86, cleanup function_hook uses Jiri Slaby <jslaby@suse.cz> - 2017-03-15 17:00 +0100

#1601409 — [PATCH 1/1] fentry: x86, cleanup function_hook uses

FromJiri Slaby <jslaby@suse.cz>
Date2017-03-15 14:50 +0100
Subject[PATCH 1/1] fentry: x86, cleanup function_hook uses
Message-ID<tlhtn-8mr-5@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1601500

FromSteven Rostedt <rostedt@goodmis.org>
Date2017-03-15 16:50 +0100
Message-ID<tljlw-1aZ-21@gated-at.bofh.it>
In reply to#1601409
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

[toc] | [prev] | [next] | [standalone]


#1601505

FromSteven Rostedt <rostedt@goodmis.org>
Date2017-03-15 17:00 +0100
Message-ID<tljvc-1eE-3@gated-at.bofh.it>
In reply to#1601500
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

[toc] | [prev] | [next] | [standalone]


#1601519

FromJiri Slaby <jslaby@suse.cz>
Date2017-03-15 17:20 +0100
Message-ID<tljOy-1CE-17@gated-at.bofh.it>
In reply to#1601505
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

[toc] | [prev] | [next] | [standalone]


#1601510

FromJiri Slaby <jslaby@suse.cz>
Date2017-03-15 17:00 +0100
Message-ID<tljvc-1eE-5@gated-at.bofh.it>
In reply to#1601500
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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web