diff mbox series

[2/6] MIPS: move FTRACE_SYSCALLS from ftrace.c into syscall.c

Message ID 20210313064149.29276-3-huangpei@loongson.cn (mailing list archive)
State New
Headers show
Series [1/6] MIPS: replace -pg with CC_FLAGS_FTRACE | expand

Commit Message

Huang Pei March 13, 2021, 6:41 a.m. UTC
Signed-off-by: Huang Pei <huangpei@loongson.cn>
---
 arch/mips/kernel/Makefile  |  1 -
 arch/mips/kernel/ftrace.c  | 33 ---------------------------------
 arch/mips/kernel/syscall.c | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 34 deletions(-)

Comments

Steven Rostedt March 25, 2021, 7:38 p.m. UTC | #1
On Sat, 13 Mar 2021 14:41:45 +0800
Huang Pei <huangpei@loongson.cn> wrote:

Why?

-- Steve

> Signed-off-by: Huang Pei <huangpei@loongson.cn>
> ---
>  arch/mips/kernel/Makefile  |  1 -
>  arch/mips/kernel/ftrace.c  | 33 ---------------------------------
>  arch/mips/kernel/syscall.c | 32 ++++++++++++++++++++++++++++++++
>  3 files changed, 32 insertions(+), 34 deletions(-)
Huang Pei March 26, 2021, 2:01 p.m. UTC | #2
I was intended to add -fpatchable-function-entry based new ftrace implementation in parallel 
with old -pg based one, which is enabled by supported gcc version at build time, since 

+. the fix for -fpatchable-function-entry is not merge into upstream; 

+. the -fpatchable-function-entry does not support static function tracing which is rarely used today, 
which is only implemented in the old -pg based implementation;

Move FTRACE_SYSCALLS into syscall.c, so both new and old implementation can easily be switched
freely. When everything is all right, old one can be easily removed, and that is patch 1/2/3 intended for

> On Mar 26, 2021, at 3:38 AM, Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> On Sat, 13 Mar 2021 14:41:45 +0800
> Huang Pei <huangpei@loongson.cn> wrote:
> 
> Why?
> 
> -- Steve
> 
>> Signed-off-by: Huang Pei <huangpei@loongson.cn>
>> ---
>> arch/mips/kernel/Makefile  |  1 -
>> arch/mips/kernel/ftrace.c  | 33 ---------------------------------
>> arch/mips/kernel/syscall.c | 32 ++++++++++++++++++++++++++++++++
>> 3 files changed, 32 insertions(+), 34 deletions(-)
diff mbox series

Patch

diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index 33e31ea10234..5b2b551058ac 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -39,7 +39,6 @@  obj-$(CONFIG_DEBUG_FS)		+= segment.o
 obj-$(CONFIG_STACKTRACE)	+= stacktrace.o
 obj-$(CONFIG_MODULES)		+= module.o
 
-obj-$(CONFIG_FTRACE_SYSCALLS)	+= ftrace.o
 obj-$(CONFIG_FUNCTION_TRACER)	+= mcount.o ftrace.o
 
 sw-y				:= r4k_switch.o
diff --git a/arch/mips/kernel/ftrace.c b/arch/mips/kernel/ftrace.c
index f57e68f40a34..5156b2e54bfe 100644
--- a/arch/mips/kernel/ftrace.c
+++ b/arch/mips/kernel/ftrace.c
@@ -12,14 +12,11 @@ 
 #include <linux/uaccess.h>
 #include <linux/init.h>
 #include <linux/ftrace.h>
-#include <linux/syscalls.h>
 
 #include <asm/asm.h>
 #include <asm/asm-offsets.h>
 #include <asm/cacheflush.h>
-#include <asm/syscall.h>
 #include <asm/uasm.h>
-#include <asm/unistd.h>
 
 #include <asm-generic/sections.h>
 
@@ -382,33 +379,3 @@  void prepare_ftrace_return(unsigned long *parent_ra_addr, unsigned long self_ra,
 	WARN_ON(1);
 }
 #endif	/* CONFIG_FUNCTION_GRAPH_TRACER */
-
-#ifdef CONFIG_FTRACE_SYSCALLS
-
-#ifdef CONFIG_32BIT
-unsigned long __init arch_syscall_addr(int nr)
-{
-	return (unsigned long)sys_call_table[nr - __NR_O32_Linux];
-}
-#endif
-
-#ifdef CONFIG_64BIT
-
-unsigned long __init arch_syscall_addr(int nr)
-{
-#ifdef CONFIG_MIPS32_N32
-	if (nr >= __NR_N32_Linux && nr < __NR_N32_Linux + __NR_N32_Linux_syscalls)
-		return (unsigned long)sysn32_call_table[nr - __NR_N32_Linux];
-#endif
-	if (nr >= __NR_64_Linux  && nr < __NR_64_Linux + __NR_64_Linux_syscalls)
-		return (unsigned long)sys_call_table[nr - __NR_64_Linux];
-#ifdef CONFIG_MIPS32_O32
-	if (nr >= __NR_O32_Linux && nr < __NR_O32_Linux + __NR_O32_Linux_syscalls)
-		return (unsigned long)sys32_call_table[nr - __NR_O32_Linux];
-#endif
-
-	return (unsigned long) &sys_ni_syscall;
-}
-#endif
-
-#endif /* CONFIG_FTRACE_SYSCALLS */
diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c
index 2afa3eef486a..797d9ce478da 100644
--- a/arch/mips/kernel/syscall.c
+++ b/arch/mips/kernel/syscall.c
@@ -39,7 +39,9 @@ 
 #include <asm/shmparam.h>
 #include <asm/sync.h>
 #include <asm/sysmips.h>
+#include <asm/syscall.h>
 #include <asm/switch_to.h>
+#include <asm/unistd.h>
 
 /*
  * For historic reasons the pipe(2) syscall on MIPS has an unusual calling
@@ -233,6 +235,36 @@  SYSCALL_DEFINE3(sysmips, long, cmd, long, arg1, long, arg2)
 	return -EINVAL;
 }
 
+#ifdef CONFIG_FTRACE_SYSCALLS
+
+#ifdef CONFIG_32BIT
+unsigned long __init arch_syscall_addr(int nr)
+{
+	return (unsigned long)sys_call_table[nr - __NR_O32_Linux];
+}
+#endif
+
+#ifdef CONFIG_64BIT
+
+unsigned long __init arch_syscall_addr(int nr)
+{
+#ifdef CONFIG_MIPS32_N32
+	if (nr >= __NR_N32_Linux && nr < __NR_N32_Linux + __NR_N32_Linux_syscalls)
+		return (unsigned long)sysn32_call_table[nr - __NR_N32_Linux];
+#endif
+	if (nr >= __NR_64_Linux  && nr < __NR_64_Linux + __NR_64_Linux_syscalls)
+		return (unsigned long)sys_call_table[nr - __NR_64_Linux];
+#ifdef CONFIG_MIPS32_O32
+	if (nr >= __NR_O32_Linux && nr < __NR_O32_Linux + __NR_O32_Linux_syscalls)
+		return (unsigned long)sys32_call_table[nr - __NR_O32_Linux];
+#endif
+
+	return (unsigned long) &sys_ni_syscall;
+}
+#endif
+
+#endif /* CONFIG_FTRACE_SYSCALLS */
+
 /*
  * No implemented yet ...
  */