diff mbox series

[2/3] parisc/ftrace: use static key to enable function graph

Message ID 20211019183152.26191-3-svens@stackframe.org (mailing list archive)
State Accepted, archived
Headers show
Series ftrace fixes for PA-RISC | expand

Commit Message

Sven Schnelle Oct. 19, 2021, 6:31 p.m. UTC
Instead of comparing function descriptors add a static branch
so the condition gets patched during runtime.

Signed-off-by: Sven Schnelle <svens@stackframe.org>
---
 arch/parisc/kernel/ftrace.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/arch/parisc/kernel/ftrace.c b/arch/parisc/kernel/ftrace.c
index f5f467ebf94c..7a2de664242a 100644
--- a/arch/parisc/kernel/ftrace.c
+++ b/arch/parisc/kernel/ftrace.c
@@ -23,6 +23,7 @@ 
 
 #define __hot __section(".text.hot")
 
+static DEFINE_STATIC_KEY_FALSE(ftrace_graph_enabled);
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
 /*
  * Hook the return address and push it in the stack of return addrs
@@ -61,9 +62,7 @@  void notrace __hot ftrace_function_trampoline(unsigned long parent,
 	ftrace_trace_function(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_enabled)) {
 		unsigned long *parent_rp;
 
 		/* calculate pointer to %rp in stack */
@@ -81,11 +80,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_enabled.key);
 	return 0;
 }
 
 int ftrace_disable_ftrace_graph_caller(void)
 {
+	static_key_disable(&ftrace_graph_enabled.key);
 	return 0;
 }
 #endif