Skip to contentSkip to conversation

x86 - irq vector assignment

PATCH In review Jack Steiner 3 participants 5 messages Sep 21, 2010 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86 - irq vector assignment

Try to assign irq vectors to cpus on the correct node & fall back to global assignment only if node-local fails. This reduces the chances of using all of the interrupt vectors of a single cpu.

---
Note: this is a fix for a problem we saw on systems with a large number of IOHs. The IOHs are distributed across 10's of nodes.

Early in boot, the IO infrastructure assigns interrupts for the DMA engines. Currently, all interrupts are targeted to cpu 0. This uses all interrupt vectors on cpu 0. Later, some drivers try to create irqs targeted to cpu 0. The assignment fails because all vectors are assigned.

This is a repost of a patch sent earlier. See

	http://marc.info/?l=linux-kernel&m=127740806705617&w=2
	http://marc.info/?l=linux-kernel&m=127791052828867&w=2
 arch/x86/kernel/apic/io_apic.c |    5 +++++
 1 file changed, 5 insertions(+)
arch/x86/kernel/apic/io_apic.c +5 -0
Index: linux/arch/x86/kernel/apic/io_apic.c
===================================================================
@@ -3253,6 +3253,11 @@ unsigned int create_irq_nr(unsigned int
 		desc_new = move_irq_desc(desc_new, node);
 		cfg_new = desc_new->chip_data;
 
+#ifdef CONFIG_NUMA
+		if (node >= 0 && __assign_irq_vector(new, cfg_new, node_to_cpumask_map[node]) == 0)
+			irq = new;
+		else
+#endif
 		if (__assign_irq_vector(new, cfg_new, apic->target_cpus()) == 0)
 			irq = new;
 		break;
#1 lore raw
Quoted 31 lines · Jack Steiner

Try to assign irq vectors to cpus on the correct node & fall back to global assignment only if node-local fails. This reduces the chances of using all of the interrupt vectors of a single cpu.

---
Note: this is a fix for a problem we saw on systems with a large number of IOHs. The IOHs are distributed across 10's of nodes.

Early in boot, the IO infrastructure assigns interrupts for the DMA engines. Currently, all interrupts are targeted to cpu 0. This uses all interrupt vectors on cpu 0. Later, some drivers try to create irqs targeted to cpu 0. The assignment fails because all vectors are assigned.

This is a repost of a patch sent earlier. See
       http://marc.info/?l=linux-kernel&m=127740806705617&w=2
       http://marc.info/?l=linux-kernel&m=127791052828867&w=2

 arch/x86/kernel/apic/io_apic.c |    5 +++++

 1 file changed, 5 insertions(+)

Index: linux/arch/x86/kernel/apic/io_apic.c
===================================================================

arch/x86/kernel/apic/io_apic.c        2010-09-17 13:00:23.448595373 -0500 renamed from arch/x86/kernel/apic/io_apic.c   2010-09-17 13:00:19.164638447 -0500 +0 -0
@@ -3253,6 +3253,11 @@ unsigned int create_irq_nr(unsigned int
                desc_new = move_irq_desc(desc_new, node);

arch/x86/kernel/apic/io_apic.c        2010-09-17 13:00:23.448595373 -0500 unsigned int create_irq_nr(unsigned int · line 3263

Quoted 10 lines
arch/x86/kernel/apic/io_apic.c        2010-09-17 13:00:23.448595373 -0500 renamed from arch/x86/kernel/apic/io_apic.c   2010-09-17 13:00:19.164638447 -0500 +5 -0
                cfg_new = desc_new->chip_data;
 
+#ifdef CONFIG_NUMA
+               if (node >= 0 && __assign_irq_vector(new, cfg_new, node_to_cpumask_map[node]) == 0)
+                       irq = new;
+               else
+#endif
                if (__assign_irq_vector(new, cfg_new, apic->target_cpus()) == 0)
                        irq = new;
                break;

target_cpus() for uv_x and x2apic phys mode all have cpu_online_mask()

so we should get the vector for other cpus. aka __assign_irq_vector() should not fail. unless you have so many irq > nr_irqs.

current code we only make sure irq_desc on device local node.

for the vectors, user can set irq smp_affinity move the device local cpus if needed.

Thanks

Yinghai

#2 lore raw
Quoted 22 lines · Yinghai Lu
Quoted 9 lines

 arch/x86/kernel/apic/io_apic.c |    5 +++++

 1 file changed, 5 insertions(+)

Index: linux/arch/x86/kernel/apic/io_apic.c
===================================================================

arch/x86/kernel/apic/io_apic.c        2010-09-17 13:00:23.448595373 -0500 renamed from arch/x86/kernel/apic/io_apic.c   2010-09-17 13:00:19.164638447 -0500 +0 -0
@@ -3253,6 +3253,11 @@ unsigned int create_irq_nr(unsigned int
                desc_new = move_irq_desc(desc_new, node);

arch/x86/kernel/apic/io_apic.c        2010-09-17 13:00:23.448595373 -0500 unsigned int create_irq_nr(unsigned int · line 3263

Quoted 10 lines
arch/x86/kernel/apic/io_apic.c        2010-09-17 13:00:23.448595373 -0500 renamed from arch/x86/kernel/apic/io_apic.c   2010-09-17 13:00:19.164638447 -0500 +5 -0
                cfg_new = desc_new->chip_data;
 
+#ifdef CONFIG_NUMA
+               if (node >= 0 && __assign_irq_vector(new, cfg_new, node_to_cpumask_map[node]) == 0)
+                       irq = new;
+               else
+#endif
                if (__assign_irq_vector(new, cfg_new, apic->target_cpus()) == 0)
                        irq = new;
                break;

target_cpus() for uv_x and x2apic phys mode all have cpu_online_mask()

Quoted 2 lines

so we should get the vector for other cpus. aka __assign_irq_vector() should not fail. unless you have so many irq > nr_irqs.

Did you even read the changelog ? It's not about "should".

All CPU0 vectors are assigned already just because the current code takes the first cpu in the target_cpus mask regardless of the node on which the irq_desc is allocated. That's crap. Why do we allocate irq_desc on node and leave the vector assigned to node(cpu0) ?

Quoted 1 line

current code we only make sure irq_desc on device local node.

Brilliant.

Quoted 2 lines

for the vectors, user can set irq smp_affinity move the device local cpus if needed.

What a nonsense. If we allocate irq_desc on a target node it does not make any sense to target the vector to whatever random node/cpu in the first place and wait for user space to fix it up. What about running into that situation _before_ we hit user space ?

Thanks,

tglx

#3 lore raw
Quoted 26 lines · Thomas Gleixner
Quoted 22 lines · Yinghai Lu
Quoted 9 lines
 arch/x86/kernel/apic/io_apic.c |    5 +++++
 1 file changed, 5 insertions(+)

Index: linux/arch/x86/kernel/apic/io_apic.c
===================================================================

arch/x86/kernel/apic/io_apic.c 2010-09-17 13:00:23.448595373 -0500 renamed from arch/x86/kernel/apic/io_apic.c 2010-09-17 13:00:19.164638447 -0500 +0 -0
@@ -3253,6 +3253,11 @@ unsigned int create_irq_nr(unsigned int
               desc_new = move_irq_desc(desc_new, node);

arch/x86/kernel/apic/io_apic.c 2010-09-17 13:00:23.448595373 -0500 unsigned int create_irq_nr(unsigned int · line 3263

Quoted 10 lines
arch/x86/kernel/apic/io_apic.c 2010-09-17 13:00:23.448595373 -0500 renamed from arch/x86/kernel/apic/io_apic.c 2010-09-17 13:00:19.164638447 -0500 +5 -0
               cfg_new = desc_new->chip_data;
 
+#ifdef CONFIG_NUMA
+               if (node >= 0 && __assign_irq_vector(new, cfg_new, node_to_cpumask_map[node]) == 0)
+                       irq = new;
+               else
+#endif
               if (__assign_irq_vector(new, cfg_new, apic->target_cpus()) == 0)
                       irq = new;
               break;

target_cpus() for uv_x and x2apic phys mode all have cpu_online_mask()

Quoted 2 lines

so we should get the vector for other cpus. aka __assign_irq_vector() should not fail. unless you have so many irq > nr_irqs.

Quoted 6 lines

Did you even read the changelog ? It's not about "should".

All CPU0 vectors are assigned already just because the current code takes the first cpu in the target_cpus mask regardless of the node on which the irq_desc is allocated. That's crap. Why do we allocate irq_desc on node and leave the vector assigned to node(cpu0) ?

ok, i got it. vectors from cpus on node0 are used by devices from others nodes.
later devices from node0 can not get vector from node0.

Yinghai

#4 lore raw
Quoted 29 lines · Yinghai Lu
Quoted 28 lines · Thomas Gleixner
Quoted 22 lines · Yinghai Lu
Quoted 9 lines
 arch/x86/kernel/apic/io_apic.c |    5 +++++
 1 file changed, 5 insertions(+)

Index: linux/arch/x86/kernel/apic/io_apic.c
===================================================================

arch/x86/kernel/apic/io_apic.c 2010-09-17 13:00:23.448595373 -0500 renamed from arch/x86/kernel/apic/io_apic.c 2010-09-17 13:00:19.164638447 -0500 +0 -0
@@ -3253,6 +3253,11 @@ unsigned int create_irq_nr(unsigned int
               desc_new = move_irq_desc(desc_new, node);

arch/x86/kernel/apic/io_apic.c 2010-09-17 13:00:23.448595373 -0500 unsigned int create_irq_nr(unsigned int · line 3263

Quoted 10 lines
arch/x86/kernel/apic/io_apic.c 2010-09-17 13:00:23.448595373 -0500 renamed from arch/x86/kernel/apic/io_apic.c 2010-09-17 13:00:19.164638447 -0500 +5 -0
               cfg_new = desc_new->chip_data;
 
+#ifdef CONFIG_NUMA
+               if (node >= 0 && __assign_irq_vector(new, cfg_new, node_to_cpumask_map[node]) == 0)
+                       irq = new;
+               else
+#endif
               if (__assign_irq_vector(new, cfg_new, apic->target_cpus()) == 0)
                       irq = new;
               break;

target_cpus() for uv_x and x2apic phys mode all have cpu_online_mask()

Quoted 2 lines

so we should get the vector for other cpus. aka __assign_irq_vector() should not fail. unless you have so many irq > nr_irqs.

Did you even read the changelog ? It's not about "should".

Quoted 7 lines
Quoted 4 lines

All CPU0 vectors are assigned already just because the current code takes the first cpu in the target_cpus mask regardless of the node on which the irq_desc is allocated. That's crap. Why do we allocate irq_desc on node and leave the vector assigned to node(cpu0) ?

ok, i got it. vectors from cpus on node0 are used by devices from others nodes.
later devices from node0 can not get vector from node0.

Does that resolve all of your questions or are there still other issues.