]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tracing: Do not use PERF enums when perf is not defined
authorSteven Rostedt <rostedt@goodmis.org>
Sun, 23 Mar 2025 19:21:51 +0000 (15:21 -0400)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Mon, 24 Mar 2025 21:12:33 +0000 (17:12 -0400)
An update was made to up the module ref count when a synthetic event is
registered for both trace and perf events. But if perf is not configured
in, the perf enums used will cause the kernel to fail to build.

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Douglas Raillard <douglas.raillard@arm.com>
Link: https://lore.kernel.org/20250323152151.528b5ced@batman.local.home
Fixes: 21581dd4e7ff ("tracing: Ensure module defining synth event cannot be unloaded while tracing")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202503232230.TeREVy8R-lkp@intel.com/
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/trace_events_synth.c

index 463b0073629a5686d1aa3a60cb697edda068a2c4..a5c5f34c207a6f495274c21d5398456c3b27f7fa 100644 (file)
@@ -858,8 +858,10 @@ static int synth_event_reg(struct trace_event_call *call,
        struct synth_event *event = container_of(call, struct synth_event, call);
 
        switch (type) {
-       case TRACE_REG_REGISTER:
+#ifdef CONFIG_PERF_EVENTS
        case TRACE_REG_PERF_REGISTER:
+#endif
+       case TRACE_REG_REGISTER:
                if (!try_module_get(event->mod))
                        return -EBUSY;
                break;
@@ -870,8 +872,10 @@ static int synth_event_reg(struct trace_event_call *call,
        int ret = trace_event_reg(call, type, data);
 
        switch (type) {
-       case TRACE_REG_UNREGISTER:
+#ifdef CONFIG_PERF_EVENTS
        case TRACE_REG_PERF_UNREGISTER:
+#endif
+       case TRACE_REG_UNREGISTER:
                module_put(event->mod);
                break;
        default: