Ingo Molnar | de30a2b | 2006-07-03 00:24:42 -0700 | [diff] [blame] | 1 | /* |
| 2 | * include/linux/irqflags.h |
| 3 | * |
| 4 | * IRQ flags tracing: follow the state of the hardirq and softirq flags and |
| 5 | * provide callbacks for transitions between ON and OFF states. |
| 6 | * |
| 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. |
| 10 | */ |
| 11 | #ifndef _LINUX_TRACE_IRQFLAGS_H |
| 12 | #define _LINUX_TRACE_IRQFLAGS_H |
| 13 | |
| 14 | #ifdef CONFIG_TRACE_IRQFLAGS |
Ingo Molnar | de30a2b | 2006-07-03 00:24:42 -0700 | [diff] [blame] | 15 | extern void trace_softirqs_on(unsigned long ip); |
| 16 | extern void trace_softirqs_off(unsigned long ip); |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame^] | 17 | extern void trace_hardirqs_on(void); |
| 18 | extern void trace_hardirqs_off(void); |
Ingo Molnar | de30a2b | 2006-07-03 00:24:42 -0700 | [diff] [blame] | 19 | # define trace_hardirq_context(p) ((p)->hardirq_context) |
| 20 | # define trace_softirq_context(p) ((p)->softirq_context) |
| 21 | # define trace_hardirqs_enabled(p) ((p)->hardirqs_enabled) |
| 22 | # define trace_softirqs_enabled(p) ((p)->softirqs_enabled) |
| 23 | # define trace_hardirq_enter() do { current->hardirq_context++; } while (0) |
| 24 | # define trace_hardirq_exit() do { current->hardirq_context--; } while (0) |
| 25 | # define trace_softirq_enter() do { current->softirq_context++; } while (0) |
| 26 | # define trace_softirq_exit() do { current->softirq_context--; } while (0) |
| 27 | # define INIT_TRACE_IRQFLAGS .softirqs_enabled = 1, |
| 28 | #else |
| 29 | # define trace_hardirqs_on() do { } while (0) |
| 30 | # define trace_hardirqs_off() do { } while (0) |
| 31 | # define trace_softirqs_on(ip) do { } while (0) |
| 32 | # define trace_softirqs_off(ip) do { } while (0) |
| 33 | # define trace_hardirq_context(p) 0 |
| 34 | # define trace_softirq_context(p) 0 |
| 35 | # define trace_hardirqs_enabled(p) 0 |
| 36 | # define trace_softirqs_enabled(p) 0 |
| 37 | # define trace_hardirq_enter() do { } while (0) |
| 38 | # define trace_hardirq_exit() do { } while (0) |
| 39 | # define trace_softirq_enter() do { } while (0) |
| 40 | # define trace_softirq_exit() do { } while (0) |
| 41 | # define INIT_TRACE_IRQFLAGS |
| 42 | #endif |
| 43 | |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame^] | 44 | #ifdef CONFIG_IRQSOFF_TRACER |
| 45 | extern void stop_critical_timings(void); |
| 46 | extern void start_critical_timings(void); |
| 47 | #else |
| 48 | # define stop_critical_timings() do { } while (0) |
| 49 | # define start_critical_timings() do { } while (0) |
| 50 | #endif |
| 51 | |
Ingo Molnar | de30a2b | 2006-07-03 00:24:42 -0700 | [diff] [blame] | 52 | #ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT |
| 53 | |
| 54 | #include <asm/irqflags.h> |
| 55 | |
| 56 | #define local_irq_enable() \ |
| 57 | do { trace_hardirqs_on(); raw_local_irq_enable(); } while (0) |
| 58 | #define local_irq_disable() \ |
| 59 | do { raw_local_irq_disable(); trace_hardirqs_off(); } while (0) |
| 60 | #define local_irq_save(flags) \ |
| 61 | do { raw_local_irq_save(flags); trace_hardirqs_off(); } while (0) |
| 62 | |
| 63 | #define local_irq_restore(flags) \ |
| 64 | do { \ |
| 65 | if (raw_irqs_disabled_flags(flags)) { \ |
| 66 | raw_local_irq_restore(flags); \ |
| 67 | trace_hardirqs_off(); \ |
| 68 | } else { \ |
| 69 | trace_hardirqs_on(); \ |
| 70 | raw_local_irq_restore(flags); \ |
| 71 | } \ |
| 72 | } while (0) |
| 73 | #else /* !CONFIG_TRACE_IRQFLAGS_SUPPORT */ |
| 74 | /* |
| 75 | * The local_irq_*() APIs are equal to the raw_local_irq*() |
| 76 | * if !TRACE_IRQFLAGS. |
| 77 | */ |
| 78 | # define raw_local_irq_disable() local_irq_disable() |
| 79 | # define raw_local_irq_enable() local_irq_enable() |
| 80 | # define raw_local_irq_save(flags) local_irq_save(flags) |
| 81 | # define raw_local_irq_restore(flags) local_irq_restore(flags) |
| 82 | #endif /* CONFIG_TRACE_IRQFLAGS_SUPPORT */ |
| 83 | |
| 84 | #ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT |
| 85 | #define safe_halt() \ |
| 86 | do { \ |
| 87 | trace_hardirqs_on(); \ |
| 88 | raw_safe_halt(); \ |
| 89 | } while (0) |
| 90 | |
| 91 | #define local_save_flags(flags) raw_local_save_flags(flags) |
| 92 | |
| 93 | #define irqs_disabled() \ |
| 94 | ({ \ |
Harvey Harrison | a7d5ac8 | 2008-03-04 22:05:27 -0800 | [diff] [blame] | 95 | unsigned long _flags; \ |
Ingo Molnar | de30a2b | 2006-07-03 00:24:42 -0700 | [diff] [blame] | 96 | \ |
Harvey Harrison | a7d5ac8 | 2008-03-04 22:05:27 -0800 | [diff] [blame] | 97 | raw_local_save_flags(_flags); \ |
| 98 | raw_irqs_disabled_flags(_flags); \ |
Ingo Molnar | de30a2b | 2006-07-03 00:24:42 -0700 | [diff] [blame] | 99 | }) |
| 100 | |
| 101 | #define irqs_disabled_flags(flags) raw_irqs_disabled_flags(flags) |
| 102 | #endif /* CONFIG_X86 */ |
| 103 | |
| 104 | #endif |