diff mbox series

[v4,1/2] tracing: Fix a compilation error without CONFIG_MODULES

Message ID 174188321162.3845006.12665585959241736399.stgit@mhiramat.tok.corp.google.com (mailing list archive)
State New
Headers show
Series tracing: Show last boot module symbols | expand

Commit Message

Masami Hiramatsu (Google) March 13, 2025, 4:26 p.m. UTC
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

There are some code which depends on CONFIG_MODULES. #ifdef
to enclose it.

Fixes: dca91c1c5468 ("tracing: Have persistent trace instances save module addresses")
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
 kernel/trace/trace.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Steven Rostedt March 14, 2025, 9:42 a.m. UTC | #1
On Fri, 14 Mar 2025 01:26:51 +0900
"Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:

> @@ -6040,9 +6042,10 @@ static void update_last_data(struct trace_array *tr)
>  		memset(tscratch->entries, 0,
>  		       flex_array_size(tscratch, entries, tscratch->nr_entries));
>  		tscratch->nr_entries = 0;
> -
> +#ifdef CONFIG_MODULES
>  		guard(mutex)(&scratch_mutex);
>  		module_for_each_mod(save_mod, tr);
> +#endif
>  	}

Hmm, I think the real fix for this would be to make
module_for_each_mod() a nop when modules are not configured.

-- Steve
diff mbox series

Patch

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index c3c79908766e..c70b2e709987 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -6001,6 +6001,7 @@  struct trace_scratch {
 
 static DEFINE_MUTEX(scratch_mutex);
 
+#ifdef CONFIG_MODULES
 static int save_mod(struct module *mod, void *data)
 {
 	struct trace_array *tr = data;
@@ -6025,6 +6026,7 @@  static int save_mod(struct module *mod, void *data)
 
 	return 0;
 }
+#endif
 
 static void update_last_data(struct trace_array *tr)
 {
@@ -6040,9 +6042,10 @@  static void update_last_data(struct trace_array *tr)
 		memset(tscratch->entries, 0,
 		       flex_array_size(tscratch, entries, tscratch->nr_entries));
 		tscratch->nr_entries = 0;
-
+#ifdef CONFIG_MODULES
 		guard(mutex)(&scratch_mutex);
 		module_for_each_mod(save_mod, tr);
+#endif
 	}
 
 	if (!(tr->flags & TRACE_ARRAY_FL_LAST_BOOT))