2 * ring buffer based initcalls tracer
4 * Copyright (C) 2008 Frederic Weisbecker <fweisbec@gmail.com>
8 #include <linux/init.h>
9 #include <linux/debugfs.h>
10 #include <linux/ftrace.h>
14 static struct trace_array *boot_trace;
15 static int trace_boot_enabled;
18 /* Should be started after do_pre_smp_initcalls() in init/main.c */
19 void start_boot_trace(void)
21 trace_boot_enabled = 1;
24 void stop_boot_trace(struct trace_array *tr)
26 trace_boot_enabled = 0;
29 static void boot_trace_init(struct trace_array *tr)
34 trace_boot_enabled = 0;
36 for_each_cpu_mask(cpu, cpu_possible_map)
37 tracing_reset(tr->data[cpu]);
40 static void boot_trace_ctrl_update(struct trace_array *tr)
48 static int initcall_print_line(struct trace_iterator *iter)
51 struct trace_entry *entry = iter->ent;
52 struct boot_trace *it = &entry->field.initcall;
53 struct trace_seq *s = &iter->seq;
55 if (iter->ent->type == TRACE_BOOT)
56 ret = trace_seq_printf(s, "%pF called from %i "
57 "returned %d after %lld msecs\n",
58 it->func, it->caller, it->result,
65 struct tracer boot_tracer __read_mostly =
68 .init = boot_trace_init,
69 .reset = stop_boot_trace,
70 .ctrl_update = boot_trace_ctrl_update,
71 .print_line = initcall_print_line,
75 void trace_boot(struct boot_trace *it)
77 struct trace_entry *entry;
78 struct trace_array_cpu *data;
79 unsigned long irq_flags;
80 struct trace_array *tr = boot_trace;
82 if (!trace_boot_enabled)
86 data = tr->data[smp_processor_id()];
88 raw_local_irq_save(irq_flags);
89 __raw_spin_lock(&data->lock);
91 entry = tracing_get_trace_entry(tr, data);
92 tracing_generic_entry_update(entry, 0);
93 entry->type = TRACE_BOOT;
94 entry->field.initcall = *it;
96 __raw_spin_unlock(&data->lock);
97 raw_local_irq_restore(irq_flags);