]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
genirq: Ensure affinity masks include one present CPU for each vector
authorDavid Woodhouse <dwmw@amazon.co.uk>
Tue, 6 Oct 2020 11:09:19 +0000 (12:09 +0100)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 7 Oct 2020 10:28:14 +0000 (11:28 +0100)
Where allocating more MSI-X vectors for a device than there are CPUs in
the system, irq_build_affinity_masks() will end up creating affinities
for some vectors which don't include *any* present CPUs.

Make it try harder to assign at least one present CPU to each vector.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
kernel/irq/affinity.c

index 3fba9220fea65255485cf51f17893a752926071a..a53c4e6f04345c69c0fb657afa76050591b42ef6 100644 (file)
@@ -364,12 +364,17 @@ static int irq_build_affinity_masks(unsigned int startvec, unsigned int numvecs,
                cpumask_copy(npresmsk, cpu_present_mask);
 
        /* Spread on present CPUs starting from affd->pre_vectors */
-       ret = __irq_build_affinity_masks(curvec, numvecs, firstvec,
-                                        node_to_cpumask, cpu_present_mask,
-                                        nmsk, masks);
-       if (ret < 0)
-               goto fail_build_affinity;
-       nr_present = ret;
+       while (nr_present < numvecs) {
+               curvec = firstvec + nr_present;
+               ret = __irq_build_affinity_masks(curvec, numvecs, firstvec,
+                                                node_to_cpumask, npresmsk,
+                                                nmsk, masks);
+               if (ret < 0)
+                       goto fail_build_affinity;
+               if (!ret)
+                       break;
+               nr_present += ret;
+       }
 
        /*
         * Spread on non present CPUs starting from the next vector to be