All of lore.kernel.org
 help / color / mirror / Atom feed
From: "tip-bot2 for Ming Lei" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Ming Lei <ming.lei@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>, Borislav Petkov <bp@alien8.de>,
	linux-kernel@vger.kernel.org
Subject: [tip: irq/core] genirq/affinity: Improve __irq_build_affinity_masks()
Date: Tue, 27 Aug 2019 14:36:34 -0000	[thread overview]
Message-ID: <156691659442.23585.17929718097373200199.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20190816022849.14075-2-ming.lei@redhat.com>

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     53c1788b7d7720565214a466afffdc818d8c6e5f
Gitweb:        https://git.kernel.org/tip/53c1788b7d7720565214a466afffdc818d8c6e5f
Author:        Ming Lei <ming.lei@redhat.com>
AuthorDate:    Fri, 16 Aug 2019 10:28:48 +08:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Tue, 27 Aug 2019 16:31:17 +02:00

genirq/affinity: Improve __irq_build_affinity_masks()

One invariant of __irq_build_affinity_masks() is that all CPUs in the
specified masks (cpu_mask AND node_to_cpumask for each node) should be
covered during the spread. Even though all requested vectors have been
reached, it's still required to spread vectors among remained CPUs. A
similar policy has been taken in case of 'numvecs <= nodes' already.

So remove the following check inside the loop:

	if (done >= numvecs)
		break;

Meantime assign at least 1 vector for remaining nodes if 'numvecs' vectors
have been handled already.

Also, if the specified cpumask for one numa node is empty, simply do not
spread vectors on this node.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20190816022849.14075-2-ming.lei@redhat.com

---
 kernel/irq/affinity.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c
index 6fef480..c7cca94 100644
--- a/kernel/irq/affinity.c
+++ b/kernel/irq/affinity.c
@@ -129,14 +129,26 @@ static int __irq_build_affinity_masks(unsigned int startvec,
 	for_each_node_mask(n, nodemsk) {
 		unsigned int ncpus, v, vecs_to_assign, vecs_per_node;
 
-		/* Spread the vectors per node */
-		vecs_per_node = (numvecs - (curvec - firstvec)) / nodes;
-
 		/* Get the cpus on this node which are in the mask */
 		cpumask_and(nmsk, cpu_mask, node_to_cpumask[n]);
-
-		/* Calculate the number of cpus per vector */
 		ncpus = cpumask_weight(nmsk);
+		if (!ncpus)
+			continue;
+
+		/*
+		 * Calculate the number of cpus per vector
+		 *
+		 * Spread the vectors evenly per node. If the requested
+		 * vector number has been reached, simply allocate one
+		 * vector for each remaining node so that all nodes can
+		 * be covered
+		 */
+		if (numvecs > done)
+			vecs_per_node = max_t(unsigned,
+					(numvecs - done) / nodes, 1);
+		else
+			vecs_per_node = 1;
+
 		vecs_to_assign = min(vecs_per_node, ncpus);
 
 		/* Account for rounding errors */
@@ -156,13 +168,11 @@ static int __irq_build_affinity_masks(unsigned int startvec,
 		}
 
 		done += v;
-		if (done >= numvecs)
-			break;
 		if (curvec >= last_affv)
 			curvec = firstvec;
 		--nodes;
 	}
-	return done;
+	return done < numvecs ? done : numvecs;
 }
 
 /*

  reply	other threads:[~2019-08-27 14:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-16  2:28 [PATCH V5 0/2] genriq/affinity: Make vectors allocation fair Ming Lei
2019-08-16  2:28 ` Ming Lei
2019-08-16  2:28 ` [PATCH V5 1/2] genirq/affinity: Improve __irq_build_affinity_masks() Ming Lei
2019-08-16  2:28   ` Ming Lei
2019-08-27 14:36   ` tip-bot2 for Ming Lei [this message]
2019-08-16  2:28 ` [PATCH V5 2/2] genirq/affinity: Spread vectors on node according to nr_cpu ratio Ming Lei
2019-08-16  2:28   ` Ming Lei
2019-08-16 15:53   ` Keith Busch
2019-08-16 15:53     ` Keith Busch
2019-08-16 16:28     ` Ming Lei
2019-08-16 16:28       ` Ming Lei
2019-08-16 16:57     ` Derrick, Jonathan
2019-08-16 16:57       ` Derrick, Jonathan
2019-08-27 14:36   ` [tip: irq/core] " tip-bot2 for Ming Lei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=156691659442.23585.17929718097373200199.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=bp@alien8.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.