2 * include/linux/irqflags.h
4 * IRQ flags tracing: follow the state of the hardirq and softirq flags and
5 * provide callbacks for transitions between ON and OFF states.
7 * This file gets included from lowlevel asm headers too, to provide
8 * wrapped versions of the local_irq_*() APIs, based on the
9 * raw_local_irq_*() macros from the lowlevel headers.
11 #ifndef _LINUX_TRACE_IRQFLAGS_H
12 #define _LINUX_TRACE_IRQFLAGS_H
14 #include <linux/typecheck.h>
15 #include <asm/irqflags.h>
17 #ifdef CONFIG_TRACE_IRQFLAGS
18 extern void trace_softirqs_on(unsigned long ip);
19 extern void trace_softirqs_off(unsigned long ip);
20 extern void trace_hardirqs_on(void);
21 extern void trace_hardirqs_off(void);
22 # define trace_hardirq_context(p) ((p)->hardirq_context)
23 # define trace_softirq_context(p) ((p)->softirq_context)
24 # define trace_hardirqs_enabled(p) ((p)->hardirqs_enabled)
25 # define trace_softirqs_enabled(p) ((p)->softirqs_enabled)
26 # define trace_hardirq_enter() do { current->hardirq_context++; } while (0)
27 # define trace_hardirq_exit() do { current->hardirq_context--; } while (0)
28 # define INIT_TRACE_IRQFLAGS .softirqs_enabled = 1,
30 # define trace_hardirqs_on() do { } while (0)
31 # define trace_hardirqs_off() do { } while (0)
32 # define trace_softirqs_on(ip) do { } while (0)
33 # define trace_softirqs_off(ip) do { } while (0)
34 # define trace_hardirq_context(p) 0
35 # define trace_softirq_context(p) 0
36 # define trace_hardirqs_enabled(p) 0
37 # define trace_softirqs_enabled(p) 0
38 # define trace_hardirq_enter() do { } while (0)
39 # define trace_hardirq_exit() do { } while (0)
40 # define INIT_TRACE_IRQFLAGS
43 #if defined(CONFIG_TRACE_IRQFLAGS) && !defined(CONFIG_PREEMPT_RT_FULL)
44 # define lockdep_softirq_enter() do { current->softirq_context++; } while (0)
45 # define lockdep_softirq_exit() do { current->softirq_context--; } while (0)
47 # define lockdep_softirq_enter() do { } while (0)
48 # define lockdep_softirq_exit() do { } while (0)
51 #if defined(CONFIG_IRQSOFF_TRACER) || \
52 defined(CONFIG_PREEMPT_TRACER)
53 extern void stop_critical_timings(void);
54 extern void start_critical_timings(void);
56 # define stop_critical_timings() do { } while (0)
57 # define start_critical_timings() do { } while (0)
61 * Wrap the arch provided IRQ routines to provide appropriate checks.
63 #define raw_local_irq_disable() arch_local_irq_disable()
64 #define raw_local_irq_enable() arch_local_irq_enable()
65 #define raw_local_irq_save(flags) \
67 typecheck(unsigned long, flags); \
68 flags = arch_local_irq_save(); \
70 #define raw_local_irq_restore(flags) \
72 typecheck(unsigned long, flags); \
73 arch_local_irq_restore(flags); \
75 #define raw_local_save_flags(flags) \
77 typecheck(unsigned long, flags); \
78 flags = arch_local_save_flags(); \
80 #define raw_irqs_disabled_flags(flags) \
82 typecheck(unsigned long, flags); \
83 arch_irqs_disabled_flags(flags); \
85 #define raw_irqs_disabled() (arch_irqs_disabled())
86 #define raw_safe_halt() arch_safe_halt()
89 * The local_irq_*() APIs are equal to the raw_local_irq*()
92 #ifdef CONFIG_TRACE_IRQFLAGS
93 #define local_irq_enable() \
94 do { trace_hardirqs_on(); raw_local_irq_enable(); } while (0)
95 #define local_irq_disable() \
96 do { raw_local_irq_disable(); trace_hardirqs_off(); } while (0)
97 #define local_irq_save(flags) \
99 raw_local_irq_save(flags); \
100 trace_hardirqs_off(); \
104 #define local_irq_restore(flags) \
106 if (raw_irqs_disabled_flags(flags)) { \
107 raw_local_irq_restore(flags); \
108 trace_hardirqs_off(); \
110 trace_hardirqs_on(); \
111 raw_local_irq_restore(flags); \
115 #define safe_halt() \
117 trace_hardirqs_on(); \
122 #else /* !CONFIG_TRACE_IRQFLAGS */
124 #define local_irq_enable() do { raw_local_irq_enable(); } while (0)
125 #define local_irq_disable() do { raw_local_irq_disable(); } while (0)
126 #define local_irq_save(flags) \
128 raw_local_irq_save(flags); \
130 #define local_irq_restore(flags) do { raw_local_irq_restore(flags); } while (0)
131 #define safe_halt() do { raw_safe_halt(); } while (0)
133 #endif /* CONFIG_TRACE_IRQFLAGS */
135 #define local_save_flags(flags) raw_local_save_flags(flags)
138 * Some architectures don't define arch_irqs_disabled(), so even if either
139 * definition would be fine we need to use different ones for the time being
140 * to avoid build issues.
142 #ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT
143 #define irqs_disabled() \
145 unsigned long _flags; \
146 raw_local_save_flags(_flags); \
147 raw_irqs_disabled_flags(_flags); \
149 #else /* !CONFIG_TRACE_IRQFLAGS_SUPPORT */
150 #define irqs_disabled() raw_irqs_disabled()
151 #endif /* CONFIG_TRACE_IRQFLAGS_SUPPORT */
153 #define irqs_disabled_flags(flags) raw_irqs_disabled_flags(flags)
156 * local_irq* variants depending on RT/!RT
158 #ifdef CONFIG_PREEMPT_RT_FULL
159 # define local_irq_disable_nort() do { } while (0)
160 # define local_irq_enable_nort() do { } while (0)
161 # define local_irq_save_nort(flags) local_save_flags(flags)
162 # define local_irq_restore_nort(flags) (void)(flags)
163 # define local_irq_disable_rt() local_irq_disable()
164 # define local_irq_enable_rt() local_irq_enable()
166 # define local_irq_disable_nort() local_irq_disable()
167 # define local_irq_enable_nort() local_irq_enable()
168 # define local_irq_save_nort(flags) local_irq_save(flags)
169 # define local_irq_restore_nort(flags) local_irq_restore(flags)
170 # define local_irq_disable_rt() do { } while (0)
171 # define local_irq_enable_rt() do { } while (0)