Skip to content

Commit 3e4b371

Browse files
committed
tracing: Show preempt and irq events callsites from the offsets in field print
When the "fields" option is set in a trace instance, it ignores the "print fmt" portion of the trace event and just prints the raw fields defined by the TP_STRUCT__entry() of the TRACE_EVENT() macro. The preempt_disable/enable and irq_disable/enable events record only the caller offset from _stext to save space in the ring buffer. Even though the "fields" option only prints the fields, it also tries to print what they represent too, which includes function names. Add a check in the output of the event field printing to see if the field name is "caller_offs" or "parent_offs" and then print the function at the offset from _stext of that field. Instead of just showing: irq_disable: caller_offs=0xba634d (12215117) parent_offs=0x39d10e2 (60625122) Show: irq_disable: caller_offs=trace_hardirqs_off.part.0+0xad/0x130 0xba634d (12215117) parent_offs=_raw_spin_lock_irqsave+0x62/0x70 0x39d10e2 (60625122) Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Andrew Morton <akpm@linux-foundation.org> Link: https://lore.kernel.org/20250506105131.4b6089a9@gandalf.local.home Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent dc6a49d commit 3e4b371

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

kernel/trace/trace_output.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,17 @@ static void print_fields(struct trace_iterator *iter, struct trace_event_call *c
10191019
}
10201020

10211021
addr = *(unsigned int *)pos;
1022+
1023+
/* Some fields reference offset from _stext. */
1024+
if (!strcmp(field->name, "caller_offs") ||
1025+
!strcmp(field->name, "parent_offs")) {
1026+
unsigned long ip;
1027+
1028+
ip = addr + (unsigned long)_stext;
1029+
ip = trace_adjust_address(tr, ip);
1030+
trace_seq_printf(&iter->seq, "%pS ", (void *)ip);
1031+
}
1032+
10221033
if (sizeof(long) == 4) {
10231034
addr = trace_adjust_address(tr, addr);
10241035
trace_seq_printf(&iter->seq, "%pS (%d)",

0 commit comments

Comments
 (0)