The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Vincent Donnefort <vdonnefort@google.com>,
	Huang Yiwei <quic_hyiwei@quicinc.com>,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: [PATCH] tracing: fix build without CONFIG_MODULES
Date: Fri, 14 Mar 2025 16:50:49 +0100	[thread overview]
Message-ID: <20250314155052.4170214-1-arnd@kernel.org> (raw)

From: Arnd Bergmann <arnd@arndb.de>

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")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 kernel/trace/trace.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index a6105b6dcc2b..51c030b9887e 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -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))
-- 
2.39.5


             reply	other threads:[~2025-03-14 15:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-14 15:50 Arnd Bergmann [this message]
2025-03-21 16:35 ` [PATCH] tracing: fix build without CONFIG_MODULES Steven Rostedt

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=20250314155052.4170214-1-arnd@kernel.org \
    --to=arnd@kernel.org \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=quic_hyiwei@quicinc.com \
    --cc=rostedt@goodmis.org \
    --cc=vdonnefort@google.com \
    /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