Skip to content

Commit 937fbf1

Browse files
committed
tracing: Add traceoff_after_boot option
Sometimes tracing is used to debug issues during the boot process. Since the trace buffer has a limited amount of storage, it may be prudent to disable tracing after the boot is finished, otherwise the critical information may be overwritten. With this option, the main tracing buffer will be turned off at the end of the boot process. Cc: Masami Hiramatsu <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Borislav Petkov <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent d082ecb commit 937fbf1

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7279,6 +7279,15 @@
72797279
See also "Event triggers" in Documentation/trace/events.rst
72807280

72817281

7282+
traceoff_after_boot
7283+
[FTRACE] Sometimes tracing is used to debug issues
7284+
during the boot process. Since the trace buffer has a
7285+
limited amount of storage, it may be prudent to
7286+
disable tracing after the boot is finished, otherwise
7287+
the critical information may be overwritten. With this
7288+
option, the main tracing buffer will be turned off at
7289+
the end of the boot process.
7290+
72827291
traceoff_on_warning
72837292
[FTRACE] enable this option to disable tracing when a
72847293
warning is hit. This turns off "tracing_on". Tracing can

kernel/trace/trace.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ void __init disable_tracing_selftest(const char *reason)
8787
static struct trace_iterator *tracepoint_print_iter;
8888
int tracepoint_printk;
8989
static bool tracepoint_printk_stop_on_boot __initdata;
90+
static bool traceoff_after_boot __initdata;
9091
static DEFINE_STATIC_KEY_FALSE(tracepoint_printk_key);
9192

9293
/* For tracers that don't implement custom flags */
@@ -330,6 +331,13 @@ static int __init set_tracepoint_printk_stop(char *str)
330331
}
331332
__setup("tp_printk_stop_on_boot", set_tracepoint_printk_stop);
332333

334+
static int __init set_traceoff_after_boot(char *str)
335+
{
336+
traceoff_after_boot = true;
337+
return 1;
338+
}
339+
__setup("traceoff_after_boot", set_traceoff_after_boot);
340+
333341
unsigned long long ns2usecs(u64 nsec)
334342
{
335343
nsec += 500;
@@ -10704,6 +10712,9 @@ __init static int late_trace_init(void)
1070410712
tracepoint_printk = 0;
1070510713
}
1070610714

10715+
if (traceoff_after_boot)
10716+
tracing_off();
10717+
1070710718
tracing_set_default_clock();
1070810719
clear_boot_tracer();
1070910720
return 0;

0 commit comments

Comments
 (0)