Skip to content

Commit 8eb1518

Browse files
committed
tracing: Do not use PERF enums when perf is not defined
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: 21581dd ("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>
1 parent 21581dd commit 8eb1518

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

kernel/trace/trace_events_synth.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -858,8 +858,10 @@ static int synth_event_reg(struct trace_event_call *call,
858858
struct synth_event *event = container_of(call, struct synth_event, call);
859859

860860
switch (type) {
861-
case TRACE_REG_REGISTER:
861+
#ifdef CONFIG_PERF_EVENTS
862862
case TRACE_REG_PERF_REGISTER:
863+
#endif
864+
case TRACE_REG_REGISTER:
863865
if (!try_module_get(event->mod))
864866
return -EBUSY;
865867
break;
@@ -870,8 +872,10 @@ static int synth_event_reg(struct trace_event_call *call,
870872
int ret = trace_event_reg(call, type, data);
871873

872874
switch (type) {
873-
case TRACE_REG_UNREGISTER:
875+
#ifdef CONFIG_PERF_EVENTS
874876
case TRACE_REG_PERF_UNREGISTER:
877+
#endif
878+
case TRACE_REG_UNREGISTER:
875879
module_put(event->mod);
876880
break;
877881
default:

0 commit comments

Comments
 (0)