[for-next][PATCH] tracing: Have trace_event_update_all() only handle module that is loading

From: Steven Rostedt

Date: Fri Aug 14 2026 - 14:21:58 EST



git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
trace/for-next

Head SHA1: ae70b04ab9c7f6162a8c0fdd18a62a945c133142


Steven Rostedt (1):
tracing: Have trace_event_update_all() only handle module that is loading

----
kernel/trace/trace.c | 2 +-
kernel/trace/trace.h | 4 ++--
kernel/trace/trace_events.c | 6 +++++-
3 files changed, 8 insertions(+), 4 deletions(-)
---------------------------
commit ae70b04ab9c7f6162a8c0fdd18a62a945c133142
Author: Steven Rostedt <rostedt@xxxxxxxxxxx>
Date: Thu Aug 13 20:42:26 2026 -0400

tracing: Have trace_event_update_all() only handle module that is loading

The function trace_event_update_all() does a scan of events looking to
replace enums with their values in the strings that get exported to the
event format files. It's run at boot up on all events and again when a
module loads.

The issue is that when a module loads, it still runs on *all* events.
There's no reason to process every event when a module loads as the
previous events have already been processed. Only execute on the events
that are loaded with the module.

Link: https://patch.msgid.link/20260813204226.29563591@xxxxxxxxxxxxxxxxxx
Fixes: 3673b8e4ce723 ("tracing: Allow for modules to convert their enums to values")
Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 01a5e87af299..575912e4c310 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -4669,7 +4669,7 @@ trace_event_update_with_eval_map(struct module *mod,

map = start;

- trace_event_update_all(map, len);
+ trace_event_update_all(map, len, mod);

if (len <= 0)
return;
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index bf77331f56a4..74a7a50d1e78 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -2285,13 +2285,13 @@ static inline const char *get_syscall_name(int syscall)

#ifdef CONFIG_EVENT_TRACING
void trace_event_init(void);
-void trace_event_update_all(struct trace_eval_map **map, int len);
+void trace_event_update_all(struct trace_eval_map **map, int len, struct module *mod);
/* Used from boot time tracer */
extern int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set);
extern int trigger_process_regex(struct trace_event_file *file, char *buff);
#else
static inline void __init trace_event_init(void) { }
-static inline void trace_event_update_all(struct trace_eval_map **map, int len) { }
+static inline void trace_event_update_all(struct trace_eval_map **map, int len, struct module *mod) { }
#endif

#ifdef CONFIG_TRACER_SNAPSHOT
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index ce902482ec7c..7313eb1361c9 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -3661,7 +3661,7 @@ static void update_event_fields(struct trace_event_call *call,
}

/* Update all events for replacing eval and sanitizing */
-void trace_event_update_all(struct trace_eval_map **map, int len)
+void trace_event_update_all(struct trace_eval_map **map, int len, struct module *mod)
{
struct trace_event_call *call, *p;
const char *last_system = NULL;
@@ -3672,6 +3672,10 @@ void trace_event_update_all(struct trace_eval_map **map, int len)

down_write(&trace_event_sem);
list_for_each_entry_safe(call, p, &ftrace_events, list) {
+
+ if (mod && call->module != mod)
+ continue;
+
/* events are usually grouped together with systems */
if (!last_system || call->class->system != last_system) {
first = true;