Blame view
include/linux/hardirq.h
5.68 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 |
#ifndef LINUX_HARDIRQ_H #define LINUX_HARDIRQ_H |
67bc4eb0b [PATCH] hardirq u... |
3 |
#include <linux/preempt.h> |
fbb9ce953 [PATCH] lockdep: ... |
4 |
#include <linux/lockdep.h> |
6a60dd121 ftrace: split out... |
5 |
#include <linux/ftrace_irq.h> |
1da177e4c Linux-2.6.12-rc2 |
6 |
#include <asm/hardirq.h> |
1da177e4c Linux-2.6.12-rc2 |
7 8 9 10 11 12 13 14 |
/* * We put the hardirq and softirq counter into the preemption * counter. The bitmask has the following meaning: * * - bits 0-7 are the preemption count (max preemption depth: 256) * - bits 8-15 are the softirq count (max # of softirqs: 256) * |
5a5fb7dbe preempt-count: fo... |
15 16 17 18 19 20 |
* The hardirq count can in theory reach the same as NR_IRQS. * In reality, the number of nested IRQS is limited to the stack * size as well. For archs with over 1000 IRQS it is not practical * to expect that they will all nest. We give a max of 10 bits for * hardirq nesting. An arch may choose to give less than 10 bits. * m68k expects it to be 8. |
1da177e4c Linux-2.6.12-rc2 |
21 |
* |
5a5fb7dbe preempt-count: fo... |
22 23 24 |
* - bits 16-25 are the hardirq count (max # of nested hardirqs: 1024) * - bit 26 is the NMI_MASK * - bit 28 is the PREEMPT_ACTIVE flag |
1da177e4c Linux-2.6.12-rc2 |
25 26 27 |
* * PREEMPT_MASK: 0x000000ff * SOFTIRQ_MASK: 0x0000ff00 |
5a5fb7dbe preempt-count: fo... |
28 29 |
* HARDIRQ_MASK: 0x03ff0000 * NMI_MASK: 0x04000000 |
1da177e4c Linux-2.6.12-rc2 |
30 31 32 |
*/ #define PREEMPT_BITS 8 #define SOFTIRQ_BITS 8 |
5a5fb7dbe preempt-count: fo... |
33 |
#define NMI_BITS 1 |
1da177e4c Linux-2.6.12-rc2 |
34 |
|
5a5fb7dbe preempt-count: fo... |
35 |
#define MAX_HARDIRQ_BITS 10 |
23d0b8b05 [PATCH] genirq: i... |
36 |
|
5a5fb7dbe preempt-count: fo... |
37 38 |
#ifndef HARDIRQ_BITS # define HARDIRQ_BITS MAX_HARDIRQ_BITS |
23d0b8b05 [PATCH] genirq: i... |
39 |
#endif |
5a5fb7dbe preempt-count: fo... |
40 41 |
#if HARDIRQ_BITS > MAX_HARDIRQ_BITS #error HARDIRQ_BITS too high! |
1da177e4c Linux-2.6.12-rc2 |
42 43 44 45 46 |
#endif #define PREEMPT_SHIFT 0 #define SOFTIRQ_SHIFT (PREEMPT_SHIFT + PREEMPT_BITS) #define HARDIRQ_SHIFT (SOFTIRQ_SHIFT + SOFTIRQ_BITS) |
5a5fb7dbe preempt-count: fo... |
47 |
#define NMI_SHIFT (HARDIRQ_SHIFT + HARDIRQ_BITS) |
1da177e4c Linux-2.6.12-rc2 |
48 49 50 51 |
#define __IRQ_MASK(x) ((1UL << (x))-1) #define PREEMPT_MASK (__IRQ_MASK(PREEMPT_BITS) << PREEMPT_SHIFT) |
1da177e4c Linux-2.6.12-rc2 |
52 |
#define SOFTIRQ_MASK (__IRQ_MASK(SOFTIRQ_BITS) << SOFTIRQ_SHIFT) |
8f28e8fa4 [PATCH] irq code:... |
53 |
#define HARDIRQ_MASK (__IRQ_MASK(HARDIRQ_BITS) << HARDIRQ_SHIFT) |
5a5fb7dbe preempt-count: fo... |
54 |
#define NMI_MASK (__IRQ_MASK(NMI_BITS) << NMI_SHIFT) |
1da177e4c Linux-2.6.12-rc2 |
55 56 57 58 |
#define PREEMPT_OFFSET (1UL << PREEMPT_SHIFT) #define SOFTIRQ_OFFSET (1UL << SOFTIRQ_SHIFT) #define HARDIRQ_OFFSET (1UL << HARDIRQ_SHIFT) |
5a5fb7dbe preempt-count: fo... |
59 |
#define NMI_OFFSET (1UL << NMI_SHIFT) |
1da177e4c Linux-2.6.12-rc2 |
60 |
|
75e1056f5 sched: Fix softir... |
61 |
#define SOFTIRQ_DISABLE_OFFSET (2 * SOFTIRQ_OFFSET) |
8e5b59a2d sched: Add defaul... |
62 63 64 65 66 |
#ifndef PREEMPT_ACTIVE #define PREEMPT_ACTIVE_BITS 1 #define PREEMPT_ACTIVE_SHIFT (NMI_SHIFT + NMI_BITS) #define PREEMPT_ACTIVE (__IRQ_MASK(PREEMPT_ACTIVE_BITS) << PREEMPT_ACTIVE_SHIFT) #endif |
5a5fb7dbe preempt-count: fo... |
67 |
#if PREEMPT_ACTIVE < (1 << (NMI_SHIFT + NMI_BITS)) |
8f28e8fa4 [PATCH] irq code:... |
68 69 |
#error PREEMPT_ACTIVE is too low! #endif |
1da177e4c Linux-2.6.12-rc2 |
70 71 |
#define hardirq_count() (preempt_count() & HARDIRQ_MASK) #define softirq_count() (preempt_count() & SOFTIRQ_MASK) |
5a5fb7dbe preempt-count: fo... |
72 73 |
#define irq_count() (preempt_count() & (HARDIRQ_MASK | SOFTIRQ_MASK \ | NMI_MASK)) |
1da177e4c Linux-2.6.12-rc2 |
74 75 76 77 |
/* * Are we doing bottom half or hardware interrupt processing? * Are we in a softirq context? Interrupt context? |
75e1056f5 sched: Fix softir... |
78 79 |
* in_softirq - Are we currently processing softirq or have bh disabled? * in_serving_softirq - Are we currently processing softirq? |
1da177e4c Linux-2.6.12-rc2 |
80 81 82 83 |
*/ #define in_irq() (hardirq_count()) #define in_softirq() (softirq_count()) #define in_interrupt() (irq_count()) |
75e1056f5 sched: Fix softir... |
84 |
#define in_serving_softirq() (softirq_count() & SOFTIRQ_OFFSET) |
1da177e4c Linux-2.6.12-rc2 |
85 |
|
375b38b42 nmi: add generic ... |
86 87 88 |
/* * Are we in NMI context? */ |
5a5fb7dbe preempt-count: fo... |
89 |
#define in_nmi() (preempt_count() & NMI_MASK) |
375b38b42 nmi: add generic ... |
90 |
|
bdd4e85dc sched: Isolate pr... |
91 |
#if defined(CONFIG_PREEMPT_COUNT) |
7fe19da4c preempt: fix kern... |
92 93 |
# define PREEMPT_CHECK_OFFSET 1 #else |
8e3e076c5 BKL: revert back ... |
94 95 |
# define PREEMPT_CHECK_OFFSET 0 #endif |
8c703d35f in_atomic(): docu... |
96 97 98 99 100 101 102 |
/* * Are we running in atomic context? WARNING: this macro cannot * always detect atomic context; in particular, it cannot know about * held spinlocks in non-preemptible kernels. Thus it should not be * used in the general case to determine whether sleeping is possible. * Do not use in_atomic() in driver code. */ |
4ba8216cd BKL: That's all, ... |
103 |
#define in_atomic() ((preempt_count() & ~PREEMPT_ACTIVE) != 0) |
4da1ce6d9 sched: add in_ato... |
104 105 106 |
/* * Check whether we were atomic before we did preempt_disable(): |
8e3e076c5 BKL: revert back ... |
107 |
* (used by the scheduler, *after* releasing the kernel lock) |
4da1ce6d9 sched: add in_ato... |
108 109 110 |
*/ #define in_atomic_preempt_off() \ ((preempt_count() & ~PREEMPT_ACTIVE) != PREEMPT_CHECK_OFFSET) |
bdd4e85dc sched: Isolate pr... |
111 |
#ifdef CONFIG_PREEMPT_COUNT |
1da177e4c Linux-2.6.12-rc2 |
112 113 114 115 116 117 |
# define preemptible() (preempt_count() == 0 && !irqs_disabled()) # define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1) #else # define preemptible() 0 # define IRQ_EXIT_OFFSET HARDIRQ_OFFSET #endif |
3aa551c9b genirq: add threa... |
118 |
#if defined(CONFIG_SMP) || defined(CONFIG_GENERIC_HARDIRQS) |
1da177e4c Linux-2.6.12-rc2 |
119 120 121 122 |
extern void synchronize_irq(unsigned int irq); #else # define synchronize_irq(irq) barrier() #endif |
f037360f2 [PATCH] m68k: thr... |
123 |
struct task_struct; |
b52bfee44 sched: Add IRQ_TI... |
124 |
#if !defined(CONFIG_VIRT_CPU_ACCOUNTING) && !defined(CONFIG_IRQ_TIME_ACCOUNTING) |
1da177e4c Linux-2.6.12-rc2 |
125 126 127 |
static inline void account_system_vtime(struct task_struct *tsk) { } |
e1e10a265 sched: Consolidat... |
128 129 |
#else extern void account_system_vtime(struct task_struct *tsk); |
1da177e4c Linux-2.6.12-rc2 |
130 |
#endif |
a57eb940d rcu: Add a TINY_P... |
131 |
#if defined(CONFIG_TINY_RCU) || defined(CONFIG_TINY_PREEMPT_RCU) |
9b1d82fa1 rcu: "Tiny RCU", ... |
132 133 134 135 136 137 138 139 140 141 |
static inline void rcu_nmi_enter(void) { } static inline void rcu_nmi_exit(void) { } #else |
64db4cfff "Tree RCU": scala... |
142 143 |
extern void rcu_nmi_enter(void); extern void rcu_nmi_exit(void); |
9b1d82fa1 rcu: "Tiny RCU", ... |
144 |
#endif |
2232c2d8e rcu: add support ... |
145 |
|
de30a2b35 [PATCH] lockdep: ... |
146 147 148 149 150 151 |
/* * It is safe to do non-atomic ops on ->hardirq_context, * because NMI handlers may not preempt and the ops are * always balanced, so the interrupted value of ->hardirq_context * will always be restored. */ |
79bf2bb33 [PATCH] tick-mana... |
152 153 154 155 156 157 158 159 160 161 |
#define __irq_enter() \ do { \ account_system_vtime(current); \ add_preempt_count(HARDIRQ_OFFSET); \ trace_hardirq_enter(); \ } while (0) /* * Enter irq context (on NO_HZ, update jiffies): */ |
dde4b2b5f [PATCH] uninline ... |
162 |
extern void irq_enter(void); |
de30a2b35 [PATCH] lockdep: ... |
163 164 165 166 167 168 169 170 171 |
/* * Exit irq context without processing softirqs: */ #define __irq_exit() \ do { \ trace_hardirq_exit(); \ account_system_vtime(current); \ sub_preempt_count(HARDIRQ_OFFSET); \ |
1da177e4c Linux-2.6.12-rc2 |
172 |
} while (0) |
de30a2b35 [PATCH] lockdep: ... |
173 174 175 |
/* * Exit irq context and process softirqs if needed: */ |
1da177e4c Linux-2.6.12-rc2 |
176 |
extern void irq_exit(void); |
2a7b8df04 sched: do not acc... |
177 178 179 180 181 182 183 184 |
#define nmi_enter() \ do { \ ftrace_nmi_enter(); \ BUG_ON(in_nmi()); \ add_preempt_count(NMI_OFFSET + HARDIRQ_OFFSET); \ lockdep_off(); \ rcu_nmi_enter(); \ trace_hardirq_enter(); \ |
17666f02b ftrace: nmi safe ... |
185 |
} while (0) |
5f34fe1cf Merge branch 'cor... |
186 |
|
2a7b8df04 sched: do not acc... |
187 188 189 190 191 192 193 194 |
#define nmi_exit() \ do { \ trace_hardirq_exit(); \ rcu_nmi_exit(); \ lockdep_on(); \ BUG_ON(!in_nmi()); \ sub_preempt_count(NMI_OFFSET + HARDIRQ_OFFSET); \ ftrace_nmi_exit(); \ |
17666f02b ftrace: nmi safe ... |
195 |
} while (0) |
de30a2b35 [PATCH] lockdep: ... |
196 |
|
1da177e4c Linux-2.6.12-rc2 |
197 |
#endif /* LINUX_HARDIRQ_H */ |