trace_irqsoff.c 17.5 KB
Newer Older
1
// SPDX-License-Identifier: GPL-2.0
2
/*
3
 * trace irqs off critical timings
4 5 6 7 8 9 10
 *
 * Copyright (C) 2007-2008 Steven Rostedt <srostedt@redhat.com>
 * Copyright (C) 2008 Ingo Molnar <mingo@redhat.com>
 *
 * From code in the latency_tracer, that is:
 *
 *  Copyright (C) 2004-2006 Ingo Molnar
11
 *  Copyright (C) 2004 Nadia Yvette Chambers
12 13 14 15 16 17 18 19
 */
#include <linux/kallsyms.h>
#include <linux/uaccess.h>
#include <linux/module.h>
#include <linux/ftrace.h>

#include "trace.h"

20 21
#include <trace/events/preemptirq.h>

22
#if defined(CONFIG_IRQSOFF_TRACER) || defined(CONFIG_PREEMPT_TRACER)
23 24 25
static struct trace_array		*irqsoff_trace __read_mostly;
static int				tracer_enabled __read_mostly;

26 27
static DEFINE_PER_CPU(int, tracing_cpu);

28
static DEFINE_RAW_SPINLOCK(max_trace_lock);
29

30 31 32 33 34 35 36
enum {
	TRACER_IRQS_OFF		= (1 << 1),
	TRACER_PREEMPT_OFF	= (1 << 2),
};

static int trace_type __read_mostly;

37
static int save_flags;
38

39 40 41
static void stop_irqsoff_tracer(struct trace_array *tr, int graph);
static int start_irqsoff_tracer(struct trace_array *tr, int graph);

42
#ifdef CONFIG_PREEMPT_TRACER
Ingo Molnar's avatar
Ingo Molnar committed
43
static inline int
44
preempt_trace(int pc)
45
{
46
	return ((trace_type & TRACER_PREEMPT_OFF) && pc);
47 48
}
#else
49
# define preempt_trace(pc) (0)
50 51 52
#endif

#ifdef CONFIG_IRQSOFF_TRACER
Ingo Molnar's avatar
Ingo Molnar committed
53
static inline int
54 55 56 57 58 59 60 61 62
irq_trace(void)
{
	return ((trace_type & TRACER_IRQS_OFF) &&
		irqs_disabled());
}
#else
# define irq_trace() (0)
#endif

63
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
64
static int irqsoff_display_graph(struct trace_array *tr, int set);
65
# define is_graph(tr) ((tr)->trace_flags & TRACE_ITER_DISPLAY_GRAPH)
66 67 68 69 70
#else
static inline int irqsoff_display_graph(struct trace_array *tr, int set)
{
	return -EINVAL;
}
71
# define is_graph(tr) false
72 73
#endif

74 75 76 77 78
/*
 * Sequence count - we record it when starting a measurement and
 * skip the latency if the sequence has changed - some other section
 * did a maximum and could disturb our measurement with serial console
 * printouts, etc. Truly coinciding maximum latencies should be rare
Lucas De Marchi's avatar
Lucas De Marchi committed
79
 * and what happens together happens separately as well, so this doesn't
80 81 82 83
 * decrease the validity of the maximum found:
 */
static __cacheline_aligned_in_smp	unsigned long max_sequence;

84
#ifdef CONFIG_FUNCTION_TRACER
85
/*
86 87 88 89 90 91 92 93 94 95 96
 * Prologue for the preempt and irqs off function tracers.
 *
 * Returns 1 if it is OK to continue, and data->disabled is
 *            incremented.
 *         0 if the trace is to be ignored, and data->disabled
 *            is kept the same.
 *
 * Note, this function is also used outside this ifdef but
 *  inside the #ifdef of the function graph tracer below.
 *  This is OK, since the function graph tracer is
 *  dependent on the function tracer.
97
 */
98 99 100
static int func_prolog_dec(struct trace_array *tr,
			   struct trace_array_cpu **data,
			   unsigned long *flags)
101 102 103 104
{
	long disabled;
	int cpu;

105 106 107 108 109 110 111 112
	/*
	 * Does not matter if we preempt. We test the flags
	 * afterward, to see if irqs are disabled or not.
	 * If we preempt and get a false positive, the flags
	 * test will fail.
	 */
	cpu = raw_smp_processor_id();
	if (likely(!per_cpu(tracing_cpu, cpu)))
113
		return 0;
114

115
	local_save_flags(*flags);
116 117 118 119 120 121
	/*
	 * Slight chance to get a false positive on tracing_cpu,
	 * although I'm starting to think there isn't a chance.
	 * Leave this for now just to be paranoid.
	 */
	if (!irqs_disabled_flags(*flags) && !preempt_count())
122
		return 0;
123

124
	*data = per_cpu_ptr(tr->trace_buffer.data, cpu);
125
	disabled = atomic_inc_return(&(*data)->disabled);
126 127

	if (likely(disabled == 1))
128 129 130 131 132 133 134 135 136 137 138
		return 1;

	atomic_dec(&(*data)->disabled);

	return 0;
}

/*
 * irqsoff uses its own tracer function to keep the overhead down:
 */
static void
139
irqsoff_tracer_call(unsigned long ip, unsigned long parent_ip,
140
		    struct ftrace_ops *op, struct pt_regs *pt_regs)
141 142 143 144 145 146 147 148 149
{
	struct trace_array *tr = irqsoff_trace;
	struct trace_array_cpu *data;
	unsigned long flags;

	if (!func_prolog_dec(tr, &data, &flags))
		return;

	trace_function(tr, ip, parent_ip, flags, preempt_count());
150 151 152

	atomic_dec(&data->disabled);
}
153
#endif /* CONFIG_FUNCTION_TRACER */
154

155
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
156
static int irqsoff_display_graph(struct trace_array *tr, int set)
157 158 159
{
	int cpu;

160
	if (!(is_graph(tr) ^ set))
161 162 163 164 165 166 167
		return 0;

	stop_irqsoff_tracer(irqsoff_trace, !set);

	for_each_possible_cpu(cpu)
		per_cpu(tracing_cpu, cpu) = 0;

168
	tr->max_latency = 0;
169
	tracing_reset_online_cpus(&irqsoff_trace->trace_buffer);
170 171 172 173 174 175 176 177 178 179 180 181

	return start_irqsoff_tracer(irqsoff_trace, set);
}

static int irqsoff_graph_entry(struct ftrace_graph_ent *trace)
{
	struct trace_array *tr = irqsoff_trace;
	struct trace_array_cpu *data;
	unsigned long flags;
	int ret;
	int pc;

182 183 184 185 186 187 188 189 190 191 192 193
	if (ftrace_graph_ignore_func(trace))
		return 0;
	/*
	 * Do not trace a function if it's filtered by set_graph_notrace.
	 * Make the index of ret stack negative to indicate that it should
	 * ignore further functions.  But it needs its own ret stack entry
	 * to recover the original index in order to continue tracing after
	 * returning from the function.
	 */
	if (ftrace_graph_notrace_addr(trace->func))
		return 1;

194
	if (!func_prolog_dec(tr, &data, &flags))
195 196
		return 0;

197 198
	pc = preempt_count();
	ret = __trace_graph_entry(tr, trace, flags, pc);
199
	atomic_dec(&data->disabled);
200

201 202 203 204 205 206 207 208 209 210
	return ret;
}

static void irqsoff_graph_return(struct ftrace_graph_ret *trace)
{
	struct trace_array *tr = irqsoff_trace;
	struct trace_array_cpu *data;
	unsigned long flags;
	int pc;

211 212
	ftrace_graph_addr_finish(trace);

213
	if (!func_prolog_dec(tr, &data, &flags))
214 215
		return;

216 217
	pc = preempt_count();
	__trace_graph_return(tr, trace, flags, pc);
218 219 220 221 222
	atomic_dec(&data->disabled);
}

static void irqsoff_trace_open(struct trace_iterator *iter)
{
223
	if (is_graph(iter->tr))
224 225 226 227 228 229 230 231 232 233 234
		graph_trace_open(iter);

}

static void irqsoff_trace_close(struct trace_iterator *iter)
{
	if (iter->private)
		graph_trace_close(iter);
}

#define GRAPH_TRACER_FLAGS (TRACE_GRAPH_PRINT_CPU | \
235 236 237
			    TRACE_GRAPH_PRINT_PROC | \
			    TRACE_GRAPH_PRINT_ABS_TIME | \
			    TRACE_GRAPH_PRINT_DURATION)
238 239 240 241 242 243 244

static enum print_line_t irqsoff_print_line(struct trace_iterator *iter)
{
	/*
	 * In graph mode call the graph tracer output function,
	 * otherwise go with the TRACE_FN event handler
	 */
245
	if (is_graph(iter->tr))
246
		return print_graph_function_flags(iter, GRAPH_TRACER_FLAGS);
247 248 249 250 251 252

	return TRACE_TYPE_UNHANDLED;
}

static void irqsoff_print_header(struct seq_file *s)
{
253 254 255
	struct trace_array *tr = irqsoff_trace;

	if (is_graph(tr))
256 257
		print_graph_headers_flags(s, GRAPH_TRACER_FLAGS);
	else
258 259 260 261 262 263 264 265
		trace_default_header(s);
}

static void
__trace_function(struct trace_array *tr,
		 unsigned long ip, unsigned long parent_ip,
		 unsigned long flags, int pc)
{
266
	if (is_graph(tr))
267 268
		trace_graph_function(tr, ip, parent_ip, flags, pc);
	else
269 270 271 272 273 274
		trace_function(tr, ip, parent_ip, flags, pc);
}

#else
#define __trace_function trace_function

275
#ifdef CONFIG_FUNCTION_TRACER
276 277 278 279
static int irqsoff_graph_entry(struct ftrace_graph_ent *trace)
{
	return -1;
}
280
#endif
281 282 283 284 285 286 287 288

static enum print_line_t irqsoff_print_line(struct trace_iterator *iter)
{
	return TRACE_TYPE_UNHANDLED;
}

static void irqsoff_trace_open(struct trace_iterator *iter) { }
static void irqsoff_trace_close(struct trace_iterator *iter) { }
289 290

#ifdef CONFIG_FUNCTION_TRACER
291
static void irqsoff_graph_return(struct ftrace_graph_ret *trace) { }
292 293 294 295 296 297 298 299 300 301
static void irqsoff_print_header(struct seq_file *s)
{
	trace_default_header(s);
}
#else
static void irqsoff_print_header(struct seq_file *s)
{
	trace_latency_header(s);
}
#endif /* CONFIG_FUNCTION_TRACER */
302 303
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */

304 305 306
/*
 * Should this new latency be reported/recorded?
 */
307
static bool report_latency(struct trace_array *tr, u64 delta)
308 309 310
{
	if (tracing_thresh) {
		if (delta < tracing_thresh)
311
			return false;
312
	} else {
313
		if (delta <= tr->max_latency)
314
			return false;
315
	}
316
	return true;
317 318
}

Ingo Molnar's avatar
Ingo Molnar committed
319
static void
320 321 322 323 324
check_critical_timing(struct trace_array *tr,
		      struct trace_array_cpu *data,
		      unsigned long parent_ip,
		      int cpu)
{
325
	u64 T0, T1, delta;
326
	unsigned long flags;
327
	int pc;
328 329

	T0 = data->preempt_timestamp;
330
	T1 = ftrace_now(cpu);
331 332 333 334
	delta = T1-T0;

	local_save_flags(flags);

335 336
	pc = preempt_count();

337
	if (!report_latency(tr, delta))
338 339
		goto out;

340
	raw_spin_lock_irqsave(&max_trace_lock, flags);
341

342
	/* check if we are still the max latency */
343
	if (!report_latency(tr, delta))
344 345
		goto out_unlock;

346
	__trace_function(tr, CALLER_ADDR0, parent_ip, flags, pc);
347 348
	/* Skip 5 functions to get to the irq/preempt enable function */
	__trace_stack(tr, flags, 5, pc);
349 350

	if (data->critical_sequence != max_sequence)
351
		goto out_unlock;
352 353 354

	data->critical_end = parent_ip;

355
	if (likely(!is_tracing_stopped())) {
356
		tr->max_latency = delta;
357 358
		update_max_tr_single(tr, current, cpu);
	}
359 360 361

	max_sequence++;

362
out_unlock:
363
	raw_spin_unlock_irqrestore(&max_trace_lock, flags);
364

365 366
out:
	data->critical_sequence = max_sequence;
367
	data->preempt_timestamp = ftrace_now(cpu);
368
	__trace_function(tr, CALLER_ADDR0, parent_ip, flags, pc);
369 370
}

Ingo Molnar's avatar
Ingo Molnar committed
371
static inline void
372
start_critical_timing(unsigned long ip, unsigned long parent_ip, int pc)
373 374 375 376 377 378
{
	int cpu;
	struct trace_array *tr = irqsoff_trace;
	struct trace_array_cpu *data;
	unsigned long flags;

379
	if (!tracer_enabled || !tracing_is_enabled())
380 381
		return;

382 383 384
	cpu = raw_smp_processor_id();

	if (per_cpu(tracing_cpu, cpu))
385 386
		return;

387
	data = per_cpu_ptr(tr->trace_buffer.data, cpu);
388

389
	if (unlikely(!data) || atomic_read(&data->disabled))
390 391 392 393 394
		return;

	atomic_inc(&data->disabled);

	data->critical_sequence = max_sequence;
395
	data->preempt_timestamp = ftrace_now(cpu);
396
	data->critical_start = parent_ip ? : ip;
397 398

	local_save_flags(flags);
399

400
	__trace_function(tr, ip, parent_ip, flags, pc);
401

402
	per_cpu(tracing_cpu, cpu) = 1;
403

404 405 406
	atomic_dec(&data->disabled);
}

Ingo Molnar's avatar
Ingo Molnar committed
407
static inline void
408
stop_critical_timing(unsigned long ip, unsigned long parent_ip, int pc)
409 410 411 412 413 414
{
	int cpu;
	struct trace_array *tr = irqsoff_trace;
	struct trace_array_cpu *data;
	unsigned long flags;

415
	cpu = raw_smp_processor_id();
416
	/* Always clear the tracing cpu on stopping the trace */
417 418
	if (unlikely(per_cpu(tracing_cpu, cpu)))
		per_cpu(tracing_cpu, cpu) = 0;
419 420 421
	else
		return;

422
	if (!tracer_enabled || !tracing_is_enabled())
423 424
		return;

425
	data = per_cpu_ptr(tr->trace_buffer.data, cpu);
426

427
	if (unlikely(!data) ||
428 429 430 431
	    !data->critical_start || atomic_read(&data->disabled))
		return;

	atomic_inc(&data->disabled);
432

433
	local_save_flags(flags);
434
	__trace_function(tr, ip, parent_ip, flags, pc);
435
	check_critical_timing(tr, data, parent_ip ? : ip, cpu);
436 437 438 439
	data->critical_start = 0;
	atomic_dec(&data->disabled);
}

440
/* start and stop critical timings used to for stoppage (in idle) */
Ingo Molnar's avatar
Ingo Molnar committed
441
void start_critical_timings(void)
442
{
443 444 445 446
	int pc = preempt_count();

	if (preempt_trace(pc) || irq_trace())
		start_critical_timing(CALLER_ADDR0, CALLER_ADDR1, pc);
447
}
Ingo Molnar's avatar
Ingo Molnar committed
448
EXPORT_SYMBOL_GPL(start_critical_timings);
449

Ingo Molnar's avatar
Ingo Molnar committed
450
void stop_critical_timings(void)
451
{
452 453 454 455
	int pc = preempt_count();

	if (preempt_trace(pc) || irq_trace())
		stop_critical_timing(CALLER_ADDR0, CALLER_ADDR1, pc);
456
}
Ingo Molnar's avatar
Ingo Molnar committed
457
EXPORT_SYMBOL_GPL(stop_critical_timings);
458

459 460 461
#ifdef CONFIG_FUNCTION_TRACER
static bool function_enabled;

462
static int register_irqsoff_function(struct trace_array *tr, int graph, int set)
463
{
464
	int ret;
465

466
	/* 'set' is set if TRACE_ITER_FUNCTION is about to be set */
467
	if (function_enabled || (!set && !(tr->trace_flags & TRACE_ITER_FUNCTION)))
468 469 470
		return 0;

	if (graph)
471 472
		ret = register_ftrace_graph(&irqsoff_graph_return,
					    &irqsoff_graph_entry);
473
	else
474
		ret = register_ftrace_function(tr->ops);
475 476 477 478 479 480 481

	if (!ret)
		function_enabled = true;

	return ret;
}

482
static void unregister_irqsoff_function(struct trace_array *tr, int graph)
483 484 485 486 487 488 489
{
	if (!function_enabled)
		return;

	if (graph)
		unregister_ftrace_graph();
	else
490
		unregister_ftrace_function(tr->ops);
491 492 493 494

	function_enabled = false;
}

495
static int irqsoff_function_set(struct trace_array *tr, u32 mask, int set)
496
{
497 498 499
	if (!(mask & TRACE_ITER_FUNCTION))
		return 0;

500
	if (set)
501
		register_irqsoff_function(tr, is_graph(tr), 1);
502
	else
503
		unregister_irqsoff_function(tr, is_graph(tr));
504 505 506 507 508
	return 1;
}
#else
static int register_irqsoff_function(struct trace_array *tr, int graph, int set)
{
509
	return 0;
510
}
511 512 513 514 515 516
static void unregister_irqsoff_function(struct trace_array *tr, int graph) { }
static inline int irqsoff_function_set(struct trace_array *tr, u32 mask, int set)
{
	return 0;
}
#endif /* CONFIG_FUNCTION_TRACER */
517

518
static int irqsoff_flag_changed(struct trace_array *tr, u32 mask, int set)
519
{
520 521
	struct tracer *tracer = tr->current_trace;

522 523
	if (irqsoff_function_set(tr, mask, set))
		return 0;
524

525
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
526 527
	if (mask & TRACE_ITER_DISPLAY_GRAPH)
		return irqsoff_display_graph(tr, set);
528
#endif
529 530 531 532 533 534 535 536

	return trace_keep_overwrite(tracer, mask, set);
}

static int start_irqsoff_tracer(struct trace_array *tr, int graph)
{
	int ret;

537
	ret = register_irqsoff_function(tr, graph, 0);
538 539

	if (!ret && tracing_is_enabled())
540
		tracer_enabled = 1;
541
	else
542
		tracer_enabled = 0;
543 544

	return ret;
545 546
}

547
static void stop_irqsoff_tracer(struct trace_array *tr, int graph)
548 549
{
	tracer_enabled = 0;
550

551
	unregister_irqsoff_function(tr, graph);
552 553
}

554 555 556
static bool irqsoff_busy;

static int __irqsoff_tracer_init(struct trace_array *tr)
557
{
558 559 560
	if (irqsoff_busy)
		return -EBUSY;

561
	save_flags = tr->trace_flags;
562 563

	/* non overwrite screws up the latency tracers */
564 565
	set_tracer_flag(tr, TRACE_ITER_OVERWRITE, 1);
	set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, 1);
566

567
	tr->max_latency = 0;
568
	irqsoff_trace = tr;
569
	/* make sure that the tracer is visible */
570
	smp_wmb();
571

572 573 574 575
	ftrace_init_array_ops(tr, irqsoff_tracer_call);

	/* Only toplevel instance supports graph tracing */
	if (start_irqsoff_tracer(tr, (tr->flags & TRACE_ARRAY_FL_GLOBAL &&
576
				      is_graph(tr))))
577
		printk(KERN_ERR "failed to start irqsoff tracer\n");
578 579 580

	irqsoff_busy = true;
	return 0;
581 582
}

583
static void __irqsoff_tracer_reset(struct trace_array *tr)
584
{
585 586 587
	int lat_flag = save_flags & TRACE_ITER_LATENCY_FMT;
	int overwrite_flag = save_flags & TRACE_ITER_OVERWRITE;

588
	stop_irqsoff_tracer(tr, is_graph(tr));
589

590 591
	set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, lat_flag);
	set_tracer_flag(tr, TRACE_ITER_OVERWRITE, overwrite_flag);
592
	ftrace_reset_array_ops(tr);
593 594

	irqsoff_busy = false;
595 596
}

597 598 599 600 601 602 603 604
static void irqsoff_tracer_start(struct trace_array *tr)
{
	tracer_enabled = 1;
}

static void irqsoff_tracer_stop(struct trace_array *tr)
{
	tracer_enabled = 0;
605 606
}

607
#ifdef CONFIG_IRQSOFF_TRACER
608 609 610
/*
 * We are only interested in hardirq on/off events:
 */
611
void tracer_hardirqs_on(unsigned long a0, unsigned long a1)
612
{
613 614 615 616
	unsigned int pc = preempt_count();

	if (!preempt_trace(pc) && irq_trace())
		stop_critical_timing(a0, a1, pc);
617 618
}

619
void tracer_hardirqs_off(unsigned long a0, unsigned long a1)
620
{
621 622 623 624
	unsigned int pc = preempt_count();

	if (!preempt_trace(pc) && irq_trace())
		start_critical_timing(a0, a1, pc);
625 626
}

627
static int irqsoff_tracer_init(struct trace_array *tr)
628 629 630
{
	trace_type = TRACER_IRQS_OFF;

631
	return __irqsoff_tracer_init(tr);
632
}
633 634 635 636 637 638

static void irqsoff_tracer_reset(struct trace_array *tr)
{
	__irqsoff_tracer_reset(tr);
}

639 640 641 642 643
static struct tracer irqsoff_tracer __read_mostly =
{
	.name		= "irqsoff",
	.init		= irqsoff_tracer_init,
	.reset		= irqsoff_tracer_reset,
644 645
	.start		= irqsoff_tracer_start,
	.stop		= irqsoff_tracer_stop,
646
	.print_max	= true,
647 648
	.print_header   = irqsoff_print_header,
	.print_line     = irqsoff_print_line,
649
	.flag_changed	= irqsoff_flag_changed,
Steven Rostedt's avatar
Steven Rostedt committed
650 651 652
#ifdef CONFIG_FTRACE_SELFTEST
	.selftest    = trace_selftest_startup_irqsoff,
#endif
653 654
	.open           = irqsoff_trace_open,
	.close          = irqsoff_trace_close,
655
	.allow_instances = true,
656
	.use_max_tr	= true,
657
};
658
#endif /*  CONFIG_IRQSOFF_TRACER */
659 660

#ifdef CONFIG_PREEMPT_TRACER
661
void tracer_preempt_on(unsigned long a0, unsigned long a1)
662
{
663 664 665 666
	int pc = preempt_count();

	if (preempt_trace(pc) && !irq_trace())
		stop_critical_timing(a0, a1, pc);
667 668
}

669
void tracer_preempt_off(unsigned long a0, unsigned long a1)
670
{
671 672 673 674
	int pc = preempt_count();

	if (preempt_trace(pc) && !irq_trace())
		start_critical_timing(a0, a1, pc);
675 676
}

677
static int preemptoff_tracer_init(struct trace_array *tr)
678 679 680
{
	trace_type = TRACER_PREEMPT_OFF;

681
	return __irqsoff_tracer_init(tr);
682 683
}

684 685 686 687 688
static void preemptoff_tracer_reset(struct trace_array *tr)
{
	__irqsoff_tracer_reset(tr);
}

689 690 691 692
static struct tracer preemptoff_tracer __read_mostly =
{
	.name		= "preemptoff",
	.init		= preemptoff_tracer_init,
693
	.reset		= preemptoff_tracer_reset,
694 695
	.start		= irqsoff_tracer_start,
	.stop		= irqsoff_tracer_stop,
696
	.print_max	= true,
697 698
	.print_header   = irqsoff_print_header,
	.print_line     = irqsoff_print_line,
699
	.flag_changed	= irqsoff_flag_changed,
Steven Rostedt's avatar
Steven Rostedt committed
700 701 702
#ifdef CONFIG_FTRACE_SELFTEST
	.selftest    = trace_selftest_startup_preemptoff,
#endif
703 704
	.open		= irqsoff_trace_open,
	.close		= irqsoff_trace_close,
705
	.allow_instances = true,
706
	.use_max_tr	= true,
707
};
708
#endif /* CONFIG_PREEMPT_TRACER */
709

710
#if defined(CONFIG_IRQSOFF_TRACER) && defined(CONFIG_PREEMPT_TRACER)
711

712
static int preemptirqsoff_tracer_init(struct trace_array *tr)
713 714 715
{
	trace_type = TRACER_IRQS_OFF | TRACER_PREEMPT_OFF;

716
	return __irqsoff_tracer_init(tr);
717 718
}

719 720 721 722 723
static void preemptirqsoff_tracer_reset(struct trace_array *tr)
{
	__irqsoff_tracer_reset(tr);
}

724 725 726 727
static struct tracer preemptirqsoff_tracer __read_mostly =
{
	.name		= "preemptirqsoff",
	.init		= preemptirqsoff_tracer_init,
728
	.reset		= preemptirqsoff_tracer_reset,
729 730
	.start		= irqsoff_tracer_start,
	.stop		= irqsoff_tracer_stop,
731
	.print_max	= true,
732 733
	.print_header   = irqsoff_print_header,
	.print_line     = irqsoff_print_line,
734
	.flag_changed	= irqsoff_flag_changed,
Steven Rostedt's avatar
Steven Rostedt committed
735 736 737
#ifdef CONFIG_FTRACE_SELFTEST
	.selftest    = trace_selftest_startup_preemptirqsoff,
#endif
738 739
	.open		= irqsoff_trace_open,
	.close		= irqsoff_trace_close,
740
	.allow_instances = true,
741
	.use_max_tr	= true,
742 743
};
#endif
744 745 746

__init static int init_irqsoff_tracer(void)
{
747 748
#ifdef CONFIG_IRQSOFF_TRACER
	register_tracer(&irqsoff_tracer);
749
#endif
750 751
#ifdef CONFIG_PREEMPT_TRACER
	register_tracer(&preemptoff_tracer);
752
#endif
753 754
#if defined(CONFIG_IRQSOFF_TRACER) && defined(CONFIG_PREEMPT_TRACER)
	register_tracer(&preemptirqsoff_tracer);
755 756
#endif

757
	return 0;
758
}
759 760
core_initcall(init_irqsoff_tracer);
#endif /* IRQSOFF_TRACER || PREEMPTOFF_TRACER */