diff options
author | Yinghai Lu <yhlu.kernel@gmail.com> | 2008-08-19 23:50:11 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-10-16 10:52:33 -0400 |
commit | 2c6927a38f65b53b62f86158fba29a068c4e8b6a (patch) | |
tree | 4f23cf5689c8fbaed771219b4afd3f785d8048bc | |
parent | 9059d8fa4a3a9153da53da890039f7f956cc9d19 (diff) |
irq: replace loop with nr_irqs with for_each_irq_desc
There are a handful of loops that go from 0 to nr_irqs and use
get_irq_desc() on them. These would allocate all the irq_desc
entries, regardless of the need for them.
Use the smarter for_each_irq_desc() iterator that will only iterate
over the present ones.
v2: make sure arch without GENERIC_HARDIRQS work too
Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | arch/x86/kernel/io_apic_64.c | 6 | ||||
-rw-r--r-- | arch/x86/kernel/irq_64.c | 5 | ||||
-rw-r--r-- | arch/x86/kernel/irqinit_64.c | 17 | ||||
-rw-r--r-- | include/linux/irq.h | 7 | ||||
-rw-r--r-- | kernel/irq/internals.h | 4 | ||||
-rw-r--r-- | kernel/irq/manage.c | 2 | ||||
-rw-r--r-- | kernel/irq/proc.c | 10 |
7 files changed, 25 insertions, 26 deletions
diff --git a/arch/x86/kernel/io_apic_64.c b/arch/x86/kernel/io_apic_64.c index 51ef7eb75f2e..708be9724daf 100644 --- a/arch/x86/kernel/io_apic_64.c +++ b/arch/x86/kernel/io_apic_64.c | |||
@@ -1871,10 +1871,10 @@ unmask: | |||
1871 | 1871 | ||
1872 | static void ir_irq_migration(struct work_struct *work) | 1872 | static void ir_irq_migration(struct work_struct *work) |
1873 | { | 1873 | { |
1874 | int irq; | 1874 | unsigned int irq; |
1875 | struct irq_desc *desc; | ||
1875 | 1876 | ||
1876 | for (irq = 0; irq < nr_irqs; irq++) { | 1877 | for_each_irq_desc(irq, desc) { |
1877 | struct irq_desc *desc = irq_to_desc(irq); | ||
1878 | if (desc->status & IRQ_MOVE_PENDING) { | 1878 | if (desc->status & IRQ_MOVE_PENDING) { |
1879 | unsigned long flags; | 1879 | unsigned long flags; |
1880 | 1880 | ||
diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c index 4a0a4eb44dcb..b3cf55e325f5 100644 --- a/arch/x86/kernel/irq_64.c +++ b/arch/x86/kernel/irq_64.c | |||
@@ -224,17 +224,16 @@ void fixup_irqs(cpumask_t map) | |||
224 | { | 224 | { |
225 | unsigned int irq; | 225 | unsigned int irq; |
226 | static int warned; | 226 | static int warned; |
227 | struct irq_desc *desc; | ||
227 | 228 | ||
228 | for (irq = 0; irq < nr_irqs; irq++) { | 229 | for_each_irq_desc(irq, desc) { |
229 | cpumask_t mask; | 230 | cpumask_t mask; |
230 | int break_affinity = 0; | 231 | int break_affinity = 0; |
231 | int set_affinity = 1; | 232 | int set_affinity = 1; |
232 | struct irq_desc *desc; | ||
233 | 233 | ||
234 | if (irq == 2) | 234 | if (irq == 2) |
235 | continue; | 235 | continue; |
236 | 236 | ||
237 | desc = irq_to_desc(irq); | ||
238 | /* interrupt's are disabled at this point */ | 237 | /* interrupt's are disabled at this point */ |
239 | spin_lock(&desc->lock); | 238 | spin_lock(&desc->lock); |
240 | 239 | ||
diff --git a/arch/x86/kernel/irqinit_64.c b/arch/x86/kernel/irqinit_64.c index 0744b49b4d12..cd9f42d028d9 100644 --- a/arch/x86/kernel/irqinit_64.c +++ b/arch/x86/kernel/irqinit_64.c | |||
@@ -142,25 +142,18 @@ void __init init_ISA_irqs(void) | |||
142 | init_bsp_APIC(); | 142 | init_bsp_APIC(); |
143 | init_8259A(0); | 143 | init_8259A(0); |
144 | 144 | ||
145 | for (i = 0; i < nr_irqs; i++) { | 145 | for (i = 0; i < 16; i++) { |
146 | struct irq_desc *desc = irq_to_desc(i); | 146 | struct irq_desc *desc = irq_to_desc(i); |
147 | 147 | ||
148 | desc->status = IRQ_DISABLED; | 148 | desc->status = IRQ_DISABLED; |
149 | desc->action = NULL; | 149 | desc->action = NULL; |
150 | desc->depth = 1; | 150 | desc->depth = 1; |
151 | 151 | ||
152 | if (i < 16) { | 152 | /* |
153 | /* | 153 | * 16 old-style INTA-cycle interrupts: |
154 | * 16 old-style INTA-cycle interrupts: | 154 | */ |
155 | */ | 155 | set_irq_chip_and_handler_name(i, &i8259A_chip, |
156 | set_irq_chip_and_handler_name(i, &i8259A_chip, | ||
157 | handle_level_irq, "XT"); | 156 | handle_level_irq, "XT"); |
158 | } else { | ||
159 | /* | ||
160 | * 'high' PCI IRQs filled in on demand | ||
161 | */ | ||
162 | desc->chip = &no_irq_chip; | ||
163 | } | ||
164 | } | 157 | } |
165 | } | 158 | } |
166 | 159 | ||
diff --git a/include/linux/irq.h b/include/linux/irq.h index c9ffef7c3b44..9de16ca8b8e5 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h | |||
@@ -202,9 +202,16 @@ extern struct irq_desc irq_desc[NR_IRQS]; | |||
202 | extern struct irq_desc *irq_desc; | 202 | extern struct irq_desc *irq_desc; |
203 | #endif | 203 | #endif |
204 | 204 | ||
205 | #ifdef CONFIG_GENERIC_HARDIRQS | ||
206 | #define for_each_irq_desc(irq, desc) \ | ||
207 | for (irq = 0, desc = irq_desc; irq < nr_irqs; irq++, desc = &irq_desc[irq]) | ||
208 | #endif | ||
209 | |||
205 | #else | 210 | #else |
206 | 211 | ||
207 | extern struct irq_desc *sparse_irqs; | 212 | extern struct irq_desc *sparse_irqs; |
213 | #define for_each_irq_desc(irqX, desc) \ | ||
214 | for (desc = sparse_irqs, irqX = desc->irq; desc && irqX != -1U; desc = desc->next, irqX = desc ? desc->irq : -1U) | ||
208 | 215 | ||
209 | #endif | 216 | #endif |
210 | 217 | ||
diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h index 422dd00c8bd3..c9767e641980 100644 --- a/kernel/irq/internals.h +++ b/kernel/irq/internals.h | |||
@@ -14,11 +14,11 @@ extern int __irq_set_trigger(struct irq_desc *desc, unsigned int irq, | |||
14 | unsigned long flags); | 14 | unsigned long flags); |
15 | 15 | ||
16 | #ifdef CONFIG_PROC_FS | 16 | #ifdef CONFIG_PROC_FS |
17 | extern void register_irq_proc(unsigned int irq); | 17 | extern void register_irq_proc(unsigned int irq, struct irq_desc *desc); |
18 | extern void register_handler_proc(unsigned int irq, struct irqaction *action); | 18 | extern void register_handler_proc(unsigned int irq, struct irqaction *action); |
19 | extern void unregister_handler_proc(unsigned int irq, struct irqaction *action); | 19 | extern void unregister_handler_proc(unsigned int irq, struct irqaction *action); |
20 | #else | 20 | #else |
21 | static inline void register_irq_proc(unsigned int irq) { } | 21 | static inline void register_irq_proc(unsigned int irq, struct irq_desc *desc) { } |
22 | static inline void register_handler_proc(unsigned int irq, | 22 | static inline void register_handler_proc(unsigned int irq, |
23 | struct irqaction *action) { } | 23 | struct irqaction *action) { } |
24 | static inline void unregister_handler_proc(unsigned int irq, | 24 | static inline void unregister_handler_proc(unsigned int irq, |
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index b5943e9f95aa..5070f55fdc16 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c | |||
@@ -478,7 +478,7 @@ int setup_irq(unsigned int irq, struct irqaction *new) | |||
478 | spin_unlock_irqrestore(&desc->lock, flags); | 478 | spin_unlock_irqrestore(&desc->lock, flags); |
479 | 479 | ||
480 | new->irq = irq; | 480 | new->irq = irq; |
481 | register_irq_proc(irq); | 481 | register_irq_proc(irq, desc); |
482 | new->dir = NULL; | 482 | new->dir = NULL; |
483 | register_handler_proc(irq, new); | 483 | register_handler_proc(irq, new); |
484 | 484 | ||
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c index c2f356c808f6..bc0993d86c8b 100644 --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c | |||
@@ -182,11 +182,10 @@ void register_handler_proc(unsigned int irq, struct irqaction *action) | |||
182 | 182 | ||
183 | #define MAX_NAMELEN 10 | 183 | #define MAX_NAMELEN 10 |
184 | 184 | ||
185 | void register_irq_proc(unsigned int irq) | 185 | void register_irq_proc(unsigned int irq, struct irq_desc *desc) |
186 | { | 186 | { |
187 | char name [MAX_NAMELEN]; | 187 | char name [MAX_NAMELEN]; |
188 | struct proc_dir_entry *entry; | 188 | struct proc_dir_entry *entry; |
189 | struct irq_desc *desc = irq_to_desc(irq); | ||
190 | 189 | ||
191 | if (!root_irq_dir || (desc->chip == &no_irq_chip) || desc->dir) | 190 | if (!root_irq_dir || (desc->chip == &no_irq_chip) || desc->dir) |
192 | return; | 191 | return; |
@@ -230,7 +229,8 @@ void register_default_affinity_proc(void) | |||
230 | 229 | ||
231 | void init_irq_proc(void) | 230 | void init_irq_proc(void) |
232 | { | 231 | { |
233 | int i; | 232 | unsigned int irq; |
233 | struct irq_desc *desc; | ||
234 | 234 | ||
235 | /* create /proc/irq */ | 235 | /* create /proc/irq */ |
236 | root_irq_dir = proc_mkdir("irq", NULL); | 236 | root_irq_dir = proc_mkdir("irq", NULL); |
@@ -242,7 +242,7 @@ void init_irq_proc(void) | |||
242 | /* | 242 | /* |
243 | * Create entries for all existing IRQs. | 243 | * Create entries for all existing IRQs. |
244 | */ | 244 | */ |
245 | for (i = 0; i < nr_irqs; i++) | 245 | for_each_irq_desc(irq, desc) |
246 | register_irq_proc(i); | 246 | register_irq_proc(irq, desc); |
247 | } | 247 | } |
248 | 248 | ||