irq/matrix: Spread interrupts on allocation
authorThomas Gleixner <tglx@linutronix.de>
Wed, 17 Jan 2018 15:01:47 +0000 (16:01 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 18 Jan 2018 10:38:41 +0000 (11:38 +0100)
commita0c9259dc4e1923a98356967ce8b732da1979df8
tree6829c45481346a20cc62efa2e6c5dedcc3cc6f1a
parent1d966eb4d6326a2521073174e9710713e9846e8b
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: 2f75d9e1c905 ("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
kernel/irq/matrix.c