Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tracing: Add tp_printk_stop_on_boot option

Add a kernel command line option that disables printing of events to
console at late_initcall_sync(). This is useful when needing to see
specific events written to console on boot up, but not wanting it when
user space starts, as user space may make the console so noisy that the
system becomes inoperable.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

+42 -11
+13
Documentation/admin-guide/kernel-parameters.txt
··· 5605 5605 Note, echoing 1 into this file without the 5606 5606 tracepoint_printk kernel cmdline option has no effect. 5607 5607 5608 + The tp_printk_stop_on_boot (see below) can also be used 5609 + to stop the printing of events to console at 5610 + late_initcall_sync. 5611 + 5608 5612 ** CAUTION ** 5609 5613 5610 5614 Having tracepoints sent to printk() and activating high 5611 5615 frequency tracepoints such as irq or sched, can cause 5612 5616 the system to live lock. 5617 + 5618 + tp_printk_stop_on_boot[FTRACE] 5619 + When tp_printk (above) is set, it can cause a lot of noise 5620 + on the console. It may be useful to only include the 5621 + printing of events during boot up, as user space may 5622 + make the system inoperable. 5623 + 5624 + This command line option will stop the printing of events 5625 + to console at the late_initcall_sync() time frame. 5613 5626 5614 5627 traceoff_on_warning 5615 5628 [FTRACE] enable this option to disable tracing when a
+29 -11
kernel/trace/trace.c
··· 86 86 /* Pipe tracepoints to printk */ 87 87 struct trace_iterator *tracepoint_print_iter; 88 88 int tracepoint_printk; 89 + static bool tracepoint_printk_stop_on_boot __initdata; 89 90 static DEFINE_STATIC_KEY_FALSE(tracepoint_printk_key); 90 91 91 92 /* For tracers that don't implement custom flags */ ··· 256 255 return 1; 257 256 } 258 257 __setup("tp_printk", set_tracepoint_printk); 258 + 259 + static int __init set_tracepoint_printk_stop(char *str) 260 + { 261 + tracepoint_printk_stop_on_boot = true; 262 + return 1; 263 + } 264 + __setup("tp_printk_stop_on_boot", set_tracepoint_printk_stop); 259 265 260 266 unsigned long long ns2usecs(u64 nsec) 261 267 { ··· 9586 9578 return 0; 9587 9579 } 9588 9580 9581 + fs_initcall(tracer_init_tracefs); 9582 + 9589 9583 static int trace_panic_handler(struct notifier_block *this, 9590 9584 unsigned long event, void *unused) 9591 9585 { ··· 10008 9998 trace_event_init(); 10009 9999 } 10010 10000 10011 - __init static int clear_boot_tracer(void) 10001 + __init static void clear_boot_tracer(void) 10012 10002 { 10013 10003 /* 10014 10004 * The default tracer at boot buffer is an init section. ··· 10018 10008 * about to be freed. 10019 10009 */ 10020 10010 if (!default_bootup_tracer) 10021 - return 0; 10011 + return; 10022 10012 10023 10013 printk(KERN_INFO "ftrace bootup tracer '%s' not registered.\n", 10024 10014 default_bootup_tracer); 10025 10015 default_bootup_tracer = NULL; 10026 - 10027 - return 0; 10028 10016 } 10029 10017 10030 - fs_initcall(tracer_init_tracefs); 10031 - late_initcall_sync(clear_boot_tracer); 10032 - 10033 10018 #ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK 10034 - __init static int tracing_set_default_clock(void) 10019 + __init static void tracing_set_default_clock(void) 10035 10020 { 10036 10021 /* sched_clock_stable() is determined in late_initcall */ 10037 10022 if (!trace_boot_clock && !sched_clock_stable()) { 10038 10023 if (security_locked_down(LOCKDOWN_TRACEFS)) { 10039 10024 pr_warn("Can not set tracing clock due to lockdown\n"); 10040 - return -EPERM; 10025 + return; 10041 10026 } 10042 10027 10043 10028 printk(KERN_WARNING ··· 10042 10037 "on the kernel command line\n"); 10043 10038 tracing_set_clock(&global_trace, "global"); 10044 10039 } 10040 + } 10041 + #else 10042 + static inline void tracing_set_default_clock(void) { } 10043 + #endif 10045 10044 10045 + __init static int late_trace_init(void) 10046 + { 10047 + if (tracepoint_printk && tracepoint_printk_stop_on_boot) { 10048 + static_key_disable(&tracepoint_printk_key.key); 10049 + tracepoint_printk = 0; 10050 + } 10051 + 10052 + tracing_set_default_clock(); 10053 + clear_boot_tracer(); 10046 10054 return 0; 10047 10055 } 10048 - late_initcall_sync(tracing_set_default_clock); 10049 - #endif 10056 + 10057 + late_initcall_sync(late_trace_init);