Skip to content

Commit 6bdf073

Browse files
committed
tracing: Disable trace_printk buffer on warning too
When /proc/sys/kernel/traceoff_on_warning is set to 1, the top level tracing buffer is disabled when a warning happens. This is very useful when debugging and want the tracing buffer to stop taking new data when a warning triggers keeping the events that lead up to the warning from being overwritten. Now that there is also a persistent ring buffer and an option to have trace_printk go to that buffer, the same holds true for that buffer. A warning could happen just before a crash but still write enough events to lose the events that lead up to the first warning that was the reason for the crash. When /proc/sys/kernel/traceoff_on_warning is set to 1 and a warning is triggered, not only disable the top level tracing buffer, but also disable the buffer that trace_printk()s are written to. Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Mark Rutland <mark.rutland@arm.com> Link: https://patch.msgid.link/20260121093858.5c5d7e7b@gandalf.local.home Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent a9e0c58 commit 6bdf073

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

kernel/trace/trace.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,9 +1666,18 @@ EXPORT_SYMBOL_GPL(tracing_off);
16661666
void disable_trace_on_warning(void)
16671667
{
16681668
if (__disable_trace_on_warning) {
1669+
struct trace_array *tr = READ_ONCE(printk_trace);
1670+
16691671
trace_array_printk_buf(global_trace.array_buffer.buffer, _THIS_IP_,
16701672
"Disabling tracing due to warning\n");
16711673
tracing_off();
1674+
1675+
/* Disable trace_printk() buffer too */
1676+
if (tr != &global_trace) {
1677+
trace_array_printk_buf(tr->array_buffer.buffer, _THIS_IP_,
1678+
"Disabling tracing due to warning\n");
1679+
tracer_tracing_off(tr);
1680+
}
16721681
}
16731682
}
16741683

0 commit comments

Comments
 (0)