tracing: Register static events output early
PATCH 1/1 tracing: Register static events output early
Early uses of trace_printk() or trace_dump_stack() won't be displayed correctly if they are printed before device initcalls through explicit calls to ftrace_dump() or if there is an early BUG() and ftrace_dump_on_oops is set. This is because we only initialize these static events output callbacks at that initcall level.
Initialize these events output at the earliest initcall state to make boot debugging possible sooner.
Before:
[ 1.936168] Dumping ftrace buffer: [ 1.936168] --------------------------------- [ 1.936168] <idle>-0 3d.s. 2299861us : Unknown type 4 [ 1.936168] ---------------------------------
After:
[ 1.946182] Dumping ftrace buffer: [ 1.946182] --------------------------------- [ 1.946182] <idle>-0 3d.s. 2309844us : <stack trace> [ 1.946182] => tick_setup_sched_timer [ 1.946182] => hrtimer_run_pending [ 1.946182] => run_timer_softirq [ 1.946182] => __do_softirq [ 1.946182] => call_softirq [ 1.946182] => do_softirq [ 1.946182] => irq_exit [ 1.946182] => smp_apic_timer_interrupt [ 1.946182] ---------------------------------
--- kernel/trace/trace_output.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/trace/trace_output.c +1 -1
@@ -1278,4 +1278,4 @@ __init static int init_events(void)return 0 ; } -device_initcall (init_events); +early_initcall (init_events);
Signature · 1 line
1.7.3.2
Steven Rostedt
maintainerkernel/trace/trace_output.c __init static int init_events(void) · line 1281
Quoted 10 lines · Frederic Weisbecker
kernel/trace/trace_output.c +1
-1@@ -1278,4 +1278,4 @@ __init static int init_events(void)return 0 ; } -device_initcall (init_events); +early_initcall (init_events);
Hmm, careful here. The ring buffers are also allocated at early_init().
But you may be OK, as things like trace_printk() don't do anything if "tracing_disabled" is set, and it's set on bootup and cleared after we allocate the buffers.
-- Steve
Quoted 15 lines · Steven Rostedt
kernel/trace/trace_output.c __init static int init_events(void) · line 1281
Quoted 10 lines · Frederic Weisbecker
kernel/trace/trace_output.c +1
-1@@ -1278,4 +1278,4 @@ __init static int init_events(void)return 0 ; } -device_initcall (init_events); +early_initcall (init_events);Hmm, careful here. The ring buffers are also allocated at
early_init().
Quoted 3 lines
But you may be OK, as things like
trace_printk()don't do anything if "tracing_disabled" is set, and it's set on bootup and cleared after we allocate the buffers.
Yep, and the output callback only impact the read side anyway, once the trace has been already pulled out of the buffer. I hope I'm not missing something in the way...