From: Jiri Slaby <jslaby@suse.cz>
To: Ingo Molnar <mingo@redhat.com>
Cc: linux-kernel@vger.kernel.org, Jiri Slaby <jslaby@suse.cz>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, Steven Rostedt <rostedt@goodmis.org>,
Frederic Weisbecker <fweisbec@gmail.com>
Subject: [PATCH 1/1] fentry: x86, cleanup function_hook uses
Date: Tue, 6 Oct 2015 14:40:21 +0200 [thread overview]
Message-ID: <1444135221-13306-1-git-send-email-jslaby@suse.cz> (raw)
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
next reply other threads:[~2015-10-06 12:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-06 12:40 Jiri Slaby [this message]
2015-10-20 19:02 ` Steven Rostedt
2017-03-15 13:44 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
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=1444135221-13306-1-git-send-email-jslaby@suse.cz \
--to=jslaby@suse.cz \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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
all inboxes | Powered by JetHome®