Skip to content

Commit d6ffc6a

Browse files
committed
x86/vector: Respect affinity mask in irq descriptor
The interrupt descriptor has a preset affinity mask at allocation time, which is usually the default affinity mask. The current code does not respect that mask and places the vector at some random CPU, which gets corrected later by a set_affinity() call. That's silly because the vector allocation can respect the mask upfront and place the interrupt on a CPU which is in the mask. If that fails, then the affinity is broken and a interrupt assigned on any online CPU. Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Juergen Gross <[email protected]> Tested-by: Yu Chen <[email protected]> Acked-by: Juergen Gross <[email protected]> Cc: Boris Ostrovsky <[email protected]> Cc: Tony Luck <[email protected]> Cc: Marc Zyngier <[email protected]> Cc: Alok Kataria <[email protected]> Cc: Joerg Roedel <[email protected]> Cc: "Rafael J. Wysocki" <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Paolo Bonzini <[email protected]> Cc: Rui Zhang <[email protected]> Cc: "K. Y. Srinivasan" <[email protected]> Cc: Arjan van de Ven <[email protected]> Cc: Dan Williams <[email protected]> Cc: Len Brown <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 2cffad7 commit d6ffc6a

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

arch/x86/kernel/apic/vector.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,25 @@ static int assign_irq_vector(struct irq_data *irqd, const struct cpumask *dest)
249249

250250
static int assign_irq_vector_any_locked(struct irq_data *irqd)
251251
{
252+
/* Get the affinity mask - either irq_default_affinity or (user) set */
253+
const struct cpumask *affmsk = irq_data_get_affinity_mask(irqd);
252254
int node = irq_data_get_node(irqd);
253255

254-
if (node != NUMA_NO_NODE) {
255-
if (!assign_vector_locked(irqd, cpumask_of_node(node)))
256-
return 0;
257-
}
256+
if (node == NUMA_NO_NODE)
257+
goto all;
258+
/* Try the intersection of @affmsk and node mask */
259+
cpumask_and(vector_searchmask, cpumask_of_node(node), affmsk);
260+
if (!assign_vector_locked(irqd, vector_searchmask))
261+
return 0;
262+
/* Try the node mask */
263+
if (!assign_vector_locked(irqd, cpumask_of_node(node)))
264+
return 0;
265+
all:
266+
/* Try the full affinity mask */
267+
cpumask_and(vector_searchmask, affmsk, cpu_online_mask);
268+
if (!assign_vector_locked(irqd, vector_searchmask))
269+
return 0;
270+
/* Try the full online mask */
258271
return assign_vector_locked(irqd, cpu_online_mask);
259272
}
260273

0 commit comments

Comments
 (0)