linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] genirq/affinity: Assign default affinity to pre/post vectors
@ 2018-12-31  3:03 Huacai Chen
  2019-01-15 19:10 ` Thomas Gleixner
  0 siblings, 1 reply; 7+ messages in thread
From: Huacai Chen @ 2018-12-31  3:03 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: linux-kernel, Fuxin Zhang, Zhangjin Wu, Huacai Chen, stable,
	Christoph Hellwig, Michael Hernandez

Generally, irq_create_affinity_masks() assign default affinity to pre/
post vectors correctly. However, it ignore the case that there are only
pre/post vectors (when nvecs == affd->pre_vectors + affd->post_vectors)
and return NULL. This case usually happens when nvecs = 1 (e.g. in nvme
driver when MSI-X is unavailable and fallback to MSI) and will trigger
the warning in pci_irq_get_affinity(). This patch fix the corner case.

Fixes: 6f9a22bc5775d231ab8f ("PCI/MSI: Ignore affinity if pre/post vector count is more than min_vecs")
Cc: stable@vger.kernel.org
Cc: Christoph Hellwig <hch@lst.de>
Cc: Michael Hernandez <michael.hernandez@cavium.com>
Signed-off-by: Huacai Chen <chenhc@lemote.com>
---
 kernel/irq/affinity.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c
index 45b68b4..9b766eb 100644
--- a/kernel/irq/affinity.c
+++ b/kernel/irq/affinity.c
@@ -240,13 +240,6 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd)
 	struct irq_affinity_desc *masks = NULL;
 	int i, nr_sets;
 
-	/*
-	 * If there aren't any vectors left after applying the pre/post
-	 * vectors don't bother with assigning affinity.
-	 */
-	if (nvecs == affd->pre_vectors + affd->post_vectors)
-		return NULL;
-
 	node_to_cpumask = alloc_node_to_cpumask();
 	if (!node_to_cpumask)
 		return NULL;
@@ -255,6 +248,17 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd)
 	if (!masks)
 		goto outnodemsk;
 
+	/*
+	 * If there aren't any vectors left after applying the pre/post
+	 * vectors then just assign the default affinity to all vectors.
+	 */
+	if (nvecs == affd->pre_vectors + affd->post_vectors) {
+		/* Fill all vectors that don't need affinity */
+		for (curvec = 0; curvec < nvecs; curvec++)
+			cpumask_copy(&masks[curvec].mask, irq_default_affinity);
+		goto outnodemsk;
+	}
+
 	/* Fill out vectors at the beginning that don't need affinity */
 	for (curvec = 0; curvec < affd->pre_vectors; curvec++)
 		cpumask_copy(&masks[curvec].mask, irq_default_affinity);
-- 
2.7.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-01-22 21:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-31  3:03 [PATCH] genirq/affinity: Assign default affinity to pre/post vectors Huacai Chen
2019-01-15 19:10 ` Thomas Gleixner
2019-01-16  3:00   ` 陈华才
2019-01-16  9:26     ` Thomas Gleixner
2019-01-17  1:14       ` 陈华才
2019-01-18  1:52         ` Huacai Chen
2019-01-22 21:04           ` Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).