[PATCH v5 1/2] tracing: Fix a compilation error without CONFIG_MODULES

From: Masami Hiramatsu (Google)
Date: Tue Mar 18 2025 - 09:40:46 EST


From: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>

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@xxxxxxxxxx>
---
Changes in v5:
- Make a nop save_mod() if CONFIG_MODULES=n instead of
adding #ifdefs around module_for_each_mod().
---
kernel/trace/trace.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index c3c79908766e..68abea81e51a 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,12 @@ static int save_mod(struct module *mod, void *data)

return 0;
}
+#else
+static int save_mod(struct module *mod, void *data)
+{
+ return 0;
+}
+#endif

static void update_last_data(struct trace_array *tr)
{