Skip to content

Commit a0c9259

Browse files
committed
irq/matrix: Spread interrupts on allocation
Keith reported an issue with vector space exhaustion on a server machine which is caused by the i40e driver allocating 168 MSI interrupts when the driver is initialized, even when most of these interrupts are not used at all. The x86 vector allocation code tries to avoid the immediate allocation with the reservation mode, but the card uses MSI and does not support MSI entry masking, which prevents reservation mode and requires immediate vector allocation. The matrix allocator is a bit naive and prefers the first CPU in the cpumask which describes the possible target CPUs for an allocation. That results in allocating all 168 vectors on CPU0 which later causes vector space exhaustion when the NVMe driver tries to allocate managed interrupts on each CPU for the per CPU queues. Avoid this by finding the CPU which has the lowest vector allocation count to spread out the non managed interrupt accross the possible target CPUs. Fixes: 2f75d9e ("genirq: Implement bitmap matrix allocator") Reported-by: Keith Busch <keith.busch@intel.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Keith Busch <keith.busch@intel.com> Link: https://lkml.kernel.org/r/alpine.DEB.2.20.1801171557330.1777@nanos
1 parent 1d966eb commit a0c9259

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

‎kernel/irq/matrix.c‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,15 +321,23 @@ void irq_matrix_remove_reserved(struct irq_matrix *m)
321321
int irq_matrix_alloc(struct irq_matrix *m, const struct cpumask *msk,
322322
bool reserved, unsigned int *mapped_cpu)
323323
{
324-
unsigned int cpu;
324+
unsigned int cpu, best_cpu, maxavl = 0;
325+
struct cpumap *cm;
326+
unsigned int bit;
325327

328+
best_cpu = UINT_MAX;
326329
for_each_cpu(cpu, msk) {
327-
struct cpumap *cm = per_cpu_ptr(m->maps, cpu);
328-
unsigned int bit;
330+
cm = per_cpu_ptr(m->maps, cpu);
329331

330-
if (!cm->online)
332+
if (!cm->online || cm->available <= maxavl)
331333
continue;
332334

335+
best_cpu = cpu;
336+
maxavl = cm->available;
337+
}
338+
339+
if (maxavl) {
340+
cm = per_cpu_ptr(m->maps, best_cpu);
333341
bit = matrix_alloc_area(m, cm, 1, false);
334342
if (bit < m->alloc_end) {
335343
cm->allocated++;
@@ -338,8 +346,8 @@ int irq_matrix_alloc(struct irq_matrix *m, const struct cpumask *msk,
338346
m->global_available--;
339347
if (reserved)
340348
m->global_reserved--;
341-
*mapped_cpu = cpu;
342-
trace_irq_matrix_alloc(bit, cpu, m, cm);
349+
*mapped_cpu = best_cpu;
350+
trace_irq_matrix_alloc(bit, best_cpu, m, cm);
343351
return bit;
344352
}
345353
}

0 commit comments

Comments
 (0)