From 98f2926171aea858b074b714bb6e111d51fa747d Mon Sep 17 00:00:00 2001 From: Sven Schnelle Date: Sat, 23 Oct 2021 20:21:01 +0200 Subject: [PATCH] parisc/ftrace: use static key to enable/disable function graph tracer This avoids using dereference_function_descriptor in the ftrace code path, and it's also faster. Signed-off-by: Sven Schnelle Signed-off-by: Helge Deller --- arch/parisc/kernel/ftrace.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/parisc/kernel/ftrace.c b/arch/parisc/kernel/ftrace.c index 3a577186f71b..2a1f826b3def 100644 --- a/arch/parisc/kernel/ftrace.c +++ b/arch/parisc/kernel/ftrace.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -24,6 +25,8 @@ #define __hot __section(".text.hot") #ifdef CONFIG_FUNCTION_GRAPH_TRACER +static DEFINE_STATIC_KEY_FALSE(ftrace_graph_enable); + /* * Hook the return address and push it in the stack of return addrs * in current thread info. @@ -60,9 +63,7 @@ void notrace __hot ftrace_function_trampoline(unsigned long parent, ftrace_func(self_addr, parent, function_trace_op, fregs); #ifdef CONFIG_FUNCTION_GRAPH_TRACER - if (dereference_function_descriptor(ftrace_graph_return) != - dereference_function_descriptor(ftrace_stub) || - ftrace_graph_entry != ftrace_graph_entry_stub) { + if (static_branch_unlikely(&ftrace_graph_enable)) { unsigned long *parent_rp; /* calculate pointer to %rp in stack */ @@ -80,11 +81,13 @@ void notrace __hot ftrace_function_trampoline(unsigned long parent, #ifdef CONFIG_FUNCTION_GRAPH_TRACER int ftrace_enable_ftrace_graph_caller(void) { + static_key_enable(&ftrace_graph_enable.key); return 0; } int ftrace_disable_ftrace_graph_caller(void) { + static_key_enable(&ftrace_graph_enable.key); return 0; } #endif