mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Song Shuai <suagrfillet@gmail.com>
To: rostedt@goodmis.org, mingo@redhat.com
Cc: linux-kernel@vger.kernel.org, Song Shuai <suagrfillet@gmail.com>
Subject: [PATCH] ftrace: fix static function tracer not working
Date: Thu, 27 Oct 2022 16:53:43 +0800	[thread overview]
Message-ID: <20221027085343.2388485-1-suagrfillet@gmail.com> (raw)

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


             reply	other threads:[~2022-10-27  8:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-27  8:53 Song Shuai [this message]
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

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=20221027085343.2388485-1-suagrfillet@gmail.com \
    --to=suagrfillet@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®