Skip to contentSkip to conversation

tracing: Do not take trace_event_sem in print_event_fields()

PATCH New Steven Rostedt 1 participant 1 message May 2, 2025 Tracing

lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

PATCH 1/1 tracing: Do not take trace_event_sem in print_event_fields()

From: Steven Rostedt <[email protected]>

On some paths in print_event_fields() it takes the trace_event_sem for read, even though it should always be held when the function is called.

Remove the taking of that mutex and add a lockdep_assert_held_read() to make sure the trace_event_sem is held when print_event_fields() is called.

Fixes 80a76994b2d88 ("tracing: Add "fields" option to show raw trace event fields")
Reported-by [email protected]
---
 kernel/trace/trace_output.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/trace_output.c +2 -2
index c5e8299d1842..aa0d3663f754 100644
@@ -1056,11 +1056,12 @@ enum print_line_t print_event_fields(struct trace_iterator *iter,
 	struct trace_event_call *call;
 	struct list_head *head;
 
+	lockdep_assert_held_read(&trace_event_sem);
+
 	/* ftrace defined events have separate call structures */
 	if (event->type <= __TRACE_LAST_TYPE) {
 		bool found = false;
 
-		down_read(&trace_event_sem);
 		list_for_each_entry(call, &ftrace_events, list) {
 			if (call->event.type == event->type) {
 				found = true;
@@ -1070,7 +1071,6 @@ enum print_line_t print_event_fields(struct trace_iterator *iter,
 			if (call->event.type > __TRACE_LAST_TYPE)
 				break;
 		}
-		up_read(&trace_event_sem);
 		if (!found) {
 			trace_seq_printf(&iter->seq, "UNKNOWN TYPE %d\n", event->type);
 			goto out;
Signature · 1 line
2.47.2