ring-buffer: fix build error
[deliverable/linux.git] / kernel / trace / trace_boot.c
CommitLineData
d13744cd
FW
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
14static struct trace_array *boot_trace;
15static int trace_boot_enabled;
16
17
18/* Should be started after do_pre_smp_initcalls() in init/main.c */
19void start_boot_trace(void)
20{
21 trace_boot_enabled = 1;
22}
23
24void stop_boot_trace(struct trace_array *tr)
25{
26 trace_boot_enabled = 0;
27}
28
29static 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)
3928a8a2 37 tracing_reset(tr, cpu);
d13744cd
FW
38}
39
40static 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
9e9efffb 48static enum print_line_t initcall_print_line(struct trace_iterator *iter)
d13744cd 49{
9e9efffb 50 int ret;
d13744cd 51 struct trace_entry *entry = iter->ent;
777e208d
SR
52 struct trace_boot *field = (struct trace_boot *)entry;
53 struct boot_trace *it = &field->initcall;
d13744cd
FW
54 struct trace_seq *s = &iter->seq;
55
9e9efffb 56 if (entry->type == TRACE_BOOT) {
d13744cd
FW
57 ret = trace_seq_printf(s, "%pF called from %i "
58 "returned %d after %lld msecs\n",
59 it->func, it->caller, it->result,
60 it->duration);
9e9efffb
FW
61 if (ret)
62 return TRACE_TYPE_HANDLED;
63 else
64 return TRACE_TYPE_PARTIAL_LINE;
65 }
66 return TRACE_TYPE_UNHANDLED;
d13744cd
FW
67}
68
69struct tracer boot_tracer __read_mostly =
70{
71 .name = "initcall",
72 .init = boot_trace_init,
73 .reset = stop_boot_trace,
74 .ctrl_update = boot_trace_ctrl_update,
75 .print_line = initcall_print_line,
76};
77
78
79void trace_boot(struct boot_trace *it)
80{
3928a8a2 81 struct ring_buffer_event *event;
777e208d 82 struct trace_boot *entry;
d13744cd
FW
83 struct trace_array_cpu *data;
84 unsigned long irq_flags;
85 struct trace_array *tr = boot_trace;
86
87 if (!trace_boot_enabled)
88 return;
89
90 preempt_disable();
91 data = tr->data[smp_processor_id()];
92
3928a8a2
SR
93 event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry),
94 &irq_flags);
95 if (!event)
96 goto out;
97 entry = ring_buffer_event_data(event);
38697053 98 tracing_generic_entry_update(&entry->ent, 0, 0);
777e208d
SR
99 entry->ent.type = TRACE_BOOT;
100 entry->initcall = *it;
3928a8a2 101 ring_buffer_unlock_commit(tr->buffer, event, irq_flags);
d13744cd 102
d13744cd
FW
103 trace_wake_up();
104
3928a8a2 105 out:
d13744cd
FW
106 preempt_enable();
107}
This page took 0.028693 seconds and 5 git commands to generate.