Skip to contentSkip to conversation

tracing: fix build without CONFIG_MODULES

PATCH In review Arnd Bergmann 2 participants 2 messages Mar 14, 2025 – Mar 21, 2025 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tracing: fix build without CONFIG_MODULES

From: Arnd Bergmann <[email protected]>

The tracing code fails to build when CONFIG_MODULES is disabled:

kernel/trace/trace.c: In function 'save_mod':
kernel/trace/trace.c:6041:45: error: invalid use of undefined type 'struct module'
6041 | entry->mod_addr = (unsigned long)mod->mem[MOD_TEXT].base;
| ^~

The problem here is that 'struct module' is not defined in this configuration.

Enclose the functions in another #ifdef, just like other parts of this file already are.

Fixes dca91c1c5468 ("tracing: Have persistent trace instances save module addresses")
---
 kernel/trace/trace.c | 4 ++++
 1 file changed, 4 insertions(+)
kernel/trace/trace.c +4 -0
index a6105b6dcc2b..51c030b9887e 100644
@@ -6019,6 +6019,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;
@@ -6043,6 +6044,7 @@ static int save_mod(struct module *mod, void *data)
 
 	return 0;
 }
+#endif
 
 static void update_last_data(struct trace_array *tr)
 {
@@ -6060,7 +6062,9 @@ static void update_last_data(struct trace_array *tr)
 		tscratch->nr_entries = 0;
 
 		guard(mutex)(&scratch_mutex);
+#ifdef CONFIG_MODULES
 		module_for_each_mod(save_mod, tr);
+#endif
 	}
 
 	if (!(tr->flags & TRACE_ARRAY_FL_LAST_BOOT))
Signature · 1 line
2.39.5
maintainer
#1 lore raw
Quoted 9 lines · On Fri, 14 Mar 2025 16:50:49 +0100 Arnd Bergmann <[email protected]> wrote:

From: Arnd Bergmann <[email protected]>

The tracing code fails to build when CONFIG_MODULES is disabled:

kernel/trace/trace.c: In function 'save_mod':
kernel/trace/trace.c:6041:45: error: invalid use of undefined type 'struct module'
6041 | entry->mod_addr = (unsigned long)mod->mem[MOD_TEXT].base;
| ^~

Quoted 8 lines

The problem here is that 'struct module' is not defined in this configuration.

Enclose the functions in another #ifdef, just like other parts of this file already are.

Fixes dca91c1c5468 ("tracing: Have persistent trace instances save module addresses")

---

Thanks, but Masami already sent one fix where I commented on and he then sent an update:

https://lore.kernel.org/all/174188321162.3845006.12665585959241736399.stgit@mhiramat.tok.corp.google.com/

and the update:

https://lore.kernel.org/all/174230515367.2909896.8132122175220657625.stgit@mhiramat.tok.corp.google.com/

-- Steve