Linux 5.6.13
[linux/fpc-iii.git] / kernel / trace / trace_preemptirq.c
blob4d8e99fdbbbeec6472919cd13ca0df2ea38a27d2
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * preemptoff and irqoff tracepoints
5 * Copyright (C) Joel Fernandes (Google) <joel@joelfernandes.org>
6 */
8 #include <linux/kallsyms.h>
9 #include <linux/uaccess.h>
10 #include <linux/module.h>
11 #include <linux/ftrace.h>
12 #include <linux/kprobes.h>
13 #include "trace.h"
15 #define CREATE_TRACE_POINTS
16 #include <trace/events/preemptirq.h>
18 #ifdef CONFIG_TRACE_IRQFLAGS
19 /* Per-cpu variable to prevent redundant calls when IRQs already off */
20 static DEFINE_PER_CPU(int, tracing_irq_cpu);
22 void trace_hardirqs_on(void)
24 if (this_cpu_read(tracing_irq_cpu)) {
25 if (!in_nmi())
26 trace_irq_enable_rcuidle(CALLER_ADDR0, CALLER_ADDR1);
27 tracer_hardirqs_on(CALLER_ADDR0, CALLER_ADDR1);
28 this_cpu_write(tracing_irq_cpu, 0);
31 lockdep_hardirqs_on(CALLER_ADDR0);
33 EXPORT_SYMBOL(trace_hardirqs_on);
34 NOKPROBE_SYMBOL(trace_hardirqs_on);
36 void trace_hardirqs_off(void)
38 if (!this_cpu_read(tracing_irq_cpu)) {
39 this_cpu_write(tracing_irq_cpu, 1);
40 tracer_hardirqs_off(CALLER_ADDR0, CALLER_ADDR1);
41 if (!in_nmi())
42 trace_irq_disable_rcuidle(CALLER_ADDR0, CALLER_ADDR1);
45 lockdep_hardirqs_off(CALLER_ADDR0);
47 EXPORT_SYMBOL(trace_hardirqs_off);
48 NOKPROBE_SYMBOL(trace_hardirqs_off);
50 __visible void trace_hardirqs_on_caller(unsigned long caller_addr)
52 if (this_cpu_read(tracing_irq_cpu)) {
53 if (!in_nmi())
54 trace_irq_enable_rcuidle(CALLER_ADDR0, caller_addr);
55 tracer_hardirqs_on(CALLER_ADDR0, caller_addr);
56 this_cpu_write(tracing_irq_cpu, 0);
59 lockdep_hardirqs_on(CALLER_ADDR0);
61 EXPORT_SYMBOL(trace_hardirqs_on_caller);
62 NOKPROBE_SYMBOL(trace_hardirqs_on_caller);
64 __visible void trace_hardirqs_off_caller(unsigned long caller_addr)
66 if (!this_cpu_read(tracing_irq_cpu)) {
67 this_cpu_write(tracing_irq_cpu, 1);
68 tracer_hardirqs_off(CALLER_ADDR0, caller_addr);
69 if (!in_nmi())
70 trace_irq_disable_rcuidle(CALLER_ADDR0, caller_addr);
73 lockdep_hardirqs_off(CALLER_ADDR0);
75 EXPORT_SYMBOL(trace_hardirqs_off_caller);
76 NOKPROBE_SYMBOL(trace_hardirqs_off_caller);
77 #endif /* CONFIG_TRACE_IRQFLAGS */
79 #ifdef CONFIG_TRACE_PREEMPT_TOGGLE
81 void trace_preempt_on(unsigned long a0, unsigned long a1)
83 if (!in_nmi())
84 trace_preempt_enable_rcuidle(a0, a1);
85 tracer_preempt_on(a0, a1);
88 void trace_preempt_off(unsigned long a0, unsigned long a1)
90 if (!in_nmi())
91 trace_preempt_disable_rcuidle(a0, a1);
92 tracer_preempt_off(a0, a1);
94 #endif