public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ftrace: fix static function tracer not working
@ 2022-10-27  8:53 Song Shuai
  2022-10-27 12:22 ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Song Shuai @ 2022-10-27  8:53 UTC (permalink / raw)
  To: rostedt, mingo; +Cc: linux-kernel, Song Shuai

Setting kernel command line parameter ftrace=function shows
nothing on the kernel built with static ftrace.

In static ftrace, ftrace_nodyn_init should be executed before
initializing tracers. While this commit `dbeafd0d6131` brings
the initialization of function tracer forward from core_initcall
where ftrace_nodyn_init still remains.

This patch puts ftrace_nodyn_init and ftrace_init together and
makes function tracer works in static ftrace.

Fixes: dbeafd0d6131 ("ftrace: Have function tracing start in early boot up")
Signed-off-by: Song Shuai <suagrfillet@gmail.com>
---
 include/linux/ftrace.h | 6 ++++++
 init/main.c            | 1 +
 kernel/trace/ftrace.c  | 4 +---
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 0b61371e287b..4bdab0461b10 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -978,6 +978,12 @@ extern void ftrace_init(void);
 static inline void ftrace_init(void) { }
 #endif
 
+
+#ifndef CONFIG_FTRACE_MCOUNT_RECORD
+extern void ftrace_nodyn_init(void);
+#else
+static inline void ftrace_nodyn_init(void) { }
+#endif
 /*
  * Structure that defines an entry function trace.
  * It's already packed but the attribute "packed" is needed
diff --git a/init/main.c b/init/main.c
index 91642a4e69be..ebf8136e828a 100644
--- a/init/main.c
+++ b/init/main.c
@@ -986,6 +986,7 @@ asmlinkage __visible void __init __no_sanitize_address start_kernel(void)
 	trap_init();
 	mm_init();
 
+	ftrace_nodyn_init();
 	ftrace_init();
 
 	/* trace_printk can be enabled here */
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 56b1a42e1937..40325ae575a5 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -7454,12 +7454,10 @@ struct ftrace_ops global_ops = {
 				  FTRACE_OPS_FL_PID,
 };
 
-static int __init ftrace_nodyn_init(void)
+void __init ftrace_nodyn_init(void)
 {
 	ftrace_enabled = 1;
-	return 0;
 }
-core_initcall(ftrace_nodyn_init);
 
 static inline int ftrace_init_dyn_tracefs(struct dentry *d_tracer) { return 0; }
 static inline void ftrace_startup_all(int command) { }
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-10-31  7:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-27  8:53 [PATCH] ftrace: fix static function tracer not working Song Shuai
2022-10-27 12:22 ` kernel test robot
2022-10-27 13:24 ` Steven Rostedt
2022-10-31  7:02   ` Song Shuai
2022-10-27 15:54 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox