blob: 3aa7eaa2114ce2abc5ae411725c7cfaa71fb137a [file] [log] [blame]
Steven Rostedt81d68a92008-05-12 21:20:42 +02001/*
Wenji Huang73d8b8b2009-02-17 01:10:02 -05002 * trace irqs off critical timings
Steven Rostedt81d68a92008-05-12 21:20:42 +02003 *
4 * Copyright (C) 2007-2008 Steven Rostedt <srostedt@redhat.com>
5 * Copyright (C) 2008 Ingo Molnar <mingo@redhat.com>
6 *
7 * From code in the latency_tracer, that is:
8 *
9 * Copyright (C) 2004-2006 Ingo Molnar
10 * Copyright (C) 2004 William Lee Irwin III
11 */
12#include <linux/kallsyms.h>
13#include <linux/debugfs.h>
14#include <linux/uaccess.h>
15#include <linux/module.h>
16#include <linux/ftrace.h>
17#include <linux/fs.h>
18
19#include "trace.h"
20
21static struct trace_array *irqsoff_trace __read_mostly;
22static int tracer_enabled __read_mostly;
23
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +020024static DEFINE_PER_CPU(int, tracing_cpu);
25
Steven Rostedt89b2f972008-05-12 21:20:44 +020026static DEFINE_SPINLOCK(max_trace_lock);
27
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +020028enum {
29 TRACER_IRQS_OFF = (1 << 1),
30 TRACER_PREEMPT_OFF = (1 << 2),
31};
32
33static int trace_type __read_mostly;
34
Steven Rostedte9d25fe2009-03-04 22:15:30 -050035static int save_lat_flag;
36
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +020037#ifdef CONFIG_PREEMPT_TRACER
Ingo Molnare309b412008-05-12 21:20:51 +020038static inline int
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +020039preempt_trace(void)
40{
41 return ((trace_type & TRACER_PREEMPT_OFF) && preempt_count());
42}
43#else
44# define preempt_trace() (0)
45#endif
46
47#ifdef CONFIG_IRQSOFF_TRACER
Ingo Molnare309b412008-05-12 21:20:51 +020048static inline int
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +020049irq_trace(void)
50{
51 return ((trace_type & TRACER_IRQS_OFF) &&
52 irqs_disabled());
53}
54#else
55# define irq_trace() (0)
56#endif
57
Steven Rostedt81d68a92008-05-12 21:20:42 +020058/*
59 * Sequence count - we record it when starting a measurement and
60 * skip the latency if the sequence has changed - some other section
61 * did a maximum and could disturb our measurement with serial console
62 * printouts, etc. Truly coinciding maximum latencies should be rare
63 * and what happens together happens separately as well, so this doesnt
64 * decrease the validity of the maximum found:
65 */
66static __cacheline_aligned_in_smp unsigned long max_sequence;
67
Steven Rostedt606576c2008-10-06 19:06:12 -040068#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedt81d68a92008-05-12 21:20:42 +020069/*
70 * irqsoff uses its own tracer function to keep the overhead down:
71 */
Ingo Molnare309b412008-05-12 21:20:51 +020072static void
Steven Rostedt81d68a92008-05-12 21:20:42 +020073irqsoff_tracer_call(unsigned long ip, unsigned long parent_ip)
74{
75 struct trace_array *tr = irqsoff_trace;
76 struct trace_array_cpu *data;
77 unsigned long flags;
78 long disabled;
79 int cpu;
80
Steven Rostedt361943a2008-05-12 21:20:44 +020081 /*
82 * Does not matter if we preempt. We test the flags
83 * afterward, to see if irqs are disabled or not.
84 * If we preempt and get a false positive, the flags
85 * test will fail.
86 */
87 cpu = raw_smp_processor_id();
88 if (likely(!per_cpu(tracing_cpu, cpu)))
Steven Rostedt81d68a92008-05-12 21:20:42 +020089 return;
90
91 local_save_flags(flags);
Steven Rostedt361943a2008-05-12 21:20:44 +020092 /* slight chance to get a false positive on tracing_cpu */
93 if (!irqs_disabled_flags(flags))
94 return;
Steven Rostedt81d68a92008-05-12 21:20:42 +020095
Steven Rostedt81d68a92008-05-12 21:20:42 +020096 data = tr->data[cpu];
97 disabled = atomic_inc_return(&data->disabled);
98
99 if (likely(disabled == 1))
Arnaldo Carvalho de Melo7be42152009-02-05 01:13:37 -0500100 trace_function(tr, ip, parent_ip, flags, preempt_count());
Steven Rostedt81d68a92008-05-12 21:20:42 +0200101
102 atomic_dec(&data->disabled);
103}
104
105static struct ftrace_ops trace_ops __read_mostly =
106{
107 .func = irqsoff_tracer_call,
108};
Steven Rostedt606576c2008-10-06 19:06:12 -0400109#endif /* CONFIG_FUNCTION_TRACER */
Steven Rostedt81d68a92008-05-12 21:20:42 +0200110
111/*
112 * Should this new latency be reported/recorded?
113 */
Ingo Molnare309b412008-05-12 21:20:51 +0200114static int report_latency(cycle_t delta)
Steven Rostedt81d68a92008-05-12 21:20:42 +0200115{
116 if (tracing_thresh) {
117 if (delta < tracing_thresh)
118 return 0;
119 } else {
120 if (delta <= tracing_max_latency)
121 return 0;
122 }
123 return 1;
124}
125
Ingo Molnare309b412008-05-12 21:20:51 +0200126static void
Steven Rostedt81d68a92008-05-12 21:20:42 +0200127check_critical_timing(struct trace_array *tr,
128 struct trace_array_cpu *data,
129 unsigned long parent_ip,
130 int cpu)
131{
Steven Rostedt89b2f972008-05-12 21:20:44 +0200132 cycle_t T0, T1, delta;
Steven Rostedt81d68a92008-05-12 21:20:42 +0200133 unsigned long flags;
Steven Rostedt38697052008-10-01 13:14:09 -0400134 int pc;
Steven Rostedt81d68a92008-05-12 21:20:42 +0200135
Steven Rostedt81d68a92008-05-12 21:20:42 +0200136 T0 = data->preempt_timestamp;
Ingo Molnar750ed1a2008-05-12 21:20:46 +0200137 T1 = ftrace_now(cpu);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200138 delta = T1-T0;
139
140 local_save_flags(flags);
141
Steven Rostedt6450c1d2008-10-02 19:23:04 -0400142 pc = preempt_count();
143
Steven Rostedt81d68a92008-05-12 21:20:42 +0200144 if (!report_latency(delta))
145 goto out;
146
Ingo Molnarc7aafc52008-05-12 21:20:45 +0200147 spin_lock_irqsave(&max_trace_lock, flags);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200148
Steven Rostedt89b2f972008-05-12 21:20:44 +0200149 /* check if we are still the max latency */
150 if (!report_latency(delta))
151 goto out_unlock;
152
Arnaldo Carvalho de Melo7be42152009-02-05 01:13:37 -0500153 trace_function(tr, CALLER_ADDR0, parent_ip, flags, pc);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200154
Steven Rostedt81d68a92008-05-12 21:20:42 +0200155 if (data->critical_sequence != max_sequence)
Steven Rostedt89b2f972008-05-12 21:20:44 +0200156 goto out_unlock;
Steven Rostedt81d68a92008-05-12 21:20:42 +0200157
Steven Rostedt81d68a92008-05-12 21:20:42 +0200158 data->critical_end = parent_ip;
159
Carsten Emdeb5130b12009-09-13 01:43:07 +0200160 if (likely(!is_tracing_stopped())) {
161 tracing_max_latency = delta;
162 update_max_tr_single(tr, current, cpu);
163 }
Steven Rostedt81d68a92008-05-12 21:20:42 +0200164
Steven Rostedt81d68a92008-05-12 21:20:42 +0200165 max_sequence++;
166
Steven Rostedt89b2f972008-05-12 21:20:44 +0200167out_unlock:
Ingo Molnarc7aafc52008-05-12 21:20:45 +0200168 spin_unlock_irqrestore(&max_trace_lock, flags);
Steven Rostedt89b2f972008-05-12 21:20:44 +0200169
Steven Rostedt81d68a92008-05-12 21:20:42 +0200170out:
171 data->critical_sequence = max_sequence;
Ingo Molnar750ed1a2008-05-12 21:20:46 +0200172 data->preempt_timestamp = ftrace_now(cpu);
Arnaldo Carvalho de Melo7be42152009-02-05 01:13:37 -0500173 trace_function(tr, CALLER_ADDR0, parent_ip, flags, pc);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200174}
175
Ingo Molnare309b412008-05-12 21:20:51 +0200176static inline void
Steven Rostedt81d68a92008-05-12 21:20:42 +0200177start_critical_timing(unsigned long ip, unsigned long parent_ip)
178{
179 int cpu;
180 struct trace_array *tr = irqsoff_trace;
181 struct trace_array_cpu *data;
182 unsigned long flags;
183
184 if (likely(!tracer_enabled))
185 return;
186
Steven Rostedtc5f888c2008-05-12 21:20:55 +0200187 cpu = raw_smp_processor_id();
188
189 if (per_cpu(tracing_cpu, cpu))
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200190 return;
191
Steven Rostedt81d68a92008-05-12 21:20:42 +0200192 data = tr->data[cpu];
193
Steven Rostedtc5f888c2008-05-12 21:20:55 +0200194 if (unlikely(!data) || atomic_read(&data->disabled))
Steven Rostedt81d68a92008-05-12 21:20:42 +0200195 return;
196
197 atomic_inc(&data->disabled);
198
199 data->critical_sequence = max_sequence;
Ingo Molnar750ed1a2008-05-12 21:20:46 +0200200 data->preempt_timestamp = ftrace_now(cpu);
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200201 data->critical_start = parent_ip ? : ip;
Steven Rostedt81d68a92008-05-12 21:20:42 +0200202
203 local_save_flags(flags);
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200204
Arnaldo Carvalho de Melo7be42152009-02-05 01:13:37 -0500205 trace_function(tr, ip, parent_ip, flags, preempt_count());
Steven Rostedt81d68a92008-05-12 21:20:42 +0200206
Steven Rostedtc5f888c2008-05-12 21:20:55 +0200207 per_cpu(tracing_cpu, cpu) = 1;
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200208
Steven Rostedt81d68a92008-05-12 21:20:42 +0200209 atomic_dec(&data->disabled);
210}
211
Ingo Molnare309b412008-05-12 21:20:51 +0200212static inline void
Steven Rostedt81d68a92008-05-12 21:20:42 +0200213stop_critical_timing(unsigned long ip, unsigned long parent_ip)
214{
215 int cpu;
216 struct trace_array *tr = irqsoff_trace;
217 struct trace_array_cpu *data;
218 unsigned long flags;
219
Steven Rostedtc5f888c2008-05-12 21:20:55 +0200220 cpu = raw_smp_processor_id();
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200221 /* Always clear the tracing cpu on stopping the trace */
Steven Rostedtc5f888c2008-05-12 21:20:55 +0200222 if (unlikely(per_cpu(tracing_cpu, cpu)))
223 per_cpu(tracing_cpu, cpu) = 0;
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200224 else
225 return;
226
227 if (!tracer_enabled)
Steven Rostedt81d68a92008-05-12 21:20:42 +0200228 return;
229
Steven Rostedt81d68a92008-05-12 21:20:42 +0200230 data = tr->data[cpu];
231
Steven Rostedt3928a8a2008-09-29 23:02:41 -0400232 if (unlikely(!data) ||
Steven Rostedt81d68a92008-05-12 21:20:42 +0200233 !data->critical_start || atomic_read(&data->disabled))
234 return;
235
236 atomic_inc(&data->disabled);
Steven Rostedtc5f888c2008-05-12 21:20:55 +0200237
Steven Rostedt81d68a92008-05-12 21:20:42 +0200238 local_save_flags(flags);
Arnaldo Carvalho de Melo7be42152009-02-05 01:13:37 -0500239 trace_function(tr, ip, parent_ip, flags, preempt_count());
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200240 check_critical_timing(tr, data, parent_ip ? : ip, cpu);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200241 data->critical_start = 0;
242 atomic_dec(&data->disabled);
243}
244
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200245/* start and stop critical timings used to for stoppage (in idle) */
Ingo Molnare309b412008-05-12 21:20:51 +0200246void start_critical_timings(void)
Steven Rostedt81d68a92008-05-12 21:20:42 +0200247{
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200248 if (preempt_trace() || irq_trace())
Steven Rostedt81d68a92008-05-12 21:20:42 +0200249 start_critical_timing(CALLER_ADDR0, CALLER_ADDR1);
250}
Ingo Molnar1fe37102008-07-26 15:09:47 +0200251EXPORT_SYMBOL_GPL(start_critical_timings);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200252
Ingo Molnare309b412008-05-12 21:20:51 +0200253void stop_critical_timings(void)
Steven Rostedt81d68a92008-05-12 21:20:42 +0200254{
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200255 if (preempt_trace() || irq_trace())
Steven Rostedt81d68a92008-05-12 21:20:42 +0200256 stop_critical_timing(CALLER_ADDR0, CALLER_ADDR1);
257}
Ingo Molnar1fe37102008-07-26 15:09:47 +0200258EXPORT_SYMBOL_GPL(stop_critical_timings);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200259
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200260#ifdef CONFIG_IRQSOFF_TRACER
Steven Rostedt81d68a92008-05-12 21:20:42 +0200261#ifdef CONFIG_PROVE_LOCKING
Ingo Molnare309b412008-05-12 21:20:51 +0200262void time_hardirqs_on(unsigned long a0, unsigned long a1)
Steven Rostedt81d68a92008-05-12 21:20:42 +0200263{
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200264 if (!preempt_trace() && irq_trace())
Steven Rostedt81d68a92008-05-12 21:20:42 +0200265 stop_critical_timing(a0, a1);
266}
267
Ingo Molnare309b412008-05-12 21:20:51 +0200268void time_hardirqs_off(unsigned long a0, unsigned long a1)
Steven Rostedt81d68a92008-05-12 21:20:42 +0200269{
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200270 if (!preempt_trace() && irq_trace())
Steven Rostedt81d68a92008-05-12 21:20:42 +0200271 start_critical_timing(a0, a1);
272}
273
274#else /* !CONFIG_PROVE_LOCKING */
275
276/*
277 * Stubs:
278 */
279
280void early_boot_irqs_off(void)
281{
282}
283
284void early_boot_irqs_on(void)
285{
286}
287
288void trace_softirqs_on(unsigned long ip)
289{
290}
291
292void trace_softirqs_off(unsigned long ip)
293{
294}
295
Ingo Molnare309b412008-05-12 21:20:51 +0200296inline void print_irqtrace_events(struct task_struct *curr)
Steven Rostedt81d68a92008-05-12 21:20:42 +0200297{
298}
299
300/*
301 * We are only interested in hardirq on/off events:
302 */
Ingo Molnare309b412008-05-12 21:20:51 +0200303void trace_hardirqs_on(void)
Steven Rostedt81d68a92008-05-12 21:20:42 +0200304{
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200305 if (!preempt_trace() && irq_trace())
Steven Rostedt81d68a92008-05-12 21:20:42 +0200306 stop_critical_timing(CALLER_ADDR0, CALLER_ADDR1);
307}
308EXPORT_SYMBOL(trace_hardirqs_on);
309
Ingo Molnare309b412008-05-12 21:20:51 +0200310void trace_hardirqs_off(void)
Steven Rostedt81d68a92008-05-12 21:20:42 +0200311{
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200312 if (!preempt_trace() && irq_trace())
Steven Rostedt81d68a92008-05-12 21:20:42 +0200313 start_critical_timing(CALLER_ADDR0, CALLER_ADDR1);
314}
315EXPORT_SYMBOL(trace_hardirqs_off);
316
Ingo Molnare309b412008-05-12 21:20:51 +0200317void trace_hardirqs_on_caller(unsigned long caller_addr)
Steven Rostedt81d68a92008-05-12 21:20:42 +0200318{
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200319 if (!preempt_trace() && irq_trace())
Steven Rostedt81d68a92008-05-12 21:20:42 +0200320 stop_critical_timing(CALLER_ADDR0, caller_addr);
321}
322EXPORT_SYMBOL(trace_hardirqs_on_caller);
323
Ingo Molnare309b412008-05-12 21:20:51 +0200324void trace_hardirqs_off_caller(unsigned long caller_addr)
Steven Rostedt81d68a92008-05-12 21:20:42 +0200325{
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200326 if (!preempt_trace() && irq_trace())
Steven Rostedt81d68a92008-05-12 21:20:42 +0200327 start_critical_timing(CALLER_ADDR0, caller_addr);
328}
329EXPORT_SYMBOL(trace_hardirqs_off_caller);
330
331#endif /* CONFIG_PROVE_LOCKING */
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200332#endif /* CONFIG_IRQSOFF_TRACER */
333
334#ifdef CONFIG_PREEMPT_TRACER
Ingo Molnare309b412008-05-12 21:20:51 +0200335void trace_preempt_on(unsigned long a0, unsigned long a1)
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200336{
Steven Rostedt1e01cb02008-07-15 09:53:37 -0400337 if (preempt_trace())
338 stop_critical_timing(a0, a1);
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200339}
340
Ingo Molnare309b412008-05-12 21:20:51 +0200341void trace_preempt_off(unsigned long a0, unsigned long a1)
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200342{
Steven Rostedt1e01cb02008-07-15 09:53:37 -0400343 if (preempt_trace())
344 start_critical_timing(a0, a1);
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200345}
346#endif /* CONFIG_PREEMPT_TRACER */
Steven Rostedt81d68a92008-05-12 21:20:42 +0200347
348static void start_irqsoff_tracer(struct trace_array *tr)
349{
Steven Rostedt81d68a92008-05-12 21:20:42 +0200350 register_ftrace_function(&trace_ops);
Steven Rostedt94523e82009-01-22 11:18:06 -0500351 if (tracing_is_enabled())
Steven Rostedt90369902008-11-05 16:05:44 -0500352 tracer_enabled = 1;
Steven Rostedt94523e82009-01-22 11:18:06 -0500353 else
Steven Rostedt90369902008-11-05 16:05:44 -0500354 tracer_enabled = 0;
Steven Rostedt81d68a92008-05-12 21:20:42 +0200355}
356
357static void stop_irqsoff_tracer(struct trace_array *tr)
358{
Steven Rostedt81d68a92008-05-12 21:20:42 +0200359 tracer_enabled = 0;
Steven Rostedt89b2f972008-05-12 21:20:44 +0200360 unregister_ftrace_function(&trace_ops);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200361}
362
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200363static void __irqsoff_tracer_init(struct trace_array *tr)
Steven Rostedt81d68a92008-05-12 21:20:42 +0200364{
Steven Rostedte9d25fe2009-03-04 22:15:30 -0500365 save_lat_flag = trace_flags & TRACE_ITER_LATENCY_FMT;
366 trace_flags |= TRACE_ITER_LATENCY_FMT;
367
Steven Rostedt745b1622009-01-15 23:40:11 -0500368 tracing_max_latency = 0;
Steven Rostedt81d68a92008-05-12 21:20:42 +0200369 irqsoff_trace = tr;
Steven Rostedtc5f888c2008-05-12 21:20:55 +0200370 /* make sure that the tracer is visible */
Steven Rostedt81d68a92008-05-12 21:20:42 +0200371 smp_wmb();
Steven Rostedt2f26ebd2009-09-01 11:06:29 -0400372 tracing_reset_online_cpus(tr);
Steven Rostedtc76f0692008-11-07 22:36:02 -0500373 start_irqsoff_tracer(tr);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200374}
375
376static void irqsoff_tracer_reset(struct trace_array *tr)
377{
Steven Rostedtc76f0692008-11-07 22:36:02 -0500378 stop_irqsoff_tracer(tr);
Steven Rostedte9d25fe2009-03-04 22:15:30 -0500379
380 if (!save_lat_flag)
381 trace_flags &= ~TRACE_ITER_LATENCY_FMT;
Steven Rostedt81d68a92008-05-12 21:20:42 +0200382}
383
Steven Rostedt90369902008-11-05 16:05:44 -0500384static void irqsoff_tracer_start(struct trace_array *tr)
385{
Steven Rostedt90369902008-11-05 16:05:44 -0500386 tracer_enabled = 1;
Steven Rostedt90369902008-11-05 16:05:44 -0500387}
388
389static void irqsoff_tracer_stop(struct trace_array *tr)
390{
391 tracer_enabled = 0;
Steven Rostedt81d68a92008-05-12 21:20:42 +0200392}
393
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200394#ifdef CONFIG_IRQSOFF_TRACER
Frederic Weisbecker1c800252008-11-16 05:57:26 +0100395static int irqsoff_tracer_init(struct trace_array *tr)
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200396{
397 trace_type = TRACER_IRQS_OFF;
398
399 __irqsoff_tracer_init(tr);
Frederic Weisbecker1c800252008-11-16 05:57:26 +0100400 return 0;
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200401}
Steven Rostedt81d68a92008-05-12 21:20:42 +0200402static struct tracer irqsoff_tracer __read_mostly =
403{
404 .name = "irqsoff",
405 .init = irqsoff_tracer_init,
406 .reset = irqsoff_tracer_reset,
Steven Rostedt90369902008-11-05 16:05:44 -0500407 .start = irqsoff_tracer_start,
408 .stop = irqsoff_tracer_stop,
Steven Rostedt81d68a92008-05-12 21:20:42 +0200409 .print_max = 1,
Steven Rostedt60a11772008-05-12 21:20:44 +0200410#ifdef CONFIG_FTRACE_SELFTEST
411 .selftest = trace_selftest_startup_irqsoff,
412#endif
Steven Rostedt81d68a92008-05-12 21:20:42 +0200413};
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200414# define register_irqsoff(trace) register_tracer(&trace)
415#else
416# define register_irqsoff(trace) do { } while (0)
417#endif
418
419#ifdef CONFIG_PREEMPT_TRACER
Frederic Weisbecker1c800252008-11-16 05:57:26 +0100420static int preemptoff_tracer_init(struct trace_array *tr)
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200421{
422 trace_type = TRACER_PREEMPT_OFF;
423
424 __irqsoff_tracer_init(tr);
Frederic Weisbecker1c800252008-11-16 05:57:26 +0100425 return 0;
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200426}
427
428static struct tracer preemptoff_tracer __read_mostly =
429{
430 .name = "preemptoff",
431 .init = preemptoff_tracer_init,
432 .reset = irqsoff_tracer_reset,
Steven Rostedt90369902008-11-05 16:05:44 -0500433 .start = irqsoff_tracer_start,
434 .stop = irqsoff_tracer_stop,
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200435 .print_max = 1,
Steven Rostedt60a11772008-05-12 21:20:44 +0200436#ifdef CONFIG_FTRACE_SELFTEST
437 .selftest = trace_selftest_startup_preemptoff,
438#endif
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200439};
440# define register_preemptoff(trace) register_tracer(&trace)
441#else
442# define register_preemptoff(trace) do { } while (0)
443#endif
444
445#if defined(CONFIG_IRQSOFF_TRACER) && \
446 defined(CONFIG_PREEMPT_TRACER)
447
Frederic Weisbecker1c800252008-11-16 05:57:26 +0100448static int preemptirqsoff_tracer_init(struct trace_array *tr)
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200449{
450 trace_type = TRACER_IRQS_OFF | TRACER_PREEMPT_OFF;
451
452 __irqsoff_tracer_init(tr);
Frederic Weisbecker1c800252008-11-16 05:57:26 +0100453 return 0;
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200454}
455
456static struct tracer preemptirqsoff_tracer __read_mostly =
457{
458 .name = "preemptirqsoff",
459 .init = preemptirqsoff_tracer_init,
460 .reset = irqsoff_tracer_reset,
Steven Rostedt90369902008-11-05 16:05:44 -0500461 .start = irqsoff_tracer_start,
462 .stop = irqsoff_tracer_stop,
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200463 .print_max = 1,
Steven Rostedt60a11772008-05-12 21:20:44 +0200464#ifdef CONFIG_FTRACE_SELFTEST
465 .selftest = trace_selftest_startup_preemptirqsoff,
466#endif
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200467};
468
469# define register_preemptirqsoff(trace) register_tracer(&trace)
470#else
471# define register_preemptirqsoff(trace) do { } while (0)
472#endif
Steven Rostedt81d68a92008-05-12 21:20:42 +0200473
474__init static int init_irqsoff_tracer(void)
475{
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200476 register_irqsoff(irqsoff_tracer);
477 register_preemptoff(preemptoff_tracer);
478 register_preemptirqsoff(preemptirqsoff_tracer);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200479
480 return 0;
481}
482device_initcall(init_irqsoff_tracer);