Skip to content

Commit 784a083

Browse files
committed
genirq/matrix: Deal with the sillyness of for_each_cpu() on UP
Most of the CPU mask operations behave the same way, but for_each_cpu() and it's variants ignore the cpumask argument and claim that CPU0 is always in the mask. This is historical, inconsistent and annoying behaviour. The matrix allocator uses for_each_cpu() and can be called on UP with an empty cpumask. The calling code does not expect that this succeeds but until commit e027fff ("x86/irq: Unbreak interrupt affinity setting") this went unnoticed. That commit added a WARN_ON() to catch cases which move an interrupt from one vector to another on the same CPU. The warning triggers on UP. Add a check for the cpumask being empty to prevent this. Fixes: 2f75d9e ("genirq: Implement bitmap matrix allocator") Reported-by: kernel test robot <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected]
1 parent e027fff commit 784a083

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

kernel/irq/matrix.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,13 @@ int irq_matrix_alloc(struct irq_matrix *m, const struct cpumask *msk,
380380
unsigned int cpu, bit;
381381
struct cpumap *cm;
382382

383+
/*
384+
* Not required in theory, but matrix_find_best_cpu() uses
385+
* for_each_cpu() which ignores the cpumask on UP .
386+
*/
387+
if (cpumask_empty(msk))
388+
return -EINVAL;
389+
383390
cpu = matrix_find_best_cpu(m, msk);
384391
if (cpu == UINT_MAX)
385392
return -ENOSPC;

0 commit comments

Comments
 (0)