]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - kernel/trace/trace_boot.c
ftrace: remove ctrl_update method
[mirror_ubuntu-bionic-kernel.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>
5601020f 11#include <linux/kallsyms.h>
d13744cd
FW
12
13#include "trace.h"
14
15static struct trace_array *boot_trace;
71566a0d 16static bool pre_initcalls_finished;
d13744cd 17
71566a0d
FW
18/* Tells the boot tracer that the pre_smp_initcalls are finished.
19 * So we are ready .
20 * It doesn't enable sched events tracing however.
21 * You have to call enable_boot_trace to do so.
22 */
d13744cd
FW
23void start_boot_trace(void)
24{
71566a0d
FW
25 pre_initcalls_finished = true;
26}
27
28void enable_boot_trace(void)
29{
d7ad44b6 30 if (pre_initcalls_finished)
e168e051 31 tracing_start_sched_switch_record();
d13744cd
FW
32}
33
71566a0d 34void disable_boot_trace(void)
d13744cd 35{
d7ad44b6 36 if (pre_initcalls_finished)
e168e051 37 tracing_stop_sched_switch_record();
d13744cd
FW
38}
39
79a9d461 40static void reset_boot_trace(struct trace_array *tr)
097d036a 41{
75f5c47d
SR
42 int cpu;
43
44 tr->time_start = ftrace_now(tr->cpu);
45
46 for_each_online_cpu(cpu)
47 tracing_reset(tr, cpu);
097d036a
FW
48}
49
d13744cd
FW
50static void boot_trace_init(struct trace_array *tr)
51{
52 int cpu;
53 boot_trace = tr;
54
d13744cd 55 for_each_cpu_mask(cpu, cpu_possible_map)
3928a8a2 56 tracing_reset(tr, cpu);
d7ad44b6 57
e168e051 58 tracing_sched_switch_assign_trace(tr);
d13744cd
FW
59}
60
9e9efffb 61static enum print_line_t initcall_print_line(struct trace_iterator *iter)
d13744cd 62{
9e9efffb 63 int ret;
d13744cd 64 struct trace_entry *entry = iter->ent;
777e208d
SR
65 struct trace_boot *field = (struct trace_boot *)entry;
66 struct boot_trace *it = &field->initcall;
d13744cd 67 struct trace_seq *s = &iter->seq;
cb5ab742
FW
68 struct timespec calltime = ktime_to_timespec(it->calltime);
69 struct timespec rettime = ktime_to_timespec(it->rettime);
d13744cd 70
9e9efffb 71 if (entry->type == TRACE_BOOT) {
8a5d900c 72 ret = trace_seq_printf(s, "[%5ld.%09ld] calling %s @ %i\n",
cb5ab742
FW
73 calltime.tv_sec,
74 calltime.tv_nsec,
75 it->func, it->caller);
76 if (!ret)
9e9efffb 77 return TRACE_TYPE_PARTIAL_LINE;
5601020f 78
8a5d900c 79 ret = trace_seq_printf(s, "[%5ld.%09ld] initcall %s "
cb5ab742
FW
80 "returned %d after %lld msecs\n",
81 rettime.tv_sec,
82 rettime.tv_nsec,
83 it->func, it->result, it->duration);
5601020f 84
cb5ab742
FW
85 if (!ret)
86 return TRACE_TYPE_PARTIAL_LINE;
87 return TRACE_TYPE_HANDLED;
9e9efffb
FW
88 }
89 return TRACE_TYPE_UNHANDLED;
d13744cd
FW
90}
91
92struct tracer boot_tracer __read_mostly =
93{
94 .name = "initcall",
95 .init = boot_trace_init,
097d036a 96 .reset = reset_boot_trace,
d13744cd
FW
97 .print_line = initcall_print_line,
98};
99
5601020f 100void trace_boot(struct boot_trace *it, initcall_t fn)
d13744cd 101{
3928a8a2 102 struct ring_buffer_event *event;
777e208d 103 struct trace_boot *entry;
d13744cd
FW
104 struct trace_array_cpu *data;
105 unsigned long irq_flags;
106 struct trace_array *tr = boot_trace;
107
71566a0d 108 if (!pre_initcalls_finished)
d13744cd
FW
109 return;
110
5601020f
FW
111 /* Get its name now since this function could
112 * disappear because it is in the .init section.
113 */
114 sprint_symbol(it->func, (unsigned long)fn);
d13744cd
FW
115 preempt_disable();
116 data = tr->data[smp_processor_id()];
117
3928a8a2
SR
118 event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry),
119 &irq_flags);
120 if (!event)
121 goto out;
122 entry = ring_buffer_event_data(event);
38697053 123 tracing_generic_entry_update(&entry->ent, 0, 0);
777e208d
SR
124 entry->ent.type = TRACE_BOOT;
125 entry->initcall = *it;
3928a8a2 126 ring_buffer_unlock_commit(tr->buffer, event, irq_flags);
d13744cd 127
d13744cd
FW
128 trace_wake_up();
129
3928a8a2 130 out:
d13744cd
FW
131 preempt_enable();
132}