aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2009-04-27 21:00:38 -0400
committerIngo Molnar <mingo@elte.hu>2009-04-28 06:21:17 -0400
commit85ac16d033370caf6f48d743c8dc8103700f5cc5 (patch)
tree04a73af31c07a8ad29780b777b3f9d041fa236fa
parent57b150cce8e004ddd36330490a68bfb59b7271e9 (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>
-rw-r--r--arch/x86/kernel/apic/io_apic.c58
-rw-r--r--arch/x86/lguest/boot.c2
-rw-r--r--drivers/pci/intr_remapping.c15
-rw-r--r--drivers/xen/events.c2
-rw-r--r--include/linux/interrupt.h2
-rw-r--r--include/linux/irq.h16
-rw-r--r--kernel/irq/handle.c28
-rw-r--r--kernel/irq/internals.h2
-rw-r--r--kernel/irq/numa_migrate.c36
-rw-r--r--kernel/softirq.c2
10 files changed, 66 insertions, 97 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
132static struct irq_pin_list *get_one_free_irq_2_pin(int cpu) 132static 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
212static struct irq_cfg *get_one_free_irq_cfg(int cpu) 209static 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
238int arch_init_chip_data(struct irq_desc *desc, int cpu) 232int 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 */
255static void 249static void
256init_copy_irq_2_pin(struct irq_cfg *old_cfg, struct irq_cfg *cfg, int cpu) 250init_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
314void arch_init_copy_chip_data(struct irq_desc *old_desc, 308void 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
334static void free_irq_cfg(struct irq_cfg *old_cfg) 328static 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 */
618static void add_pin_to_irq_cpu(struct irq_cfg *cfg, int cpu, int apic, int pin) 612static 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 */
653static void __init replace_pin_at_irq_cpu(struct irq_cfg *cfg, int cpu, 647static 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
676static inline void io_apic_modify_irq(struct irq_cfg *cfg, 670static 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
637void lguest_setup_irq(unsigned int irq) 637void 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}
diff --git a/drivers/pci/intr_remapping.c b/drivers/pci/intr_remapping.c
index f5e0ea724a6f..9eff36a293e0 100644
--- a/drivers/pci/intr_remapping.c
+++ b/drivers/pci/intr_remapping.c
@@ -23,15 +23,12 @@ struct irq_2_iommu {
23}; 23};
24 24
25#ifdef CONFIG_GENERIC_HARDIRQS 25#ifdef CONFIG_GENERIC_HARDIRQS
26static struct irq_2_iommu *get_one_free_irq_2_iommu(int cpu) 26static struct irq_2_iommu *get_one_free_irq_2_iommu(int node)
27{ 27{
28 struct irq_2_iommu *iommu; 28 struct irq_2_iommu *iommu;
29 int node;
30
31 node = cpu_to_node(cpu);
32 29
33 iommu = kzalloc_node(sizeof(*iommu), GFP_ATOMIC, node); 30 iommu = kzalloc_node(sizeof(*iommu), GFP_ATOMIC, node);
34 printk(KERN_DEBUG "alloc irq_2_iommu on cpu %d node %d\n", cpu, node); 31 printk(KERN_DEBUG "alloc irq_2_iommu on node %d\n", node);
35 32
36 return iommu; 33 return iommu;
37} 34}
@@ -48,7 +45,7 @@ static struct irq_2_iommu *irq_2_iommu(unsigned int irq)
48 return desc->irq_2_iommu; 45 return desc->irq_2_iommu;
49} 46}
50 47
51static struct irq_2_iommu *irq_2_iommu_alloc_cpu(unsigned int irq, int cpu) 48static struct irq_2_iommu *irq_2_iommu_alloc_node(unsigned int irq, int node)
52{ 49{
53 struct irq_desc *desc; 50 struct irq_desc *desc;
54 struct irq_2_iommu *irq_iommu; 51 struct irq_2_iommu *irq_iommu;
@@ -56,7 +53,7 @@ static struct irq_2_iommu *irq_2_iommu_alloc_cpu(unsigned int irq, int cpu)
56 /* 53 /*
57 * alloc irq desc if not allocated already. 54 * alloc irq desc if not allocated already.
58 */ 55 */
59 desc = irq_to_desc_alloc_cpu(irq, cpu); 56 desc = irq_to_desc_alloc_node(irq, node);
60 if (!desc) { 57 if (!desc) {
61 printk(KERN_INFO "can not get irq_desc for %d\n", irq); 58 printk(KERN_INFO "can not get irq_desc for %d\n", irq);
62 return NULL; 59 return NULL;
@@ -65,14 +62,14 @@ static struct irq_2_iommu *irq_2_iommu_alloc_cpu(unsigned int irq, int cpu)
65 irq_iommu = desc->irq_2_iommu; 62 irq_iommu = desc->irq_2_iommu;
66 63
67 if (!irq_iommu) 64 if (!irq_iommu)
68 desc->irq_2_iommu = get_one_free_irq_2_iommu(cpu); 65 desc->irq_2_iommu = get_one_free_irq_2_iommu(node);
69 66
70 return desc->irq_2_iommu; 67 return desc->irq_2_iommu;
71} 68}
72 69
73static struct irq_2_iommu *irq_2_iommu_alloc(unsigned int irq) 70static struct irq_2_iommu *irq_2_iommu_alloc(unsigned int irq)
74{ 71{
75 return irq_2_iommu_alloc_cpu(irq, boot_cpu_id); 72 return irq_2_iommu_alloc_node(irq, cpu_to_node(boot_cpu_id));
76} 73}
77 74
78#else /* !CONFIG_SPARSE_IRQ */ 75#else /* !CONFIG_SPARSE_IRQ */
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index 33389880279b..be437c2bc942 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -335,7 +335,7 @@ static int find_unbound_irq(void)
335 if (irq == nr_irqs) 335 if (irq == nr_irqs)
336 panic("No available IRQ to bind to: increase nr_irqs!\n"); 336 panic("No available IRQ to bind to: increase nr_irqs!\n");
337 337
338 desc = irq_to_desc_alloc_cpu(irq, 0); 338 desc = irq_to_desc_alloc_node(irq, 0);
339 if (WARN_ON(desc == NULL)) 339 if (WARN_ON(desc == NULL))
340 return -1; 340 return -1;
341 341
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 91bb76f44f14..ff374ceface0 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -566,6 +566,6 @@ struct irq_desc;
566extern int early_irq_init(void); 566extern int early_irq_init(void);
567extern int arch_probe_nr_irqs(void); 567extern int arch_probe_nr_irqs(void);
568extern int arch_early_irq_init(void); 568extern int arch_early_irq_init(void);
569extern int arch_init_chip_data(struct irq_desc *desc, int cpu); 569extern int arch_init_chip_data(struct irq_desc *desc, int node);
570 570
571#endif 571#endif
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 8e4c18b29157..a09baf8f9d99 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -187,7 +187,7 @@ struct irq_desc {
187 spinlock_t lock; 187 spinlock_t lock;
188#ifdef CONFIG_SMP 188#ifdef CONFIG_SMP
189 cpumask_var_t affinity; 189 cpumask_var_t affinity;
190 unsigned int cpu; 190 unsigned int node;
191#ifdef CONFIG_GENERIC_PENDING_IRQ 191#ifdef CONFIG_GENERIC_PENDING_IRQ
192 cpumask_var_t pending_mask; 192 cpumask_var_t pending_mask;
193#endif 193#endif
@@ -201,16 +201,16 @@ struct irq_desc {
201} ____cacheline_internodealigned_in_smp; 201} ____cacheline_internodealigned_in_smp;
202 202
203extern void arch_init_copy_chip_data(struct irq_desc *old_desc, 203extern void arch_init_copy_chip_data(struct irq_desc *old_desc,
204 struct irq_desc *desc, int cpu); 204 struct irq_desc *desc, int node);
205extern void arch_free_chip_data(struct irq_desc *old_desc, struct irq_desc *desc); 205extern void arch_free_chip_data(struct irq_desc *old_desc, struct irq_desc *desc);
206 206
207#ifndef CONFIG_SPARSE_IRQ 207#ifndef CONFIG_SPARSE_IRQ
208extern struct irq_desc irq_desc[NR_IRQS]; 208extern struct irq_desc irq_desc[NR_IRQS];
209#else /* CONFIG_SPARSE_IRQ */ 209#else /* CONFIG_SPARSE_IRQ */
210extern struct irq_desc *move_irq_desc(struct irq_desc *old_desc, int cpu); 210extern struct irq_desc *move_irq_desc(struct irq_desc *old_desc, int node);
211#endif /* CONFIG_SPARSE_IRQ */ 211#endif /* CONFIG_SPARSE_IRQ */
212 212
213extern struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu); 213extern struct irq_desc *irq_to_desc_alloc_node(unsigned int irq, int node);
214 214
215/* 215/*
216 * Migration helpers for obsolete names, they will go away: 216 * Migration helpers for obsolete names, they will go away:
@@ -422,12 +422,10 @@ extern int set_irq_msi(unsigned int irq, struct msi_desc *entry);
422 * Allocates affinity and pending_mask cpumask if required. 422 * Allocates affinity and pending_mask cpumask if required.
423 * Returns true if successful (or not required). 423 * Returns true if successful (or not required).
424 */ 424 */
425static inline bool alloc_desc_masks(struct irq_desc *desc, int cpu, 425static inline bool alloc_desc_masks(struct irq_desc *desc, int node,
426 bool boot) 426 bool boot)
427{ 427{
428#ifdef CONFIG_CPUMASK_OFFSTACK 428#ifdef CONFIG_CPUMASK_OFFSTACK
429 int node;
430
431 if (boot) { 429 if (boot) {
432 alloc_bootmem_cpumask_var(&desc->affinity); 430 alloc_bootmem_cpumask_var(&desc->affinity);
433 431
@@ -437,8 +435,6 @@ static inline bool alloc_desc_masks(struct irq_desc *desc, int cpu,
437 return true; 435 return true;
438 } 436 }
439 437
440 node = cpu_to_node(cpu);
441
442 if (!alloc_cpumask_var_node(&desc->affinity, GFP_ATOMIC, node)) 438 if (!alloc_cpumask_var_node(&desc->affinity, GFP_ATOMIC, node))
443 return false; 439 return false;
444 440
@@ -494,7 +490,7 @@ static inline void free_desc_masks(struct irq_desc *old_desc,
494 490
495#else /* !CONFIG_SMP */ 491#else /* !CONFIG_SMP */
496 492
497static inline bool alloc_desc_masks(struct irq_desc *desc, int cpu, 493static inline bool alloc_desc_masks(struct irq_desc *desc, int node,
498 bool boot) 494 bool boot)
499{ 495{
500 return true; 496 return true;
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index 3e0cbc44bd73..a6368db2618b 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -81,12 +81,10 @@ static struct irq_desc irq_desc_init = {
81 .lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock), 81 .lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
82}; 82};
83 83
84void init_kstat_irqs(struct irq_desc *desc, int cpu, int nr) 84void init_kstat_irqs(struct irq_desc *desc, int node, int nr)
85{ 85{
86 int node;
87 void *ptr; 86 void *ptr;
88 87
89 node = cpu_to_node(cpu);
90 ptr = kzalloc_node(nr * sizeof(*desc->kstat_irqs), GFP_ATOMIC, node); 88 ptr = kzalloc_node(nr * sizeof(*desc->kstat_irqs), GFP_ATOMIC, node);
91 89
92 /* 90 /*
@@ -94,33 +92,32 @@ void init_kstat_irqs(struct irq_desc *desc, int cpu, int nr)
94 * init_copy_kstat_irqs() could still use old one 92 * init_copy_kstat_irqs() could still use old one
95 */ 93 */
96 if (ptr) { 94 if (ptr) {
97 printk(KERN_DEBUG " alloc kstat_irqs on cpu %d node %d\n", 95 printk(KERN_DEBUG " alloc kstat_irqs on node %d\n", node);
98 cpu, node);
99 desc->kstat_irqs = ptr; 96 desc->kstat_irqs = ptr;
100 } 97 }
101} 98}
102 99
103static void init_one_irq_desc(int irq, struct irq_desc *desc, int cpu) 100static void init_one_irq_desc(int irq, struct irq_desc *desc, int node)
104{ 101{
105 memcpy(desc, &irq_desc_init, sizeof(struct irq_desc)); 102 memcpy(desc, &irq_desc_init, sizeof(struct irq_desc));
106 103
107 spin_lock_init(&desc->lock); 104 spin_lock_init(&desc->lock);
108 desc->irq = irq; 105 desc->irq = irq;
109#ifdef CONFIG_SMP 106#ifdef CONFIG_SMP
110 desc->cpu = cpu; 107 desc->node = node;
111#endif 108#endif
112 lockdep_set_class(&desc->lock, &irq_desc_lock_class); 109 lockdep_set_class(&desc->lock, &irq_desc_lock_class);
113 init_kstat_irqs(desc, cpu, nr_cpu_ids); 110 init_kstat_irqs(desc, node, nr_cpu_ids);
114 if (!desc->kstat_irqs) { 111 if (!desc->kstat_irqs) {
115 printk(KERN_ERR "can not alloc kstat_irqs\n"); 112 printk(KERN_ERR "can not alloc kstat_irqs\n");
116 BUG_ON(1); 113 BUG_ON(1);
117 } 114 }
118 if (!alloc_desc_masks(desc, cpu, false)) { 115 if (!alloc_desc_masks(desc, node, false)) {
119 printk(KERN_ERR "can not alloc irq_desc cpumasks\n"); 116 printk(KERN_ERR "can not alloc irq_desc cpumasks\n");
120 BUG_ON(1); 117 BUG_ON(1);
121 } 118 }
122 init_desc_masks(desc); 119 init_desc_masks(desc);
123 arch_init_chip_data(desc, cpu); 120 arch_init_chip_data(desc, node);
124} 121}
125 122
126/* 123/*
@@ -189,11 +186,10 @@ struct irq_desc *irq_to_desc(unsigned int irq)
189 return NULL; 186 return NULL;
190} 187}
191 188
192struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu) 189struct irq_desc *irq_to_desc_alloc_node(unsigned int irq, int node)
193{ 190{
194 struct irq_desc *desc; 191 struct irq_desc *desc;
195 unsigned long flags; 192 unsigned long flags;
196 int node;
197 193
198 if (irq >= nr_irqs) { 194 if (irq >= nr_irqs) {
199 WARN(1, "irq (%d) >= nr_irqs (%d) in irq_to_desc_alloc\n", 195 WARN(1, "irq (%d) >= nr_irqs (%d) in irq_to_desc_alloc\n",
@@ -212,15 +208,13 @@ struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu)
212 if (desc) 208 if (desc)
213 goto out_unlock; 209 goto out_unlock;
214 210
215 node = cpu_to_node(cpu);
216 desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node); 211 desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node);
217 printk(KERN_DEBUG " alloc irq_desc for %d on cpu %d node %d\n", 212 printk(KERN_DEBUG " alloc irq_desc for %d on node %d\n", irq, node);
218 irq, cpu, node);
219 if (!desc) { 213 if (!desc) {
220 printk(KERN_ERR "can not alloc irq_desc\n"); 214 printk(KERN_ERR "can not alloc irq_desc\n");
221 BUG_ON(1); 215 BUG_ON(1);
222 } 216 }
223 init_one_irq_desc(irq, desc, cpu); 217 init_one_irq_desc(irq, desc, node);
224 218
225 irq_desc_ptrs[irq] = desc; 219 irq_desc_ptrs[irq] = desc;
226 220
@@ -270,7 +264,7 @@ struct irq_desc *irq_to_desc(unsigned int irq)
270 return (irq < NR_IRQS) ? irq_desc + irq : NULL; 264 return (irq < NR_IRQS) ? irq_desc + irq : NULL;
271} 265}
272 266
273struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu) 267struct irq_desc *irq_to_desc_alloc_node(unsigned int irq, int node)
274{ 268{
275 return irq_to_desc(irq); 269 return irq_to_desc(irq);
276} 270}
diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h
index de5f412f6a92..73468253143b 100644
--- a/kernel/irq/internals.h
+++ b/kernel/irq/internals.h
@@ -16,7 +16,7 @@ extern void __disable_irq(struct irq_desc *desc, unsigned int irq, bool susp);
16extern void __enable_irq(struct irq_desc *desc, unsigned int irq, bool resume); 16extern void __enable_irq(struct irq_desc *desc, unsigned int irq, bool resume);
17 17
18extern struct lock_class_key irq_desc_lock_class; 18extern struct lock_class_key irq_desc_lock_class;
19extern void init_kstat_irqs(struct irq_desc *desc, int cpu, int nr); 19extern void init_kstat_irqs(struct irq_desc *desc, int node, int nr);
20extern void clear_kstat_irqs(struct irq_desc *desc); 20extern void clear_kstat_irqs(struct irq_desc *desc);
21extern spinlock_t sparse_irq_lock; 21extern spinlock_t sparse_irq_lock;
22 22
diff --git a/kernel/irq/numa_migrate.c b/kernel/irq/numa_migrate.c
index ce72bc3f4ced..2f69bee57bf2 100644
--- a/kernel/irq/numa_migrate.c
+++ b/kernel/irq/numa_migrate.c
@@ -15,9 +15,9 @@
15 15
16static void init_copy_kstat_irqs(struct irq_desc *old_desc, 16static void init_copy_kstat_irqs(struct irq_desc *old_desc,
17 struct irq_desc *desc, 17 struct irq_desc *desc,
18 int cpu, int nr) 18 int node, int nr)
19{ 19{
20 init_kstat_irqs(desc, cpu, nr); 20 init_kstat_irqs(desc, node, nr);
21 21
22 if (desc->kstat_irqs != old_desc->kstat_irqs) 22 if (desc->kstat_irqs != old_desc->kstat_irqs)
23 memcpy(desc->kstat_irqs, old_desc->kstat_irqs, 23 memcpy(desc->kstat_irqs, old_desc->kstat_irqs,
@@ -34,20 +34,20 @@ static void free_kstat_irqs(struct irq_desc *old_desc, struct irq_desc *desc)
34} 34}
35 35
36static bool init_copy_one_irq_desc(int irq, struct irq_desc *old_desc, 36static bool init_copy_one_irq_desc(int irq, struct irq_desc *old_desc,
37 struct irq_desc *desc, int cpu) 37 struct irq_desc *desc, int node)
38{ 38{
39 memcpy(desc, old_desc, sizeof(struct irq_desc)); 39 memcpy(desc, old_desc, sizeof(struct irq_desc));
40 if (!alloc_desc_masks(desc, cpu, false)) { 40 if (!alloc_desc_masks(desc, node, false)) {
41 printk(KERN_ERR "irq %d: can not get new irq_desc cpumask " 41 printk(KERN_ERR "irq %d: can not get new irq_desc cpumask "
42 "for migration.\n", irq); 42 "for migration.\n", irq);
43 return false; 43 return false;
44 } 44 }
45 spin_lock_init(&desc->lock); 45 spin_lock_init(&desc->lock);
46 desc->cpu = cpu; 46 desc->node = node;
47 lockdep_set_class(&desc->lock, &irq_desc_lock_class); 47 lockdep_set_class(&desc->lock, &irq_desc_lock_class);
48 init_copy_kstat_irqs(old_desc, desc, cpu, nr_cpu_ids); 48 init_copy_kstat_irqs(old_desc, desc, node, nr_cpu_ids);
49 init_copy_desc_masks(old_desc, desc); 49 init_copy_desc_masks(old_desc, desc);
50 arch_init_copy_chip_data(old_desc, desc, cpu); 50 arch_init_copy_chip_data(old_desc, desc, node);
51 return true; 51 return true;
52} 52}
53 53
@@ -59,12 +59,11 @@ static void free_one_irq_desc(struct irq_desc *old_desc, struct irq_desc *desc)
59} 59}
60 60
61static struct irq_desc *__real_move_irq_desc(struct irq_desc *old_desc, 61static struct irq_desc *__real_move_irq_desc(struct irq_desc *old_desc,
62 int cpu) 62 int node)
63{ 63{
64 struct irq_desc *desc; 64 struct irq_desc *desc;
65 unsigned int irq; 65 unsigned int irq;
66 unsigned long flags; 66 unsigned long flags;
67 int node;
68 67
69 irq = old_desc->irq; 68 irq = old_desc->irq;
70 69
@@ -76,7 +75,6 @@ static struct irq_desc *__real_move_irq_desc(struct irq_desc *old_desc,
76 if (desc && old_desc != desc) 75 if (desc && old_desc != desc)
77 goto out_unlock; 76 goto out_unlock;
78 77
79 node = cpu_to_node(cpu);
80 desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node); 78 desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node);
81 if (!desc) { 79 if (!desc) {
82 printk(KERN_ERR "irq %d: can not get new irq_desc " 80 printk(KERN_ERR "irq %d: can not get new irq_desc "
@@ -85,7 +83,7 @@ static struct irq_desc *__real_move_irq_desc(struct irq_desc *old_desc,
85 desc = old_desc; 83 desc = old_desc;
86 goto out_unlock; 84 goto out_unlock;
87 } 85 }
88 if (!init_copy_one_irq_desc(irq, old_desc, desc, cpu)) { 86 if (!init_copy_one_irq_desc(irq, old_desc, desc, node)) {
89 /* still use old one */ 87 /* still use old one */
90 kfree(desc); 88 kfree(desc);
91 desc = old_desc; 89 desc = old_desc;
@@ -107,24 +105,14 @@ out_unlock:
107 return desc; 105 return desc;
108} 106}
109 107
110struct irq_desc *move_irq_desc(struct irq_desc *desc, int cpu) 108struct irq_desc *move_irq_desc(struct irq_desc *desc, int node)
111{ 109{
112 int old_cpu;
113 int node, old_node;
114
115 /* those all static, do move them */ 110 /* those all static, do move them */
116 if (desc->irq < NR_IRQS_LEGACY) 111 if (desc->irq < NR_IRQS_LEGACY)
117 return desc; 112 return desc;
118 113
119 old_cpu = desc->cpu; 114 if (desc->node != node)
120 if (old_cpu != cpu) { 115 desc = __real_move_irq_desc(desc, node);
121 node = cpu_to_node(cpu);
122 old_node = cpu_to_node(old_cpu);
123 if (old_node != node)
124 desc = __real_move_irq_desc(desc, cpu);
125 else
126 desc->cpu = cpu;
127 }
128 116
129 return desc; 117 return desc;
130} 118}
diff --git a/kernel/softirq.c b/kernel/softirq.c
index b525dd348511..f674f332a024 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -828,7 +828,7 @@ int __init __weak arch_early_irq_init(void)
828 return 0; 828 return 0;
829} 829}
830 830
831int __weak arch_init_chip_data(struct irq_desc *desc, int cpu) 831int __weak arch_init_chip_data(struct irq_desc *desc, int node)
832{ 832{
833 return 0; 833 return 0;
834} 834}