mm, memory_hotplug: try to migrate full pfn range
[linux/fpc-iii.git] / kernel / trace / trace_preemptirq.c
blob71f553cceb3c1ee07bafe04b419797e59793f8b7
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 "trace.h"
14 #define CREATE_TRACE_POINTS
15 #include <trace/events/preemptirq.h>
17 #ifdef CONFIG_TRACE_IRQFLAGS
18 /* Per-cpu variable to prevent redundant calls when IRQs already off */
19 static DEFINE_PER_CPU(int, tracing_irq_cpu);
21 void trace_hardirqs_on(void)
23 if (this_cpu_read(tracing_irq_cpu)) {
24 if (!in_nmi())
25 trace_irq_enable_rcuidle(CALLER_ADDR0, CALLER_ADDR1);
26 tracer_hardirqs_on(CALLER_ADDR0, CALLER_ADDR1);
27 this_cpu_write(tracing_irq_cpu, 0);
30 lockdep_hardirqs_on(CALLER_ADDR0);
32 EXPORT_SYMBOL(trace_hardirqs_on);
34 void trace_hardirqs_off(void)
36 if (!this_cpu_read(tracing_irq_cpu)) {
37 this_cpu_write(tracing_irq_cpu, 1);
38 tracer_hardirqs_off(CALLER_ADDR0, CALLER_ADDR1);
39 if (!in_nmi())
40 trace_irq_disable_rcuidle(CALLER_ADDR0, CALLER_ADDR1);
43 lockdep_hardirqs_off(CALLER_ADDR0);
45 EXPORT_SYMBOL(trace_hardirqs_off);
47 __visible void trace_hardirqs_on_caller(unsigned long caller_addr)
49 if (this_cpu_read(tracing_irq_cpu)) {
50 if (!in_nmi())
51 trace_irq_enable_rcuidle(CALLER_ADDR0, caller_addr);
52 tracer_hardirqs_on(CALLER_ADDR0, caller_addr);
53 this_cpu_write(tracing_irq_cpu, 0);
56 lockdep_hardirqs_on(CALLER_ADDR0);
58 EXPORT_SYMBOL(trace_hardirqs_on_caller);
60 __visible void trace_hardirqs_off_caller(unsigned long caller_addr)
62 if (!this_cpu_read(tracing_irq_cpu)) {
63 this_cpu_write(tracing_irq_cpu, 1);
64 tracer_hardirqs_off(CALLER_ADDR0, caller_addr);
65 if (!in_nmi())
66 trace_irq_disable_rcuidle(CALLER_ADDR0, caller_addr);
69 lockdep_hardirqs_off(CALLER_ADDR0);
71 EXPORT_SYMBOL(trace_hardirqs_off_caller);
72 #endif /* CONFIG_TRACE_IRQFLAGS */
74 #ifdef CONFIG_TRACE_PREEMPT_TOGGLE
76 void trace_preempt_on(unsigned long a0, unsigned long a1)
78 if (!in_nmi())
79 trace_preempt_enable_rcuidle(a0, a1);
80 tracer_preempt_on(a0, a1);
83 void trace_preempt_off(unsigned long a0, unsigned long a1)
85 if (!in_nmi())
86 trace_preempt_disable_rcuidle(a0, a1);
87 tracer_preempt_off(a0, a1);
89 #endif