[PATCH v4 1/2] tracing: Fix a compilation error without CONFIG_MODULES
From: Masami Hiramatsu (Google)
Date: Thu Mar 13 2025 - 12:29:41 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>
---
kernel/trace/trace.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
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))