blob: 98ea6d28df15d4093ad9b9744b07ec1522191c7c [file] [log] [blame]
Steven Rostedt (VMware)bcea3f92018-08-16 11:23:53 -04001// SPDX-License-Identifier: GPL-2.0
Steven Rostedt81d68a92008-05-12 21:20:42 +02002/*
Wenji Huang73d8b8b2009-02-17 01:10:02 -05003 * trace irqs off critical timings
Steven Rostedt81d68a92008-05-12 21:20:42 +02004 *
5 * Copyright (C) 2007-2008 Steven Rostedt <srostedt@redhat.com>
6 * Copyright (C) 2008 Ingo Molnar <mingo@redhat.com>
7 *
8 * From code in the latency_tracer, that is:
9 *
10 * Copyright (C) 2004-2006 Ingo Molnar
Nadia Yvette Chambers6d49e352012-12-06 10:39:54 +010011 * Copyright (C) 2004 Nadia Yvette Chambers
Steven Rostedt81d68a92008-05-12 21:20:42 +020012 */
13#include <linux/kallsyms.h>
Steven Rostedt81d68a92008-05-12 21:20:42 +020014#include <linux/uaccess.h>
15#include <linux/module.h>
16#include <linux/ftrace.h>
Steven Rostedt81d68a92008-05-12 21:20:42 +020017
18#include "trace.h"
19
Joel Fernandesd5915812017-10-10 15:51:37 -070020#include <trace/events/preemptirq.h>
21
Joel Fernandesaaecaa02017-10-05 17:54:31 -070022#if defined(CONFIG_IRQSOFF_TRACER) || defined(CONFIG_PREEMPT_TRACER)
Steven Rostedt81d68a92008-05-12 21:20:42 +020023static struct trace_array *irqsoff_trace __read_mostly;
24static int tracer_enabled __read_mostly;
25
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +020026static DEFINE_PER_CPU(int, tracing_cpu);
27
Thomas Gleixner5389f6f2009-07-25 17:13:33 +020028static DEFINE_RAW_SPINLOCK(max_trace_lock);
Steven Rostedt89b2f972008-05-12 21:20:44 +020029
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +020030enum {
31 TRACER_IRQS_OFF = (1 << 1),
32 TRACER_PREEMPT_OFF = (1 << 2),
33};
34
35static int trace_type __read_mostly;
36
Steven Rostedt (Red Hat)613f04a2013-03-14 15:03:53 -040037static int save_flags;
Steven Rostedte9d25fe2009-03-04 22:15:30 -050038
Jiri Olsa62b915f2010-04-02 19:01:22 +020039static void stop_irqsoff_tracer(struct trace_array *tr, int graph);
40static int start_irqsoff_tracer(struct trace_array *tr, int graph);
41
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +020042#ifdef CONFIG_PREEMPT_TRACER
Ingo Molnare309b412008-05-12 21:20:51 +020043static inline int
Steven Rostedt (VMware)f27107f2018-08-07 17:03:12 -040044preempt_trace(int pc)
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +020045{
Steven Rostedt (VMware)f27107f2018-08-07 17:03:12 -040046 return ((trace_type & TRACER_PREEMPT_OFF) && pc);
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +020047}
48#else
Steven Rostedt (VMware)f27107f2018-08-07 17:03:12 -040049# define preempt_trace(pc) (0)
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +020050#endif
51
52#ifdef CONFIG_IRQSOFF_TRACER
Ingo Molnare309b412008-05-12 21:20:51 +020053static inline int
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +020054irq_trace(void)
55{
56 return ((trace_type & TRACER_IRQS_OFF) &&
57 irqs_disabled());
58}
59#else
60# define irq_trace() (0)
61#endif
62
Jiri Olsa62b915f2010-04-02 19:01:22 +020063#ifdef CONFIG_FUNCTION_GRAPH_TRACER
Steven Rostedt (Red Hat)03905582015-09-28 15:37:49 -040064static int irqsoff_display_graph(struct trace_array *tr, int set);
Steven Rostedt (Red Hat)983f9382015-09-30 09:42:05 -040065# define is_graph(tr) ((tr)->trace_flags & TRACE_ITER_DISPLAY_GRAPH)
Steven Rostedt (Red Hat)03905582015-09-28 15:37:49 -040066#else
67static inline int irqsoff_display_graph(struct trace_array *tr, int set)
68{
69 return -EINVAL;
70}
Steven Rostedt (Red Hat)983f9382015-09-30 09:42:05 -040071# define is_graph(tr) false
Jiri Olsa62b915f2010-04-02 19:01:22 +020072#endif
Jiri Olsa62b915f2010-04-02 19:01:22 +020073
Steven Rostedt81d68a92008-05-12 21:20:42 +020074/*
75 * Sequence count - we record it when starting a measurement and
76 * skip the latency if the sequence has changed - some other section
77 * did a maximum and could disturb our measurement with serial console
78 * printouts, etc. Truly coinciding maximum latencies should be rare
Lucas De Marchi25985ed2011-03-30 22:57:33 -030079 * and what happens together happens separately as well, so this doesn't
Steven Rostedt81d68a92008-05-12 21:20:42 +020080 * decrease the validity of the maximum found:
81 */
82static __cacheline_aligned_in_smp unsigned long max_sequence;
83
Steven Rostedt606576c2008-10-06 19:06:12 -040084#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedt81d68a92008-05-12 21:20:42 +020085/*
Steven Rostedt5e6d2b92010-10-05 19:41:43 -040086 * Prologue for the preempt and irqs off function tracers.
87 *
88 * Returns 1 if it is OK to continue, and data->disabled is
89 * incremented.
90 * 0 if the trace is to be ignored, and data->disabled
91 * is kept the same.
92 *
93 * Note, this function is also used outside this ifdef but
94 * inside the #ifdef of the function graph tracer below.
95 * This is OK, since the function graph tracer is
96 * dependent on the function tracer.
Steven Rostedt81d68a92008-05-12 21:20:42 +020097 */
Steven Rostedt5e6d2b92010-10-05 19:41:43 -040098static int func_prolog_dec(struct trace_array *tr,
99 struct trace_array_cpu **data,
100 unsigned long *flags)
Steven Rostedt81d68a92008-05-12 21:20:42 +0200101{
Steven Rostedt81d68a92008-05-12 21:20:42 +0200102 long disabled;
103 int cpu;
104
Steven Rostedt361943a2008-05-12 21:20:44 +0200105 /*
106 * Does not matter if we preempt. We test the flags
107 * afterward, to see if irqs are disabled or not.
108 * If we preempt and get a false positive, the flags
109 * test will fail.
110 */
111 cpu = raw_smp_processor_id();
112 if (likely(!per_cpu(tracing_cpu, cpu)))
Steven Rostedt5e6d2b92010-10-05 19:41:43 -0400113 return 0;
Steven Rostedt81d68a92008-05-12 21:20:42 +0200114
Steven Rostedt5e6d2b92010-10-05 19:41:43 -0400115 local_save_flags(*flags);
Steven Rostedt (Red Hat)cb86e052016-03-18 12:27:43 -0400116 /*
117 * Slight chance to get a false positive on tracing_cpu,
118 * although I'm starting to think there isn't a chance.
119 * Leave this for now just to be paranoid.
120 */
121 if (!irqs_disabled_flags(*flags) && !preempt_count())
Steven Rostedt5e6d2b92010-10-05 19:41:43 -0400122 return 0;
Steven Rostedt81d68a92008-05-12 21:20:42 +0200123
Steven Rostedt (Red Hat)12883ef2013-03-05 09:24:35 -0500124 *data = per_cpu_ptr(tr->trace_buffer.data, cpu);
Steven Rostedt5e6d2b92010-10-05 19:41:43 -0400125 disabled = atomic_inc_return(&(*data)->disabled);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200126
127 if (likely(disabled == 1))
Steven Rostedt5e6d2b92010-10-05 19:41:43 -0400128 return 1;
129
130 atomic_dec(&(*data)->disabled);
131
132 return 0;
133}
134
135/*
136 * irqsoff uses its own tracer function to keep the overhead down:
137 */
138static void
Steven Rostedt2f5f6ad2011-08-08 16:57:47 -0400139irqsoff_tracer_call(unsigned long ip, unsigned long parent_ip,
Steven Rostedta1e2e312011-08-09 12:50:46 -0400140 struct ftrace_ops *op, struct pt_regs *pt_regs)
Steven Rostedt5e6d2b92010-10-05 19:41:43 -0400141{
142 struct trace_array *tr = irqsoff_trace;
143 struct trace_array_cpu *data;
144 unsigned long flags;
145
146 if (!func_prolog_dec(tr, &data, &flags))
147 return;
148
149 trace_function(tr, ip, parent_ip, flags, preempt_count());
Steven Rostedt81d68a92008-05-12 21:20:42 +0200150
151 atomic_dec(&data->disabled);
152}
Steven Rostedt606576c2008-10-06 19:06:12 -0400153#endif /* CONFIG_FUNCTION_TRACER */
Steven Rostedt81d68a92008-05-12 21:20:42 +0200154
Jiri Olsa62b915f2010-04-02 19:01:22 +0200155#ifdef CONFIG_FUNCTION_GRAPH_TRACER
Steven Rostedt (Red Hat)03905582015-09-28 15:37:49 -0400156static int irqsoff_display_graph(struct trace_array *tr, int set)
Jiri Olsa62b915f2010-04-02 19:01:22 +0200157{
158 int cpu;
159
Steven Rostedt (Red Hat)983f9382015-09-30 09:42:05 -0400160 if (!(is_graph(tr) ^ set))
Jiri Olsa62b915f2010-04-02 19:01:22 +0200161 return 0;
162
163 stop_irqsoff_tracer(irqsoff_trace, !set);
164
165 for_each_possible_cpu(cpu)
166 per_cpu(tracing_cpu, cpu) = 0;
167
Steven Rostedt (Red Hat)6d9b3fa2014-01-14 11:28:38 -0500168 tr->max_latency = 0;
Steven Rostedt (Red Hat)12883ef2013-03-05 09:24:35 -0500169 tracing_reset_online_cpus(&irqsoff_trace->trace_buffer);
Jiri Olsa62b915f2010-04-02 19:01:22 +0200170
171 return start_irqsoff_tracer(irqsoff_trace, set);
172}
173
174static int irqsoff_graph_entry(struct ftrace_graph_ent *trace)
175{
176 struct trace_array *tr = irqsoff_trace;
177 struct trace_array_cpu *data;
178 unsigned long flags;
Jiri Olsa62b915f2010-04-02 19:01:22 +0200179 int ret;
Jiri Olsa62b915f2010-04-02 19:01:22 +0200180 int pc;
181
Steven Rostedt (Red Hat)1a414422016-12-08 19:28:28 -0500182 if (ftrace_graph_ignore_func(trace))
183 return 0;
184 /*
185 * Do not trace a function if it's filtered by set_graph_notrace.
186 * Make the index of ret stack negative to indicate that it should
187 * ignore further functions. But it needs its own ret stack entry
188 * to recover the original index in order to continue tracing after
189 * returning from the function.
190 */
191 if (ftrace_graph_notrace_addr(trace->func))
192 return 1;
193
Steven Rostedt5e6d2b92010-10-05 19:41:43 -0400194 if (!func_prolog_dec(tr, &data, &flags))
Jiri Olsa62b915f2010-04-02 19:01:22 +0200195 return 0;
196
Steven Rostedt5e6d2b92010-10-05 19:41:43 -0400197 pc = preempt_count();
198 ret = __trace_graph_entry(tr, trace, flags, pc);
Jiri Olsa62b915f2010-04-02 19:01:22 +0200199 atomic_dec(&data->disabled);
Steven Rostedt5e6d2b92010-10-05 19:41:43 -0400200
Jiri Olsa62b915f2010-04-02 19:01:22 +0200201 return ret;
202}
203
204static void irqsoff_graph_return(struct ftrace_graph_ret *trace)
205{
206 struct trace_array *tr = irqsoff_trace;
207 struct trace_array_cpu *data;
208 unsigned long flags;
Jiri Olsa62b915f2010-04-02 19:01:22 +0200209 int pc;
210
Steven Rostedt (VMware)5cf99a0f2018-11-29 08:50:27 -0500211 ftrace_graph_addr_finish(trace);
212
Steven Rostedt5e6d2b92010-10-05 19:41:43 -0400213 if (!func_prolog_dec(tr, &data, &flags))
Jiri Olsa62b915f2010-04-02 19:01:22 +0200214 return;
215
Steven Rostedt5e6d2b92010-10-05 19:41:43 -0400216 pc = preempt_count();
217 __trace_graph_return(tr, trace, flags, pc);
Jiri Olsa62b915f2010-04-02 19:01:22 +0200218 atomic_dec(&data->disabled);
219}
220
221static void irqsoff_trace_open(struct trace_iterator *iter)
222{
Steven Rostedt (Red Hat)983f9382015-09-30 09:42:05 -0400223 if (is_graph(iter->tr))
Jiri Olsa62b915f2010-04-02 19:01:22 +0200224 graph_trace_open(iter);
225
226}
227
228static void irqsoff_trace_close(struct trace_iterator *iter)
229{
230 if (iter->private)
231 graph_trace_close(iter);
232}
233
234#define GRAPH_TRACER_FLAGS (TRACE_GRAPH_PRINT_CPU | \
Jiri Olsa321e68b2011-06-03 16:58:47 +0200235 TRACE_GRAPH_PRINT_PROC | \
236 TRACE_GRAPH_PRINT_ABS_TIME | \
237 TRACE_GRAPH_PRINT_DURATION)
Jiri Olsa62b915f2010-04-02 19:01:22 +0200238
239static enum print_line_t irqsoff_print_line(struct trace_iterator *iter)
240{
Jiri Olsa62b915f2010-04-02 19:01:22 +0200241 /*
242 * In graph mode call the graph tracer output function,
243 * otherwise go with the TRACE_FN event handler
244 */
Steven Rostedt (Red Hat)983f9382015-09-30 09:42:05 -0400245 if (is_graph(iter->tr))
Jiri Olsa0a772622010-09-23 14:00:52 +0200246 return print_graph_function_flags(iter, GRAPH_TRACER_FLAGS);
Jiri Olsa62b915f2010-04-02 19:01:22 +0200247
248 return TRACE_TYPE_UNHANDLED;
249}
250
251static void irqsoff_print_header(struct seq_file *s)
252{
Steven Rostedt (Red Hat)983f9382015-09-30 09:42:05 -0400253 struct trace_array *tr = irqsoff_trace;
254
255 if (is_graph(tr))
Jiri Olsa0a772622010-09-23 14:00:52 +0200256 print_graph_headers_flags(s, GRAPH_TRACER_FLAGS);
257 else
Jiri Olsa62b915f2010-04-02 19:01:22 +0200258 trace_default_header(s);
259}
260
261static void
Jiri Olsa62b915f2010-04-02 19:01:22 +0200262__trace_function(struct trace_array *tr,
263 unsigned long ip, unsigned long parent_ip,
264 unsigned long flags, int pc)
265{
Steven Rostedt (Red Hat)983f9382015-09-30 09:42:05 -0400266 if (is_graph(tr))
Jiri Olsa0a772622010-09-23 14:00:52 +0200267 trace_graph_function(tr, ip, parent_ip, flags, pc);
268 else
Jiri Olsa62b915f2010-04-02 19:01:22 +0200269 trace_function(tr, ip, parent_ip, flags, pc);
Jiri Olsa62b915f2010-04-02 19:01:22 +0200270}
271
272#else
273#define __trace_function trace_function
274
Steven Rostedt (Red Hat)8179e8a2015-09-29 10:24:56 -0400275#ifdef CONFIG_FUNCTION_TRACER
Jiri Olsa62b915f2010-04-02 19:01:22 +0200276static int irqsoff_graph_entry(struct ftrace_graph_ent *trace)
277{
278 return -1;
279}
Steven Rostedt (Red Hat)8179e8a2015-09-29 10:24:56 -0400280#endif
Jiri Olsa62b915f2010-04-02 19:01:22 +0200281
282static enum print_line_t irqsoff_print_line(struct trace_iterator *iter)
283{
284 return TRACE_TYPE_UNHANDLED;
285}
286
Jiri Olsa62b915f2010-04-02 19:01:22 +0200287static void irqsoff_trace_open(struct trace_iterator *iter) { }
288static void irqsoff_trace_close(struct trace_iterator *iter) { }
Jiri Olsa7e9a49e2011-11-07 16:08:49 +0100289
290#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedt (Red Hat)8179e8a2015-09-29 10:24:56 -0400291static void irqsoff_graph_return(struct ftrace_graph_ret *trace) { }
Jiri Olsa7e9a49e2011-11-07 16:08:49 +0100292static void irqsoff_print_header(struct seq_file *s)
293{
294 trace_default_header(s);
295}
296#else
297static void irqsoff_print_header(struct seq_file *s)
298{
299 trace_latency_header(s);
300}
301#endif /* CONFIG_FUNCTION_TRACER */
Jiri Olsa62b915f2010-04-02 19:01:22 +0200302#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
303
Steven Rostedt81d68a92008-05-12 21:20:42 +0200304/*
305 * Should this new latency be reported/recorded?
306 */
Thomas Gleixnera5a1d1c2016-12-21 20:32:01 +0100307static bool report_latency(struct trace_array *tr, u64 delta)
Steven Rostedt81d68a92008-05-12 21:20:42 +0200308{
309 if (tracing_thresh) {
310 if (delta < tracing_thresh)
Yaowei Bai79851822015-09-29 22:43:30 +0800311 return false;
Steven Rostedt81d68a92008-05-12 21:20:42 +0200312 } else {
Steven Rostedt (Red Hat)6d9b3fa2014-01-14 11:28:38 -0500313 if (delta <= tr->max_latency)
Yaowei Bai79851822015-09-29 22:43:30 +0800314 return false;
Steven Rostedt81d68a92008-05-12 21:20:42 +0200315 }
Yaowei Bai79851822015-09-29 22:43:30 +0800316 return true;
Steven Rostedt81d68a92008-05-12 21:20:42 +0200317}
318
Ingo Molnare309b412008-05-12 21:20:51 +0200319static void
Steven Rostedt81d68a92008-05-12 21:20:42 +0200320check_critical_timing(struct trace_array *tr,
321 struct trace_array_cpu *data,
322 unsigned long parent_ip,
323 int cpu)
324{
Thomas Gleixnera5a1d1c2016-12-21 20:32:01 +0100325 u64 T0, T1, delta;
Steven Rostedt81d68a92008-05-12 21:20:42 +0200326 unsigned long flags;
Steven Rostedt38697052008-10-01 13:14:09 -0400327 int pc;
Steven Rostedt81d68a92008-05-12 21:20:42 +0200328
Steven Rostedt81d68a92008-05-12 21:20:42 +0200329 T0 = data->preempt_timestamp;
Ingo Molnar750ed1a2008-05-12 21:20:46 +0200330 T1 = ftrace_now(cpu);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200331 delta = T1-T0;
332
333 local_save_flags(flags);
334
Steven Rostedt6450c1d2008-10-02 19:23:04 -0400335 pc = preempt_count();
336
Steven Rostedt (Red Hat)6d9b3fa2014-01-14 11:28:38 -0500337 if (!report_latency(tr, delta))
Steven Rostedt81d68a92008-05-12 21:20:42 +0200338 goto out;
339
Thomas Gleixner5389f6f2009-07-25 17:13:33 +0200340 raw_spin_lock_irqsave(&max_trace_lock, flags);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200341
Steven Rostedt89b2f972008-05-12 21:20:44 +0200342 /* check if we are still the max latency */
Steven Rostedt (Red Hat)6d9b3fa2014-01-14 11:28:38 -0500343 if (!report_latency(tr, delta))
Steven Rostedt89b2f972008-05-12 21:20:44 +0200344 goto out_unlock;
345
Jiri Olsa62b915f2010-04-02 19:01:22 +0200346 __trace_function(tr, CALLER_ADDR0, parent_ip, flags, pc);
Steven Rostedtcc51a0f2009-12-11 11:54:51 -0500347 /* Skip 5 functions to get to the irq/preempt enable function */
348 __trace_stack(tr, flags, 5, pc);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200349
Steven Rostedt81d68a92008-05-12 21:20:42 +0200350 if (data->critical_sequence != max_sequence)
Steven Rostedt89b2f972008-05-12 21:20:44 +0200351 goto out_unlock;
Steven Rostedt81d68a92008-05-12 21:20:42 +0200352
Steven Rostedt81d68a92008-05-12 21:20:42 +0200353 data->critical_end = parent_ip;
354
Carsten Emdeb5130b12009-09-13 01:43:07 +0200355 if (likely(!is_tracing_stopped())) {
Steven Rostedt (Red Hat)6d9b3fa2014-01-14 11:28:38 -0500356 tr->max_latency = delta;
Carsten Emdeb5130b12009-09-13 01:43:07 +0200357 update_max_tr_single(tr, current, cpu);
358 }
Steven Rostedt81d68a92008-05-12 21:20:42 +0200359
Steven Rostedt81d68a92008-05-12 21:20:42 +0200360 max_sequence++;
361
Steven Rostedt89b2f972008-05-12 21:20:44 +0200362out_unlock:
Thomas Gleixner5389f6f2009-07-25 17:13:33 +0200363 raw_spin_unlock_irqrestore(&max_trace_lock, flags);
Steven Rostedt89b2f972008-05-12 21:20:44 +0200364
Steven Rostedt81d68a92008-05-12 21:20:42 +0200365out:
366 data->critical_sequence = max_sequence;
Ingo Molnar750ed1a2008-05-12 21:20:46 +0200367 data->preempt_timestamp = ftrace_now(cpu);
Jiri Olsa62b915f2010-04-02 19:01:22 +0200368 __trace_function(tr, CALLER_ADDR0, parent_ip, flags, pc);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200369}
370
Ingo Molnare309b412008-05-12 21:20:51 +0200371static inline void
Steven Rostedt (VMware)f27107f2018-08-07 17:03:12 -0400372start_critical_timing(unsigned long ip, unsigned long parent_ip, int pc)
Steven Rostedt81d68a92008-05-12 21:20:42 +0200373{
374 int cpu;
375 struct trace_array *tr = irqsoff_trace;
376 struct trace_array_cpu *data;
377 unsigned long flags;
378
Steven Rostedt (Red Hat)10246fa2013-07-01 15:58:24 -0400379 if (!tracer_enabled || !tracing_is_enabled())
Steven Rostedt81d68a92008-05-12 21:20:42 +0200380 return;
381
Steven Rostedtc5f888c2008-05-12 21:20:55 +0200382 cpu = raw_smp_processor_id();
383
384 if (per_cpu(tracing_cpu, cpu))
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200385 return;
386
Steven Rostedt (Red Hat)12883ef2013-03-05 09:24:35 -0500387 data = per_cpu_ptr(tr->trace_buffer.data, cpu);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200388
Steven Rostedtc5f888c2008-05-12 21:20:55 +0200389 if (unlikely(!data) || atomic_read(&data->disabled))
Steven Rostedt81d68a92008-05-12 21:20:42 +0200390 return;
391
392 atomic_inc(&data->disabled);
393
394 data->critical_sequence = max_sequence;
Ingo Molnar750ed1a2008-05-12 21:20:46 +0200395 data->preempt_timestamp = ftrace_now(cpu);
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200396 data->critical_start = parent_ip ? : ip;
Steven Rostedt81d68a92008-05-12 21:20:42 +0200397
398 local_save_flags(flags);
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200399
Steven Rostedt (VMware)f27107f2018-08-07 17:03:12 -0400400 __trace_function(tr, ip, parent_ip, flags, pc);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200401
Steven Rostedtc5f888c2008-05-12 21:20:55 +0200402 per_cpu(tracing_cpu, cpu) = 1;
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200403
Steven Rostedt81d68a92008-05-12 21:20:42 +0200404 atomic_dec(&data->disabled);
405}
406
Ingo Molnare309b412008-05-12 21:20:51 +0200407static inline void
Steven Rostedt (VMware)f27107f2018-08-07 17:03:12 -0400408stop_critical_timing(unsigned long ip, unsigned long parent_ip, int pc)
Steven Rostedt81d68a92008-05-12 21:20:42 +0200409{
410 int cpu;
411 struct trace_array *tr = irqsoff_trace;
412 struct trace_array_cpu *data;
413 unsigned long flags;
414
Steven Rostedtc5f888c2008-05-12 21:20:55 +0200415 cpu = raw_smp_processor_id();
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200416 /* Always clear the tracing cpu on stopping the trace */
Steven Rostedtc5f888c2008-05-12 21:20:55 +0200417 if (unlikely(per_cpu(tracing_cpu, cpu)))
418 per_cpu(tracing_cpu, cpu) = 0;
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200419 else
420 return;
421
Steven Rostedt (Red Hat)10246fa2013-07-01 15:58:24 -0400422 if (!tracer_enabled || !tracing_is_enabled())
Steven Rostedt81d68a92008-05-12 21:20:42 +0200423 return;
424
Steven Rostedt (Red Hat)12883ef2013-03-05 09:24:35 -0500425 data = per_cpu_ptr(tr->trace_buffer.data, cpu);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200426
Steven Rostedt3928a8a2008-09-29 23:02:41 -0400427 if (unlikely(!data) ||
Steven Rostedt81d68a92008-05-12 21:20:42 +0200428 !data->critical_start || atomic_read(&data->disabled))
429 return;
430
431 atomic_inc(&data->disabled);
Steven Rostedtc5f888c2008-05-12 21:20:55 +0200432
Steven Rostedt81d68a92008-05-12 21:20:42 +0200433 local_save_flags(flags);
Steven Rostedt (VMware)f27107f2018-08-07 17:03:12 -0400434 __trace_function(tr, ip, parent_ip, flags, pc);
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200435 check_critical_timing(tr, data, parent_ip ? : ip, cpu);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200436 data->critical_start = 0;
437 atomic_dec(&data->disabled);
438}
439
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200440/* start and stop critical timings used to for stoppage (in idle) */
Ingo Molnare309b412008-05-12 21:20:51 +0200441void start_critical_timings(void)
Steven Rostedt81d68a92008-05-12 21:20:42 +0200442{
Steven Rostedt (VMware)f27107f2018-08-07 17:03:12 -0400443 int pc = preempt_count();
444
445 if (preempt_trace(pc) || irq_trace())
446 start_critical_timing(CALLER_ADDR0, CALLER_ADDR1, pc);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200447}
Ingo Molnar1fe37102008-07-26 15:09:47 +0200448EXPORT_SYMBOL_GPL(start_critical_timings);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200449
Ingo Molnare309b412008-05-12 21:20:51 +0200450void stop_critical_timings(void)
Steven Rostedt81d68a92008-05-12 21:20:42 +0200451{
Steven Rostedt (VMware)f27107f2018-08-07 17:03:12 -0400452 int pc = preempt_count();
453
454 if (preempt_trace(pc) || irq_trace())
455 stop_critical_timing(CALLER_ADDR0, CALLER_ADDR1, pc);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200456}
Ingo Molnar1fe37102008-07-26 15:09:47 +0200457EXPORT_SYMBOL_GPL(stop_critical_timings);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200458
Steven Rostedt (Red Hat)8179e8a2015-09-29 10:24:56 -0400459#ifdef CONFIG_FUNCTION_TRACER
460static bool function_enabled;
461
Steven Rostedt (Red Hat)4104d322014-01-10 17:01:58 -0500462static int register_irqsoff_function(struct trace_array *tr, int graph, int set)
Steven Rostedt81d68a92008-05-12 21:20:42 +0200463{
Steven Rostedt (Red Hat)328df472013-03-14 12:10:40 -0400464 int ret;
Jiri Olsa62b915f2010-04-02 19:01:22 +0200465
Steven Rostedt (Red Hat)328df472013-03-14 12:10:40 -0400466 /* 'set' is set if TRACE_ITER_FUNCTION is about to be set */
Steven Rostedt (Red Hat)983f9382015-09-30 09:42:05 -0400467 if (function_enabled || (!set && !(tr->trace_flags & TRACE_ITER_FUNCTION)))
Steven Rostedt (Red Hat)328df472013-03-14 12:10:40 -0400468 return 0;
469
470 if (graph)
Jiri Olsa62b915f2010-04-02 19:01:22 +0200471 ret = register_ftrace_graph(&irqsoff_graph_return,
472 &irqsoff_graph_entry);
Steven Rostedt (Red Hat)328df472013-03-14 12:10:40 -0400473 else
Steven Rostedt (Red Hat)4104d322014-01-10 17:01:58 -0500474 ret = register_ftrace_function(tr->ops);
Steven Rostedt (Red Hat)328df472013-03-14 12:10:40 -0400475
476 if (!ret)
477 function_enabled = true;
478
479 return ret;
480}
481
Steven Rostedt (Red Hat)4104d322014-01-10 17:01:58 -0500482static void unregister_irqsoff_function(struct trace_array *tr, int graph)
Steven Rostedt (Red Hat)328df472013-03-14 12:10:40 -0400483{
484 if (!function_enabled)
485 return;
486
487 if (graph)
488 unregister_ftrace_graph();
489 else
Steven Rostedt (Red Hat)4104d322014-01-10 17:01:58 -0500490 unregister_ftrace_function(tr->ops);
Steven Rostedt (Red Hat)328df472013-03-14 12:10:40 -0400491
492 function_enabled = false;
493}
494
Steven Rostedt (Red Hat)8179e8a2015-09-29 10:24:56 -0400495static int irqsoff_function_set(struct trace_array *tr, u32 mask, int set)
Steven Rostedt (Red Hat)328df472013-03-14 12:10:40 -0400496{
Steven Rostedt (Red Hat)8179e8a2015-09-29 10:24:56 -0400497 if (!(mask & TRACE_ITER_FUNCTION))
498 return 0;
499
Steven Rostedt (Red Hat)328df472013-03-14 12:10:40 -0400500 if (set)
Steven Rostedt (Red Hat)983f9382015-09-30 09:42:05 -0400501 register_irqsoff_function(tr, is_graph(tr), 1);
Steven Rostedt (Red Hat)328df472013-03-14 12:10:40 -0400502 else
Steven Rostedt (Red Hat)983f9382015-09-30 09:42:05 -0400503 unregister_irqsoff_function(tr, is_graph(tr));
Steven Rostedt (Red Hat)8179e8a2015-09-29 10:24:56 -0400504 return 1;
505}
506#else
507static int register_irqsoff_function(struct trace_array *tr, int graph, int set)
508{
Steven Rostedt (Red Hat)03905582015-09-28 15:37:49 -0400509 return 0;
Steven Rostedt (Red Hat)328df472013-03-14 12:10:40 -0400510}
Steven Rostedt (Red Hat)8179e8a2015-09-29 10:24:56 -0400511static void unregister_irqsoff_function(struct trace_array *tr, int graph) { }
512static inline int irqsoff_function_set(struct trace_array *tr, u32 mask, int set)
513{
514 return 0;
515}
516#endif /* CONFIG_FUNCTION_TRACER */
Steven Rostedt (Red Hat)328df472013-03-14 12:10:40 -0400517
Steven Rostedt (Red Hat)bf6065b2014-01-10 17:51:01 -0500518static int irqsoff_flag_changed(struct trace_array *tr, u32 mask, int set)
Steven Rostedt (Red Hat)328df472013-03-14 12:10:40 -0400519{
Steven Rostedt (Red Hat)bf6065b2014-01-10 17:51:01 -0500520 struct tracer *tracer = tr->current_trace;
521
Steven Rostedt (Red Hat)8179e8a2015-09-29 10:24:56 -0400522 if (irqsoff_function_set(tr, mask, set))
523 return 0;
Steven Rostedt (Red Hat)03905582015-09-28 15:37:49 -0400524
Steven Rostedt (Red Hat)729358d2015-09-29 10:15:10 -0400525#ifdef CONFIG_FUNCTION_GRAPH_TRACER
Steven Rostedt (Red Hat)03905582015-09-28 15:37:49 -0400526 if (mask & TRACE_ITER_DISPLAY_GRAPH)
527 return irqsoff_display_graph(tr, set);
Steven Rostedt (Red Hat)729358d2015-09-29 10:15:10 -0400528#endif
Steven Rostedt (Red Hat)328df472013-03-14 12:10:40 -0400529
530 return trace_keep_overwrite(tracer, mask, set);
531}
532
533static int start_irqsoff_tracer(struct trace_array *tr, int graph)
534{
535 int ret;
536
Steven Rostedt (Red Hat)4104d322014-01-10 17:01:58 -0500537 ret = register_irqsoff_function(tr, graph, 0);
Jiri Olsa62b915f2010-04-02 19:01:22 +0200538
539 if (!ret && tracing_is_enabled())
Steven Rostedt90369902008-11-05 16:05:44 -0500540 tracer_enabled = 1;
Steven Rostedt94523e82009-01-22 11:18:06 -0500541 else
Steven Rostedt90369902008-11-05 16:05:44 -0500542 tracer_enabled = 0;
Jiri Olsa62b915f2010-04-02 19:01:22 +0200543
544 return ret;
Steven Rostedt81d68a92008-05-12 21:20:42 +0200545}
546
Jiri Olsa62b915f2010-04-02 19:01:22 +0200547static void stop_irqsoff_tracer(struct trace_array *tr, int graph)
Steven Rostedt81d68a92008-05-12 21:20:42 +0200548{
Steven Rostedt81d68a92008-05-12 21:20:42 +0200549 tracer_enabled = 0;
Jiri Olsa62b915f2010-04-02 19:01:22 +0200550
Steven Rostedt (Red Hat)4104d322014-01-10 17:01:58 -0500551 unregister_irqsoff_function(tr, graph);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200552}
553
Steven Rostedt (Red Hat)02f2f762014-01-14 09:32:58 -0500554static bool irqsoff_busy;
555
556static int __irqsoff_tracer_init(struct trace_array *tr)
Steven Rostedt81d68a92008-05-12 21:20:42 +0200557{
Steven Rostedt (Red Hat)02f2f762014-01-14 09:32:58 -0500558 if (irqsoff_busy)
559 return -EBUSY;
560
Steven Rostedt (Red Hat)983f9382015-09-30 09:42:05 -0400561 save_flags = tr->trace_flags;
Steven Rostedt (Red Hat)613f04a2013-03-14 15:03:53 -0400562
563 /* non overwrite screws up the latency tracers */
Steven Rostedt2b6080f2012-05-11 13:29:49 -0400564 set_tracer_flag(tr, TRACE_ITER_OVERWRITE, 1);
565 set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, 1);
Steven Rostedte9d25fe2009-03-04 22:15:30 -0500566
Steven Rostedt (Red Hat)6d9b3fa2014-01-14 11:28:38 -0500567 tr->max_latency = 0;
Steven Rostedt81d68a92008-05-12 21:20:42 +0200568 irqsoff_trace = tr;
Steven Rostedtc5f888c2008-05-12 21:20:55 +0200569 /* make sure that the tracer is visible */
Steven Rostedt81d68a92008-05-12 21:20:42 +0200570 smp_wmb();
Jiri Olsa62b915f2010-04-02 19:01:22 +0200571
Steven Rostedt (Red Hat)4104d322014-01-10 17:01:58 -0500572 ftrace_init_array_ops(tr, irqsoff_tracer_call);
573
574 /* Only toplevel instance supports graph tracing */
575 if (start_irqsoff_tracer(tr, (tr->flags & TRACE_ARRAY_FL_GLOBAL &&
Steven Rostedt (Red Hat)983f9382015-09-30 09:42:05 -0400576 is_graph(tr))))
Jiri Olsa62b915f2010-04-02 19:01:22 +0200577 printk(KERN_ERR "failed to start irqsoff tracer\n");
Steven Rostedt (Red Hat)02f2f762014-01-14 09:32:58 -0500578
579 irqsoff_busy = true;
580 return 0;
Steven Rostedt81d68a92008-05-12 21:20:42 +0200581}
582
Joel Fernandes (Google)2b27ece2018-06-28 11:21:45 -0700583static void __irqsoff_tracer_reset(struct trace_array *tr)
Steven Rostedt81d68a92008-05-12 21:20:42 +0200584{
Steven Rostedt (Red Hat)613f04a2013-03-14 15:03:53 -0400585 int lat_flag = save_flags & TRACE_ITER_LATENCY_FMT;
586 int overwrite_flag = save_flags & TRACE_ITER_OVERWRITE;
587
Steven Rostedt (Red Hat)983f9382015-09-30 09:42:05 -0400588 stop_irqsoff_tracer(tr, is_graph(tr));
Steven Rostedte9d25fe2009-03-04 22:15:30 -0500589
Steven Rostedt2b6080f2012-05-11 13:29:49 -0400590 set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, lat_flag);
591 set_tracer_flag(tr, TRACE_ITER_OVERWRITE, overwrite_flag);
Steven Rostedt (Red Hat)4104d322014-01-10 17:01:58 -0500592 ftrace_reset_array_ops(tr);
Steven Rostedt (Red Hat)02f2f762014-01-14 09:32:58 -0500593
594 irqsoff_busy = false;
Steven Rostedt81d68a92008-05-12 21:20:42 +0200595}
596
Steven Rostedt90369902008-11-05 16:05:44 -0500597static void irqsoff_tracer_start(struct trace_array *tr)
598{
Steven Rostedt90369902008-11-05 16:05:44 -0500599 tracer_enabled = 1;
Steven Rostedt90369902008-11-05 16:05:44 -0500600}
601
602static void irqsoff_tracer_stop(struct trace_array *tr)
603{
604 tracer_enabled = 0;
Steven Rostedt81d68a92008-05-12 21:20:42 +0200605}
606
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200607#ifdef CONFIG_IRQSOFF_TRACER
Joel Fernandes (Google)c3bc8fd2018-07-30 15:24:23 -0700608/*
609 * We are only interested in hardirq on/off events:
610 */
Steven Rostedt (VMware)3f1756d2018-08-08 21:28:05 -0400611void tracer_hardirqs_on(unsigned long a0, unsigned long a1)
Joel Fernandes (Google)c3bc8fd2018-07-30 15:24:23 -0700612{
Steven Rostedt (VMware)f27107f2018-08-07 17:03:12 -0400613 unsigned int pc = preempt_count();
614
Steven Rostedt (VMware)f27107f2018-08-07 17:03:12 -0400615 if (!preempt_trace(pc) && irq_trace())
616 stop_critical_timing(a0, a1, pc);
Joel Fernandes (Google)c3bc8fd2018-07-30 15:24:23 -0700617}
618
Steven Rostedt (VMware)3f1756d2018-08-08 21:28:05 -0400619void tracer_hardirqs_off(unsigned long a0, unsigned long a1)
Joel Fernandes (Google)c3bc8fd2018-07-30 15:24:23 -0700620{
Steven Rostedt (VMware)f27107f2018-08-07 17:03:12 -0400621 unsigned int pc = preempt_count();
622
Steven Rostedt (VMware)f27107f2018-08-07 17:03:12 -0400623 if (!preempt_trace(pc) && irq_trace())
624 start_critical_timing(a0, a1, pc);
Joel Fernandes (Google)c3bc8fd2018-07-30 15:24:23 -0700625}
626
Frederic Weisbecker1c800252008-11-16 05:57:26 +0100627static int irqsoff_tracer_init(struct trace_array *tr)
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200628{
629 trace_type = TRACER_IRQS_OFF;
630
Steven Rostedt (Red Hat)02f2f762014-01-14 09:32:58 -0500631 return __irqsoff_tracer_init(tr);
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200632}
Joel Fernandes (Google)2b27ece2018-06-28 11:21:45 -0700633
634static void irqsoff_tracer_reset(struct trace_array *tr)
635{
636 __irqsoff_tracer_reset(tr);
637}
638
Steven Rostedt81d68a92008-05-12 21:20:42 +0200639static struct tracer irqsoff_tracer __read_mostly =
640{
641 .name = "irqsoff",
642 .init = irqsoff_tracer_init,
643 .reset = irqsoff_tracer_reset,
Steven Rostedt90369902008-11-05 16:05:44 -0500644 .start = irqsoff_tracer_start,
645 .stop = irqsoff_tracer_stop,
Hiraku Toyookaf43c7382012-10-02 17:27:10 +0900646 .print_max = true,
Jiri Olsa62b915f2010-04-02 19:01:22 +0200647 .print_header = irqsoff_print_header,
648 .print_line = irqsoff_print_line,
Steven Rostedt (Red Hat)328df472013-03-14 12:10:40 -0400649 .flag_changed = irqsoff_flag_changed,
Steven Rostedt60a11772008-05-12 21:20:44 +0200650#ifdef CONFIG_FTRACE_SELFTEST
651 .selftest = trace_selftest_startup_irqsoff,
652#endif
Jiri Olsa62b915f2010-04-02 19:01:22 +0200653 .open = irqsoff_trace_open,
654 .close = irqsoff_trace_close,
Steven Rostedt (Red Hat)02f2f762014-01-14 09:32:58 -0500655 .allow_instances = true,
Hiraku Toyookaf43c7382012-10-02 17:27:10 +0900656 .use_max_tr = true,
Steven Rostedt81d68a92008-05-12 21:20:42 +0200657};
Joel Fernandes (Google)c3bc8fd2018-07-30 15:24:23 -0700658#endif /* CONFIG_IRQSOFF_TRACER */
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200659
660#ifdef CONFIG_PREEMPT_TRACER
Steven Rostedt (VMware)3f1756d2018-08-08 21:28:05 -0400661void tracer_preempt_on(unsigned long a0, unsigned long a1)
Joel Fernandes (Google)c3bc8fd2018-07-30 15:24:23 -0700662{
Steven Rostedt (VMware)f27107f2018-08-07 17:03:12 -0400663 int pc = preempt_count();
664
665 if (preempt_trace(pc) && !irq_trace())
666 stop_critical_timing(a0, a1, pc);
Joel Fernandes (Google)c3bc8fd2018-07-30 15:24:23 -0700667}
668
Steven Rostedt (VMware)3f1756d2018-08-08 21:28:05 -0400669void tracer_preempt_off(unsigned long a0, unsigned long a1)
Joel Fernandes (Google)c3bc8fd2018-07-30 15:24:23 -0700670{
Steven Rostedt (VMware)f27107f2018-08-07 17:03:12 -0400671 int pc = preempt_count();
672
673 if (preempt_trace(pc) && !irq_trace())
674 start_critical_timing(a0, a1, pc);
Joel Fernandes (Google)c3bc8fd2018-07-30 15:24:23 -0700675}
676
Frederic Weisbecker1c800252008-11-16 05:57:26 +0100677static int preemptoff_tracer_init(struct trace_array *tr)
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200678{
679 trace_type = TRACER_PREEMPT_OFF;
680
Steven Rostedt (Red Hat)02f2f762014-01-14 09:32:58 -0500681 return __irqsoff_tracer_init(tr);
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200682}
683
Joel Fernandes (Google)2b27ece2018-06-28 11:21:45 -0700684static void preemptoff_tracer_reset(struct trace_array *tr)
685{
686 __irqsoff_tracer_reset(tr);
687}
688
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200689static struct tracer preemptoff_tracer __read_mostly =
690{
691 .name = "preemptoff",
692 .init = preemptoff_tracer_init,
Joel Fernandes (Google)2b27ece2018-06-28 11:21:45 -0700693 .reset = preemptoff_tracer_reset,
Steven Rostedt90369902008-11-05 16:05:44 -0500694 .start = irqsoff_tracer_start,
695 .stop = irqsoff_tracer_stop,
Hiraku Toyookaf43c7382012-10-02 17:27:10 +0900696 .print_max = true,
Jiri Olsa62b915f2010-04-02 19:01:22 +0200697 .print_header = irqsoff_print_header,
698 .print_line = irqsoff_print_line,
Steven Rostedt (Red Hat)328df472013-03-14 12:10:40 -0400699 .flag_changed = irqsoff_flag_changed,
Steven Rostedt60a11772008-05-12 21:20:44 +0200700#ifdef CONFIG_FTRACE_SELFTEST
701 .selftest = trace_selftest_startup_preemptoff,
702#endif
Jiri Olsa62b915f2010-04-02 19:01:22 +0200703 .open = irqsoff_trace_open,
704 .close = irqsoff_trace_close,
Steven Rostedt (Red Hat)02f2f762014-01-14 09:32:58 -0500705 .allow_instances = true,
Hiraku Toyookaf43c7382012-10-02 17:27:10 +0900706 .use_max_tr = true,
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200707};
Joel Fernandes (Google)c3bc8fd2018-07-30 15:24:23 -0700708#endif /* CONFIG_PREEMPT_TRACER */
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200709
Joel Fernandes (Google)c3bc8fd2018-07-30 15:24:23 -0700710#if defined(CONFIG_IRQSOFF_TRACER) && defined(CONFIG_PREEMPT_TRACER)
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200711
Frederic Weisbecker1c800252008-11-16 05:57:26 +0100712static int preemptirqsoff_tracer_init(struct trace_array *tr)
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200713{
714 trace_type = TRACER_IRQS_OFF | TRACER_PREEMPT_OFF;
715
Steven Rostedt (Red Hat)02f2f762014-01-14 09:32:58 -0500716 return __irqsoff_tracer_init(tr);
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200717}
718
Joel Fernandes (Google)2b27ece2018-06-28 11:21:45 -0700719static void preemptirqsoff_tracer_reset(struct trace_array *tr)
720{
721 __irqsoff_tracer_reset(tr);
722}
723
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200724static struct tracer preemptirqsoff_tracer __read_mostly =
725{
726 .name = "preemptirqsoff",
727 .init = preemptirqsoff_tracer_init,
Joel Fernandes (Google)2b27ece2018-06-28 11:21:45 -0700728 .reset = preemptirqsoff_tracer_reset,
Steven Rostedt90369902008-11-05 16:05:44 -0500729 .start = irqsoff_tracer_start,
730 .stop = irqsoff_tracer_stop,
Hiraku Toyookaf43c7382012-10-02 17:27:10 +0900731 .print_max = true,
Jiri Olsa62b915f2010-04-02 19:01:22 +0200732 .print_header = irqsoff_print_header,
733 .print_line = irqsoff_print_line,
Steven Rostedt (Red Hat)328df472013-03-14 12:10:40 -0400734 .flag_changed = irqsoff_flag_changed,
Steven Rostedt60a11772008-05-12 21:20:44 +0200735#ifdef CONFIG_FTRACE_SELFTEST
736 .selftest = trace_selftest_startup_preemptirqsoff,
737#endif
Jiri Olsa62b915f2010-04-02 19:01:22 +0200738 .open = irqsoff_trace_open,
739 .close = irqsoff_trace_close,
Steven Rostedt (Red Hat)02f2f762014-01-14 09:32:58 -0500740 .allow_instances = true,
Hiraku Toyookaf43c7382012-10-02 17:27:10 +0900741 .use_max_tr = true,
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200742};
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200743#endif
Steven Rostedt81d68a92008-05-12 21:20:42 +0200744
745__init static int init_irqsoff_tracer(void)
746{
Joel Fernandes (Google)c3bc8fd2018-07-30 15:24:23 -0700747#ifdef CONFIG_IRQSOFF_TRACER
748 register_tracer(&irqsoff_tracer);
749#endif
750#ifdef CONFIG_PREEMPT_TRACER
751 register_tracer(&preemptoff_tracer);
752#endif
753#if defined(CONFIG_IRQSOFF_TRACER) && defined(CONFIG_PREEMPT_TRACER)
754 register_tracer(&preemptirqsoff_tracer);
755#endif
Steven Rostedt81d68a92008-05-12 21:20:42 +0200756
757 return 0;
758}
Steven Rostedt6f415672012-10-05 12:13:07 -0400759core_initcall(init_irqsoff_tracer);
Joel Fernandesaaecaa02017-10-05 17:54:31 -0700760#endif /* IRQSOFF_TRACER || PREEMPTOFF_TRACER */