]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - kernel/trace/trace_boot.c
tracing/fastboot: change the printing of boot tracer according to bootgraph.pl
[linux-2.6-omap-h63xx.git] / kernel / trace / trace_boot.c
1 /*
2  * ring buffer based initcalls tracer
3  *
4  * Copyright (C) 2008 Frederic Weisbecker <fweisbec@gmail.com>
5  *
6  */
7
8 #include <linux/init.h>
9 #include <linux/debugfs.h>
10 #include <linux/ftrace.h>
11
12 #include "trace.h"
13
14 static struct trace_array *boot_trace;
15 static int trace_boot_enabled;
16
17
18 /* Should be started after do_pre_smp_initcalls() in init/main.c */
19 void start_boot_trace(void)
20 {
21         trace_boot_enabled = 1;
22 }
23
24 void stop_boot_trace(struct trace_array *tr)
25 {
26         trace_boot_enabled = 0;
27 }
28
29 static void boot_trace_init(struct trace_array *tr)
30 {
31         int cpu;
32         boot_trace = tr;
33
34         trace_boot_enabled = 0;
35
36         for_each_cpu_mask(cpu, cpu_possible_map)
37                 tracing_reset(tr, cpu);
38 }
39
40 static void boot_trace_ctrl_update(struct trace_array *tr)
41 {
42         if (tr->ctrl)
43                 start_boot_trace();
44         else
45                 stop_boot_trace(tr);
46 }
47
48 static enum print_line_t initcall_print_line(struct trace_iterator *iter)
49 {
50         int ret;
51         struct trace_entry *entry = iter->ent;
52         struct trace_boot *field = (struct trace_boot *)entry;
53         struct boot_trace *it = &field->initcall;
54         struct trace_seq *s = &iter->seq;
55         struct timespec calltime = ktime_to_timespec(it->calltime);
56         struct timespec rettime = ktime_to_timespec(it->rettime);
57
58         if (entry->type == TRACE_BOOT) {
59                 ret = trace_seq_printf(s, "[%5ld.%06ld] calling  %pF @ %i\n",
60                                           calltime.tv_sec,
61                                           calltime.tv_nsec,
62                                           it->func, it->caller);
63                 if (!ret)
64                         return TRACE_TYPE_PARTIAL_LINE;
65                 ret = trace_seq_printf(s, "[%5ld.%06ld] initcall %pF "
66                                           "returned %d after %lld msecs\n",
67                                           rettime.tv_sec,
68                                           rettime.tv_nsec,
69                                           it->func, it->result, it->duration);
70                 if (!ret)
71                         return TRACE_TYPE_PARTIAL_LINE;
72                 return TRACE_TYPE_HANDLED;
73         }
74         return TRACE_TYPE_UNHANDLED;
75 }
76
77 struct tracer boot_tracer __read_mostly =
78 {
79         .name           = "initcall",
80         .init           = boot_trace_init,
81         .reset          = stop_boot_trace,
82         .ctrl_update    = boot_trace_ctrl_update,
83         .print_line     = initcall_print_line,
84 };
85
86
87 void trace_boot(struct boot_trace *it)
88 {
89         struct ring_buffer_event *event;
90         struct trace_boot *entry;
91         struct trace_array_cpu *data;
92         unsigned long irq_flags;
93         struct trace_array *tr = boot_trace;
94
95         if (!trace_boot_enabled)
96                 return;
97
98         preempt_disable();
99         data = tr->data[smp_processor_id()];
100
101         event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry),
102                                          &irq_flags);
103         if (!event)
104                 goto out;
105         entry   = ring_buffer_event_data(event);
106         tracing_generic_entry_update(&entry->ent, 0, 0);
107         entry->ent.type = TRACE_BOOT;
108         entry->initcall = *it;
109         ring_buffer_unlock_commit(tr->buffer, event, irq_flags);
110
111         trace_wake_up();
112
113  out:
114         preempt_enable();
115 }