From: Chengming Zhou <zhouchengming@bytedance.com> To: rostedt@goodmis.org, mark.rutland@arm.com, mingo@redhat.com, tglx@linutronix.de, catalin.marinas@arm.com, will@kernel.org, dave.hansen@linux.intel.com, broonie@kernel.org Cc: x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, songmuchun@bytedance.com, qirui.001@bytedance.com, Chengming Zhou <zhouchengming@bytedance.com> Subject: [PATCH v3 2/3] x86/ftrace: cleanup graph tracer Date: Thu, 24 Feb 2022 17:32:50 +0800 [thread overview] Message-ID: <20220224093251.49971-2-zhouchengming@bytedance.com> (raw) In-Reply-To: <20220224093251.49971-1-zhouchengming@bytedance.com> Put CONFIG_DYNAMIC_FTRACE related code after prepare_ftrace_return(), in which we define ftrace_graph_func() for graph_ops in DYNAMIC_FTRACE_WITH_ARGS case, then define ftrace_graph_caller enable and disable functions in the #else case to override. Since ftrace_graph_caller enable and disable functions have weak versions in Ftrace core code, we don't need to override them in the DYNAMIC_FTRACE_WITH_ARGS case. This patch is just a cleanup, doesn't have functional changes actually. Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com> --- arch/x86/kernel/ftrace.c | 78 +++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 46 deletions(-) diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c index 7cc540e6de0c..e49c9d3e986b 100644 --- a/arch/x86/kernel/ftrace.c +++ b/arch/x86/kernel/ftrace.c @@ -583,51 +583,6 @@ void arch_ftrace_trampoline_free(struct ftrace_ops *ops) #endif /* CONFIG_DYNAMIC_FTRACE */ #ifdef CONFIG_FUNCTION_GRAPH_TRACER - -#ifdef CONFIG_DYNAMIC_FTRACE - -#ifndef CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS -extern void ftrace_graph_call(void); -static const char *ftrace_jmp_replace(unsigned long ip, unsigned long addr) -{ - return text_gen_insn(JMP32_INSN_OPCODE, (void *)ip, (void *)addr); -} - -static int ftrace_mod_jmp(unsigned long ip, void *func) -{ - const char *new; - - new = ftrace_jmp_replace(ip, (unsigned long)func); - text_poke_bp((void *)ip, new, MCOUNT_INSN_SIZE, NULL); - return 0; -} - -int ftrace_enable_ftrace_graph_caller(void) -{ - unsigned long ip = (unsigned long)(&ftrace_graph_call); - - return ftrace_mod_jmp(ip, &ftrace_graph_caller); -} - -int ftrace_disable_ftrace_graph_caller(void) -{ - unsigned long ip = (unsigned long)(&ftrace_graph_call); - - return ftrace_mod_jmp(ip, &ftrace_stub); -} -#else /* !CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS */ -int ftrace_enable_ftrace_graph_caller(void) -{ - return 0; -} - -int ftrace_disable_ftrace_graph_caller(void) -{ - return 0; -} -#endif /* CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS */ -#endif /* !CONFIG_DYNAMIC_FTRACE */ - /* * Hook the return address and push it in the stack of return addrs * in current thread info. @@ -666,6 +621,8 @@ void prepare_ftrace_return(unsigned long ip, unsigned long *parent, ftrace_test_recursion_unlock(bit); } +#ifdef CONFIG_DYNAMIC_FTRACE + #ifdef CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS void ftrace_graph_func(unsigned long ip, unsigned long parent_ip, struct ftrace_ops *op, struct ftrace_regs *fregs) @@ -675,6 +632,35 @@ void ftrace_graph_func(unsigned long ip, unsigned long parent_ip, prepare_ftrace_return(ip, (unsigned long *)stack, 0); } -#endif +#else +extern void ftrace_graph_call(void); +static const char *ftrace_jmp_replace(unsigned long ip, unsigned long addr) +{ + return text_gen_insn(JMP32_INSN_OPCODE, (void *)ip, (void *)addr); +} +static int ftrace_mod_jmp(unsigned long ip, void *func) +{ + const char *new; + + new = ftrace_jmp_replace(ip, (unsigned long)func); + text_poke_bp((void *)ip, new, MCOUNT_INSN_SIZE, NULL); + return 0; +} + +int ftrace_enable_ftrace_graph_caller(void) +{ + unsigned long ip = (unsigned long)(&ftrace_graph_call); + + return ftrace_mod_jmp(ip, &ftrace_graph_caller); +} + +int ftrace_disable_ftrace_graph_caller(void) +{ + unsigned long ip = (unsigned long)(&ftrace_graph_call); + + return ftrace_mod_jmp(ip, &ftrace_stub); +} +#endif /* CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS */ +#endif /* CONFIG_DYNAMIC_FTRACE */ #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ -- 2.20.1
WARNING: multiple messages have this Message-ID (diff)
From: Chengming Zhou <zhouchengming@bytedance.com> To: rostedt@goodmis.org, mark.rutland@arm.com, mingo@redhat.com, tglx@linutronix.de, catalin.marinas@arm.com, will@kernel.org, dave.hansen@linux.intel.com, broonie@kernel.org Cc: x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, songmuchun@bytedance.com, qirui.001@bytedance.com, Chengming Zhou <zhouchengming@bytedance.com> Subject: [PATCH v3 2/3] x86/ftrace: cleanup graph tracer Date: Thu, 24 Feb 2022 17:32:50 +0800 [thread overview] Message-ID: <20220224093251.49971-2-zhouchengming@bytedance.com> (raw) In-Reply-To: <20220224093251.49971-1-zhouchengming@bytedance.com> Put CONFIG_DYNAMIC_FTRACE related code after prepare_ftrace_return(), in which we define ftrace_graph_func() for graph_ops in DYNAMIC_FTRACE_WITH_ARGS case, then define ftrace_graph_caller enable and disable functions in the #else case to override. Since ftrace_graph_caller enable and disable functions have weak versions in Ftrace core code, we don't need to override them in the DYNAMIC_FTRACE_WITH_ARGS case. This patch is just a cleanup, doesn't have functional changes actually. Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com> --- arch/x86/kernel/ftrace.c | 78 +++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 46 deletions(-) diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c index 7cc540e6de0c..e49c9d3e986b 100644 --- a/arch/x86/kernel/ftrace.c +++ b/arch/x86/kernel/ftrace.c @@ -583,51 +583,6 @@ void arch_ftrace_trampoline_free(struct ftrace_ops *ops) #endif /* CONFIG_DYNAMIC_FTRACE */ #ifdef CONFIG_FUNCTION_GRAPH_TRACER - -#ifdef CONFIG_DYNAMIC_FTRACE - -#ifndef CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS -extern void ftrace_graph_call(void); -static const char *ftrace_jmp_replace(unsigned long ip, unsigned long addr) -{ - return text_gen_insn(JMP32_INSN_OPCODE, (void *)ip, (void *)addr); -} - -static int ftrace_mod_jmp(unsigned long ip, void *func) -{ - const char *new; - - new = ftrace_jmp_replace(ip, (unsigned long)func); - text_poke_bp((void *)ip, new, MCOUNT_INSN_SIZE, NULL); - return 0; -} - -int ftrace_enable_ftrace_graph_caller(void) -{ - unsigned long ip = (unsigned long)(&ftrace_graph_call); - - return ftrace_mod_jmp(ip, &ftrace_graph_caller); -} - -int ftrace_disable_ftrace_graph_caller(void) -{ - unsigned long ip = (unsigned long)(&ftrace_graph_call); - - return ftrace_mod_jmp(ip, &ftrace_stub); -} -#else /* !CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS */ -int ftrace_enable_ftrace_graph_caller(void) -{ - return 0; -} - -int ftrace_disable_ftrace_graph_caller(void) -{ - return 0; -} -#endif /* CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS */ -#endif /* !CONFIG_DYNAMIC_FTRACE */ - /* * Hook the return address and push it in the stack of return addrs * in current thread info. @@ -666,6 +621,8 @@ void prepare_ftrace_return(unsigned long ip, unsigned long *parent, ftrace_test_recursion_unlock(bit); } +#ifdef CONFIG_DYNAMIC_FTRACE + #ifdef CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS void ftrace_graph_func(unsigned long ip, unsigned long parent_ip, struct ftrace_ops *op, struct ftrace_regs *fregs) @@ -675,6 +632,35 @@ void ftrace_graph_func(unsigned long ip, unsigned long parent_ip, prepare_ftrace_return(ip, (unsigned long *)stack, 0); } -#endif +#else +extern void ftrace_graph_call(void); +static const char *ftrace_jmp_replace(unsigned long ip, unsigned long addr) +{ + return text_gen_insn(JMP32_INSN_OPCODE, (void *)ip, (void *)addr); +} +static int ftrace_mod_jmp(unsigned long ip, void *func) +{ + const char *new; + + new = ftrace_jmp_replace(ip, (unsigned long)func); + text_poke_bp((void *)ip, new, MCOUNT_INSN_SIZE, NULL); + return 0; +} + +int ftrace_enable_ftrace_graph_caller(void) +{ + unsigned long ip = (unsigned long)(&ftrace_graph_call); + + return ftrace_mod_jmp(ip, &ftrace_graph_caller); +} + +int ftrace_disable_ftrace_graph_caller(void) +{ + unsigned long ip = (unsigned long)(&ftrace_graph_call); + + return ftrace_mod_jmp(ip, &ftrace_stub); +} +#endif /* CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS */ +#endif /* CONFIG_DYNAMIC_FTRACE */ #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-02-24 9:33 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-02-24 9:32 [PATCH v3 1/3] ftrace: cleanup ftrace_graph_caller enable and disable Chengming Zhou 2022-02-24 9:32 ` Chengming Zhou 2022-02-24 9:32 ` Chengming Zhou [this message] 2022-02-24 9:32 ` [PATCH v3 2/3] x86/ftrace: cleanup graph tracer Chengming Zhou 2022-02-24 9:32 ` [PATCH v3 3/3] arm64/ftrace: Make function graph use ftrace directly Chengming Zhou 2022-02-24 9:32 ` Chengming Zhou 2022-03-22 12:48 ` Chengming Zhou 2022-03-22 12:48 ` Chengming Zhou 2022-03-22 13:41 ` Steven Rostedt 2022-03-22 13:41 ` Steven Rostedt 2022-03-22 14:14 ` [External] " Chengming Zhou 2022-03-22 14:14 ` Chengming Zhou 2022-03-22 14:49 ` Steven Rostedt 2022-03-22 14:49 ` Steven Rostedt 2022-04-07 2:26 ` Chengming Zhou 2022-04-07 2:26 ` Chengming Zhou 2022-04-07 8:58 ` Mark Brown 2022-04-07 8:58 ` Mark Brown 2022-04-07 12:39 ` Chengming Zhou 2022-04-07 12:39 ` Chengming Zhou
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=20220224093251.49971-2-zhouchengming@bytedance.com \ --to=zhouchengming@bytedance.com \ --cc=broonie@kernel.org \ --cc=catalin.marinas@arm.com \ --cc=dave.hansen@linux.intel.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mark.rutland@arm.com \ --cc=mingo@redhat.com \ --cc=qirui.001@bytedance.com \ --cc=rostedt@goodmis.org \ --cc=songmuchun@bytedance.com \ --cc=tglx@linutronix.de \ --cc=will@kernel.org \ --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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.