aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_boot.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/trace/trace_boot.c')
-rw-r--r--kernel/trace/trace_boot.c41
1 files changed, 17 insertions, 24 deletions
diff --git a/kernel/trace/trace_boot.c b/kernel/trace/trace_boot.c
index 366c8c333e13..a29ef23ffb47 100644
--- a/kernel/trace/trace_boot.c
+++ b/kernel/trace/trace_boot.c
@@ -9,8 +9,10 @@
9#include <linux/debugfs.h> 9#include <linux/debugfs.h>
10#include <linux/ftrace.h> 10#include <linux/ftrace.h>
11#include <linux/kallsyms.h> 11#include <linux/kallsyms.h>
12#include <linux/time.h>
12 13
13#include "trace.h" 14#include "trace.h"
15#include "trace_output.h"
14 16
15static struct trace_array *boot_trace; 17static struct trace_array *boot_trace;
16static bool pre_initcalls_finished; 18static bool pre_initcalls_finished;
@@ -27,13 +29,13 @@ void start_boot_trace(void)
27 29
28void enable_boot_trace(void) 30void enable_boot_trace(void)
29{ 31{
30 if (pre_initcalls_finished) 32 if (boot_trace && pre_initcalls_finished)
31 tracing_start_sched_switch_record(); 33 tracing_start_sched_switch_record();
32} 34}
33 35
34void disable_boot_trace(void) 36void disable_boot_trace(void)
35{ 37{
36 if (pre_initcalls_finished) 38 if (boot_trace && pre_initcalls_finished)
37 tracing_stop_sched_switch_record(); 39 tracing_stop_sched_switch_record();
38} 40}
39 41
@@ -42,6 +44,9 @@ static int boot_trace_init(struct trace_array *tr)
42 int cpu; 44 int cpu;
43 boot_trace = tr; 45 boot_trace = tr;
44 46
47 if (!tr)
48 return 0;
49
45 for_each_cpu(cpu, cpu_possible_mask) 50 for_each_cpu(cpu, cpu_possible_mask)
46 tracing_reset(tr, cpu); 51 tracing_reset(tr, cpu);
47 52
@@ -63,7 +68,7 @@ initcall_call_print_line(struct trace_iterator *iter)
63 trace_assign_type(field, entry); 68 trace_assign_type(field, entry);
64 call = &field->boot_call; 69 call = &field->boot_call;
65 ts = iter->ts; 70 ts = iter->ts;
66 nsec_rem = do_div(ts, 1000000000); 71 nsec_rem = do_div(ts, NSEC_PER_SEC);
67 72
68 ret = trace_seq_printf(s, "[%5ld.%09ld] calling %s @ %i\n", 73 ret = trace_seq_printf(s, "[%5ld.%09ld] calling %s @ %i\n",
69 (unsigned long)ts, nsec_rem, call->func, call->caller); 74 (unsigned long)ts, nsec_rem, call->func, call->caller);
@@ -88,7 +93,7 @@ initcall_ret_print_line(struct trace_iterator *iter)
88 trace_assign_type(field, entry); 93 trace_assign_type(field, entry);
89 init_ret = &field->boot_ret; 94 init_ret = &field->boot_ret;
90 ts = iter->ts; 95 ts = iter->ts;
91 nsec_rem = do_div(ts, 1000000000); 96 nsec_rem = do_div(ts, NSEC_PER_SEC);
92 97
93 ret = trace_seq_printf(s, "[%5ld.%09ld] initcall %s " 98 ret = trace_seq_printf(s, "[%5ld.%09ld] initcall %s "
94 "returned %d after %llu msecs\n", 99 "returned %d after %llu msecs\n",
@@ -128,10 +133,9 @@ void trace_boot_call(struct boot_trace_call *bt, initcall_t fn)
128{ 133{
129 struct ring_buffer_event *event; 134 struct ring_buffer_event *event;
130 struct trace_boot_call *entry; 135 struct trace_boot_call *entry;
131 unsigned long irq_flags;
132 struct trace_array *tr = boot_trace; 136 struct trace_array *tr = boot_trace;
133 137
134 if (!pre_initcalls_finished) 138 if (!tr || !pre_initcalls_finished)
135 return; 139 return;
136 140
137 /* Get its name now since this function could 141 /* Get its name now since this function could
@@ -140,18 +144,13 @@ void trace_boot_call(struct boot_trace_call *bt, initcall_t fn)
140 sprint_symbol(bt->func, (unsigned long)fn); 144 sprint_symbol(bt->func, (unsigned long)fn);
141 preempt_disable(); 145 preempt_disable();
142 146
143 event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry), 147 event = trace_buffer_lock_reserve(tr, TRACE_BOOT_CALL,
144 &irq_flags); 148 sizeof(*entry), 0, 0);
145 if (!event) 149 if (!event)
146 goto out; 150 goto out;
147 entry = ring_buffer_event_data(event); 151 entry = ring_buffer_event_data(event);
148 tracing_generic_entry_update(&entry->ent, 0, 0);
149 entry->ent.type = TRACE_BOOT_CALL;
150 entry->boot_call = *bt; 152 entry->boot_call = *bt;
151 ring_buffer_unlock_commit(tr->buffer, event, irq_flags); 153 trace_buffer_unlock_commit(tr, event, 0, 0);
152
153 trace_wake_up();
154
155 out: 154 out:
156 preempt_enable(); 155 preempt_enable();
157} 156}
@@ -160,27 +159,21 @@ void trace_boot_ret(struct boot_trace_ret *bt, initcall_t fn)
160{ 159{
161 struct ring_buffer_event *event; 160 struct ring_buffer_event *event;
162 struct trace_boot_ret *entry; 161 struct trace_boot_ret *entry;
163 unsigned long irq_flags;
164 struct trace_array *tr = boot_trace; 162 struct trace_array *tr = boot_trace;
165 163
166 if (!pre_initcalls_finished) 164 if (!tr || !pre_initcalls_finished)
167 return; 165 return;
168 166
169 sprint_symbol(bt->func, (unsigned long)fn); 167 sprint_symbol(bt->func, (unsigned long)fn);
170 preempt_disable(); 168 preempt_disable();
171 169
172 event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry), 170 event = trace_buffer_lock_reserve(tr, TRACE_BOOT_RET,
173 &irq_flags); 171 sizeof(*entry), 0, 0);
174 if (!event) 172 if (!event)
175 goto out; 173 goto out;
176 entry = ring_buffer_event_data(event); 174 entry = ring_buffer_event_data(event);
177 tracing_generic_entry_update(&entry->ent, 0, 0);
178 entry->ent.type = TRACE_BOOT_RET;
179 entry->boot_ret = *bt; 175 entry->boot_ret = *bt;
180 ring_buffer_unlock_commit(tr->buffer, event, irq_flags); 176 trace_buffer_unlock_commit(tr, event, 0, 0);
181
182 trace_wake_up();
183
184 out: 177 out:
185 preempt_enable(); 178 preempt_enable();
186} 179}