diff options
author | Yinghai Lu <yinghai@kernel.org> | 2009-04-27 21:00:38 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-04-28 06:21:17 -0400 |
commit | 85ac16d033370caf6f48d743c8dc8103700f5cc5 (patch) | |
tree | 04a73af31c07a8ad29780b777b3f9d041fa236fa /arch | |
parent | 57b150cce8e004ddd36330490a68bfb59b7271e9 (diff) |
x86/irq: change irq_desc_alloc() to take node instead of cpu
This simplifies the node awareness of the code. All our allocators
only deal with a NUMA node ID locality not with CPU ids anyway - so
there's no need to maintain (and transform) a CPU id all across the
IRq layer.
v2: keep move_irq_desc related
[ Impact: cleanup, prepare IRQ code to be NUMA-aware ]
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
LKML-Reference: <49F65536.2020300@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kernel/apic/io_apic.c | 58 | ||||
-rw-r--r-- | arch/x86/lguest/boot.c | 2 |
2 files changed, 27 insertions, 33 deletions
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index 5c7630b40a54..560b887ba27c 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c | |||
@@ -129,12 +129,9 @@ struct irq_pin_list { | |||
129 | struct irq_pin_list *next; | 129 | struct irq_pin_list *next; |
130 | }; | 130 | }; |
131 | 131 | ||
132 | static struct irq_pin_list *get_one_free_irq_2_pin(int cpu) | 132 | static struct irq_pin_list *get_one_free_irq_2_pin(int node) |
133 | { | 133 | { |
134 | struct irq_pin_list *pin; | 134 | struct irq_pin_list *pin; |
135 | int node; | ||
136 | |||
137 | node = cpu_to_node(cpu); | ||
138 | 135 | ||
139 | pin = kzalloc_node(sizeof(*pin), GFP_ATOMIC, node); | 136 | pin = kzalloc_node(sizeof(*pin), GFP_ATOMIC, node); |
140 | 137 | ||
@@ -209,12 +206,9 @@ static struct irq_cfg *irq_cfg(unsigned int irq) | |||
209 | return cfg; | 206 | return cfg; |
210 | } | 207 | } |
211 | 208 | ||
212 | static struct irq_cfg *get_one_free_irq_cfg(int cpu) | 209 | static struct irq_cfg *get_one_free_irq_cfg(int node) |
213 | { | 210 | { |
214 | struct irq_cfg *cfg; | 211 | struct irq_cfg *cfg; |
215 | int node; | ||
216 | |||
217 | node = cpu_to_node(cpu); | ||
218 | 212 | ||
219 | cfg = kzalloc_node(sizeof(*cfg), GFP_ATOMIC, node); | 213 | cfg = kzalloc_node(sizeof(*cfg), GFP_ATOMIC, node); |
220 | if (cfg) { | 214 | if (cfg) { |
@@ -235,13 +229,13 @@ static struct irq_cfg *get_one_free_irq_cfg(int cpu) | |||
235 | return cfg; | 229 | return cfg; |
236 | } | 230 | } |
237 | 231 | ||
238 | int arch_init_chip_data(struct irq_desc *desc, int cpu) | 232 | int arch_init_chip_data(struct irq_desc *desc, int node) |
239 | { | 233 | { |
240 | struct irq_cfg *cfg; | 234 | struct irq_cfg *cfg; |
241 | 235 | ||
242 | cfg = desc->chip_data; | 236 | cfg = desc->chip_data; |
243 | if (!cfg) { | 237 | if (!cfg) { |
244 | desc->chip_data = get_one_free_irq_cfg(cpu); | 238 | desc->chip_data = get_one_free_irq_cfg(node); |
245 | if (!desc->chip_data) { | 239 | if (!desc->chip_data) { |
246 | printk(KERN_ERR "can not alloc irq_cfg\n"); | 240 | printk(KERN_ERR "can not alloc irq_cfg\n"); |
247 | BUG_ON(1); | 241 | BUG_ON(1); |
@@ -253,7 +247,7 @@ int arch_init_chip_data(struct irq_desc *desc, int cpu) | |||
253 | 247 | ||
254 | /* for move_irq_desc */ | 248 | /* for move_irq_desc */ |
255 | static void | 249 | static void |
256 | init_copy_irq_2_pin(struct irq_cfg *old_cfg, struct irq_cfg *cfg, int cpu) | 250 | init_copy_irq_2_pin(struct irq_cfg *old_cfg, struct irq_cfg *cfg, int node) |
257 | { | 251 | { |
258 | struct irq_pin_list *old_entry, *head, *tail, *entry; | 252 | struct irq_pin_list *old_entry, *head, *tail, *entry; |
259 | 253 | ||
@@ -262,7 +256,7 @@ init_copy_irq_2_pin(struct irq_cfg *old_cfg, struct irq_cfg *cfg, int cpu) | |||
262 | if (!old_entry) | 256 | if (!old_entry) |
263 | return; | 257 | return; |
264 | 258 | ||
265 | entry = get_one_free_irq_2_pin(cpu); | 259 | entry = get_one_free_irq_2_pin(node); |
266 | if (!entry) | 260 | if (!entry) |
267 | return; | 261 | return; |
268 | 262 | ||
@@ -272,7 +266,7 @@ init_copy_irq_2_pin(struct irq_cfg *old_cfg, struct irq_cfg *cfg, int cpu) | |||
272 | tail = entry; | 266 | tail = entry; |
273 | old_entry = old_entry->next; | 267 | old_entry = old_entry->next; |
274 | while (old_entry) { | 268 | while (old_entry) { |
275 | entry = get_one_free_irq_2_pin(cpu); | 269 | entry = get_one_free_irq_2_pin(node); |
276 | if (!entry) { | 270 | if (!entry) { |
277 | entry = head; | 271 | entry = head; |
278 | while (entry) { | 272 | while (entry) { |
@@ -312,12 +306,12 @@ static void free_irq_2_pin(struct irq_cfg *old_cfg, struct irq_cfg *cfg) | |||
312 | } | 306 | } |
313 | 307 | ||
314 | void arch_init_copy_chip_data(struct irq_desc *old_desc, | 308 | void arch_init_copy_chip_data(struct irq_desc *old_desc, |
315 | struct irq_desc *desc, int cpu) | 309 | struct irq_desc *desc, int node) |
316 | { | 310 | { |
317 | struct irq_cfg *cfg; | 311 | struct irq_cfg *cfg; |
318 | struct irq_cfg *old_cfg; | 312 | struct irq_cfg *old_cfg; |
319 | 313 | ||
320 | cfg = get_one_free_irq_cfg(cpu); | 314 | cfg = get_one_free_irq_cfg(node); |
321 | 315 | ||
322 | if (!cfg) | 316 | if (!cfg) |
323 | return; | 317 | return; |
@@ -328,7 +322,7 @@ void arch_init_copy_chip_data(struct irq_desc *old_desc, | |||
328 | 322 | ||
329 | memcpy(cfg, old_cfg, sizeof(struct irq_cfg)); | 323 | memcpy(cfg, old_cfg, sizeof(struct irq_cfg)); |
330 | 324 | ||
331 | init_copy_irq_2_pin(old_cfg, cfg, cpu); | 325 | init_copy_irq_2_pin(old_cfg, cfg, node); |
332 | } | 326 | } |
333 | 327 | ||
334 | static void free_irq_cfg(struct irq_cfg *old_cfg) | 328 | static void free_irq_cfg(struct irq_cfg *old_cfg) |
@@ -615,13 +609,13 @@ set_ioapic_affinity_irq(unsigned int irq, const struct cpumask *mask) | |||
615 | * shared ISA-space IRQs, so we have to support them. We are super | 609 | * shared ISA-space IRQs, so we have to support them. We are super |
616 | * fast in the common case, and fast for shared ISA-space IRQs. | 610 | * fast in the common case, and fast for shared ISA-space IRQs. |
617 | */ | 611 | */ |
618 | static void add_pin_to_irq_cpu(struct irq_cfg *cfg, int cpu, int apic, int pin) | 612 | static void add_pin_to_irq_node(struct irq_cfg *cfg, int node, int apic, int pin) |
619 | { | 613 | { |
620 | struct irq_pin_list *entry; | 614 | struct irq_pin_list *entry; |
621 | 615 | ||
622 | entry = cfg->irq_2_pin; | 616 | entry = cfg->irq_2_pin; |
623 | if (!entry) { | 617 | if (!entry) { |
624 | entry = get_one_free_irq_2_pin(cpu); | 618 | entry = get_one_free_irq_2_pin(node); |
625 | if (!entry) { | 619 | if (!entry) { |
626 | printk(KERN_ERR "can not alloc irq_2_pin to add %d - %d\n", | 620 | printk(KERN_ERR "can not alloc irq_2_pin to add %d - %d\n", |
627 | apic, pin); | 621 | apic, pin); |
@@ -641,7 +635,7 @@ static void add_pin_to_irq_cpu(struct irq_cfg *cfg, int cpu, int apic, int pin) | |||
641 | entry = entry->next; | 635 | entry = entry->next; |
642 | } | 636 | } |
643 | 637 | ||
644 | entry->next = get_one_free_irq_2_pin(cpu); | 638 | entry->next = get_one_free_irq_2_pin(node); |
645 | entry = entry->next; | 639 | entry = entry->next; |
646 | entry->apic = apic; | 640 | entry->apic = apic; |
647 | entry->pin = pin; | 641 | entry->pin = pin; |
@@ -650,7 +644,7 @@ static void add_pin_to_irq_cpu(struct irq_cfg *cfg, int cpu, int apic, int pin) | |||
650 | /* | 644 | /* |
651 | * Reroute an IRQ to a different pin. | 645 | * Reroute an IRQ to a different pin. |
652 | */ | 646 | */ |
653 | static void __init replace_pin_at_irq_cpu(struct irq_cfg *cfg, int cpu, | 647 | static void __init replace_pin_at_irq_node(struct irq_cfg *cfg, int node, |
654 | int oldapic, int oldpin, | 648 | int oldapic, int oldpin, |
655 | int newapic, int newpin) | 649 | int newapic, int newpin) |
656 | { | 650 | { |
@@ -670,7 +664,7 @@ static void __init replace_pin_at_irq_cpu(struct irq_cfg *cfg, int cpu, | |||
670 | 664 | ||
671 | /* why? call replace before add? */ | 665 | /* why? call replace before add? */ |
672 | if (!replaced) | 666 | if (!replaced) |
673 | add_pin_to_irq_cpu(cfg, cpu, newapic, newpin); | 667 | add_pin_to_irq_node(cfg, node, newapic, newpin); |
674 | } | 668 | } |
675 | 669 | ||
676 | static inline void io_apic_modify_irq(struct irq_cfg *cfg, | 670 | static inline void io_apic_modify_irq(struct irq_cfg *cfg, |
@@ -1612,7 +1606,7 @@ static void __init setup_IO_APIC_irqs(void) | |||
1612 | int notcon = 0; | 1606 | int notcon = 0; |
1613 | struct irq_desc *desc; | 1607 | struct irq_desc *desc; |
1614 | struct irq_cfg *cfg; | 1608 | struct irq_cfg *cfg; |
1615 | int cpu = boot_cpu_id; | 1609 | int node = cpu_to_node(boot_cpu_id); |
1616 | 1610 | ||
1617 | apic_printk(APIC_VERBOSE, KERN_DEBUG "init IO_APIC IRQs\n"); | 1611 | apic_printk(APIC_VERBOSE, KERN_DEBUG "init IO_APIC IRQs\n"); |
1618 | 1612 | ||
@@ -1647,13 +1641,13 @@ static void __init setup_IO_APIC_irqs(void) | |||
1647 | apic->multi_timer_check(apic_id, irq)) | 1641 | apic->multi_timer_check(apic_id, irq)) |
1648 | continue; | 1642 | continue; |
1649 | 1643 | ||
1650 | desc = irq_to_desc_alloc_cpu(irq, cpu); | 1644 | desc = irq_to_desc_alloc_node(irq, node); |
1651 | if (!desc) { | 1645 | if (!desc) { |
1652 | printk(KERN_INFO "can not get irq_desc for %d\n", irq); | 1646 | printk(KERN_INFO "can not get irq_desc for %d\n", irq); |
1653 | continue; | 1647 | continue; |
1654 | } | 1648 | } |
1655 | cfg = desc->chip_data; | 1649 | cfg = desc->chip_data; |
1656 | add_pin_to_irq_cpu(cfg, cpu, apic_id, pin); | 1650 | add_pin_to_irq_node(cfg, node, apic_id, pin); |
1657 | 1651 | ||
1658 | setup_IO_APIC_irq(apic_id, pin, irq, desc, | 1652 | setup_IO_APIC_irq(apic_id, pin, irq, desc, |
1659 | irq_trigger(idx), irq_polarity(idx)); | 1653 | irq_trigger(idx), irq_polarity(idx)); |
@@ -2863,7 +2857,7 @@ static inline void __init check_timer(void) | |||
2863 | { | 2857 | { |
2864 | struct irq_desc *desc = irq_to_desc(0); | 2858 | struct irq_desc *desc = irq_to_desc(0); |
2865 | struct irq_cfg *cfg = desc->chip_data; | 2859 | struct irq_cfg *cfg = desc->chip_data; |
2866 | int cpu = boot_cpu_id; | 2860 | int node = cpu_to_node(boot_cpu_id); |
2867 | int apic1, pin1, apic2, pin2; | 2861 | int apic1, pin1, apic2, pin2; |
2868 | unsigned long flags; | 2862 | unsigned long flags; |
2869 | int no_pin1 = 0; | 2863 | int no_pin1 = 0; |
@@ -2929,7 +2923,7 @@ static inline void __init check_timer(void) | |||
2929 | * Ok, does IRQ0 through the IOAPIC work? | 2923 | * Ok, does IRQ0 through the IOAPIC work? |
2930 | */ | 2924 | */ |
2931 | if (no_pin1) { | 2925 | if (no_pin1) { |
2932 | add_pin_to_irq_cpu(cfg, cpu, apic1, pin1); | 2926 | add_pin_to_irq_node(cfg, node, apic1, pin1); |
2933 | setup_timer_IRQ0_pin(apic1, pin1, cfg->vector); | 2927 | setup_timer_IRQ0_pin(apic1, pin1, cfg->vector); |
2934 | } else { | 2928 | } else { |
2935 | /* for edge trigger, setup_IO_APIC_irq already | 2929 | /* for edge trigger, setup_IO_APIC_irq already |
@@ -2966,7 +2960,7 @@ static inline void __init check_timer(void) | |||
2966 | /* | 2960 | /* |
2967 | * legacy devices should be connected to IO APIC #0 | 2961 | * legacy devices should be connected to IO APIC #0 |
2968 | */ | 2962 | */ |
2969 | replace_pin_at_irq_cpu(cfg, cpu, apic1, pin1, apic2, pin2); | 2963 | replace_pin_at_irq_node(cfg, node, apic1, pin1, apic2, pin2); |
2970 | setup_timer_IRQ0_pin(apic2, pin2, cfg->vector); | 2964 | setup_timer_IRQ0_pin(apic2, pin2, cfg->vector); |
2971 | enable_8259A_irq(0); | 2965 | enable_8259A_irq(0); |
2972 | if (timer_irq_works()) { | 2966 | if (timer_irq_works()) { |
@@ -3185,7 +3179,7 @@ unsigned int create_irq_nr(unsigned int irq_want) | |||
3185 | unsigned int new; | 3179 | unsigned int new; |
3186 | unsigned long flags; | 3180 | unsigned long flags; |
3187 | struct irq_cfg *cfg_new = NULL; | 3181 | struct irq_cfg *cfg_new = NULL; |
3188 | int cpu = boot_cpu_id; | 3182 | int node = cpu_to_node(boot_cpu_id); |
3189 | struct irq_desc *desc_new = NULL; | 3183 | struct irq_desc *desc_new = NULL; |
3190 | 3184 | ||
3191 | irq = 0; | 3185 | irq = 0; |
@@ -3194,7 +3188,7 @@ unsigned int create_irq_nr(unsigned int irq_want) | |||
3194 | 3188 | ||
3195 | spin_lock_irqsave(&vector_lock, flags); | 3189 | spin_lock_irqsave(&vector_lock, flags); |
3196 | for (new = irq_want; new < nr_irqs; new++) { | 3190 | for (new = irq_want; new < nr_irqs; new++) { |
3197 | desc_new = irq_to_desc_alloc_cpu(new, cpu); | 3191 | desc_new = irq_to_desc_alloc_node(new, node); |
3198 | if (!desc_new) { | 3192 | if (!desc_new) { |
3199 | printk(KERN_INFO "can not get irq_desc for %d\n", new); | 3193 | printk(KERN_INFO "can not get irq_desc for %d\n", new); |
3200 | continue; | 3194 | continue; |
@@ -3968,7 +3962,7 @@ int io_apic_set_pci_routing (int ioapic, int pin, int irq, int triggering, int p | |||
3968 | { | 3962 | { |
3969 | struct irq_desc *desc; | 3963 | struct irq_desc *desc; |
3970 | struct irq_cfg *cfg; | 3964 | struct irq_cfg *cfg; |
3971 | int cpu = boot_cpu_id; | 3965 | int node = cpu_to_node(boot_cpu_id); |
3972 | 3966 | ||
3973 | if (!IO_APIC_IRQ(irq)) { | 3967 | if (!IO_APIC_IRQ(irq)) { |
3974 | apic_printk(APIC_QUIET,KERN_ERR "IOAPIC[%d]: Invalid reference to IRQ 0\n", | 3968 | apic_printk(APIC_QUIET,KERN_ERR "IOAPIC[%d]: Invalid reference to IRQ 0\n", |
@@ -3976,7 +3970,7 @@ int io_apic_set_pci_routing (int ioapic, int pin, int irq, int triggering, int p | |||
3976 | return -EINVAL; | 3970 | return -EINVAL; |
3977 | } | 3971 | } |
3978 | 3972 | ||
3979 | desc = irq_to_desc_alloc_cpu(irq, cpu); | 3973 | desc = irq_to_desc_alloc_node(irq, node); |
3980 | if (!desc) { | 3974 | if (!desc) { |
3981 | printk(KERN_INFO "can not get irq_desc %d\n", irq); | 3975 | printk(KERN_INFO "can not get irq_desc %d\n", irq); |
3982 | return 0; | 3976 | return 0; |
@@ -3987,7 +3981,7 @@ int io_apic_set_pci_routing (int ioapic, int pin, int irq, int triggering, int p | |||
3987 | */ | 3981 | */ |
3988 | if (irq >= NR_IRQS_LEGACY) { | 3982 | if (irq >= NR_IRQS_LEGACY) { |
3989 | cfg = desc->chip_data; | 3983 | cfg = desc->chip_data; |
3990 | add_pin_to_irq_cpu(cfg, cpu, ioapic, pin); | 3984 | add_pin_to_irq_node(cfg, node, ioapic, pin); |
3991 | } | 3985 | } |
3992 | 3986 | ||
3993 | setup_IO_APIC_irq(ioapic, pin, irq, desc, triggering, polarity); | 3987 | setup_IO_APIC_irq(ioapic, pin, irq, desc, triggering, polarity); |
diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c index ca7ec44bafc3..45acbcf25683 100644 --- a/arch/x86/lguest/boot.c +++ b/arch/x86/lguest/boot.c | |||
@@ -636,7 +636,7 @@ static void __init lguest_init_IRQ(void) | |||
636 | 636 | ||
637 | void lguest_setup_irq(unsigned int irq) | 637 | void lguest_setup_irq(unsigned int irq) |
638 | { | 638 | { |
639 | irq_to_desc_alloc_cpu(irq, 0); | 639 | irq_to_desc_alloc_node(irq, 0); |
640 | set_irq_chip_and_handler_name(irq, &lguest_irq_controller, | 640 | set_irq_chip_and_handler_name(irq, &lguest_irq_controller, |
641 | handle_level_irq, "level"); | 641 | handle_level_irq, "level"); |
642 | } | 642 | } |