linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Use NUMA node cpu mask in irq affinity [v3]
@ 2012-03-26 19:02 Prarit Bhargava
  2012-03-29  9:54 ` [tip:irq/core] genirq: Respect NUMA node affinity in setup_irq_irq affinity() tip-bot for Prarit Bhargava
  0 siblings, 1 reply; 2+ messages in thread
From: Prarit Bhargava @ 2012-03-26 19:02 UTC (permalink / raw)
  To: linux-kernel; +Cc: Prarit Bhargava, Yinghai Lu, Thomas Gleixner, David Rientjes

[Resending ... Seems to have died on the vine here
http://marc.info/?l=linux-kernel&m=132914231706596&q=raw ]

The irq affinity files (/proc/irq/.../smp_affinity) contain a mask that is
used to "pin" an irq to a set of cpus.  On boot this set is currently all
cpus.  This can be incorrect as ACPI SRAT may tell us that a specific
device or bus is attached to a particular node and it's cpus.

When setting up the irq affinity we should take into account the NUMA node
cpu mask by and'ing it into the irq's affinity mask.

[v2]: Thomas and Yinghai pointed out that it is possible that the mask is
empty after and'ing in the NUMA node's cpumask.  The code now checks to see
if the mask will be empty before applying the NUMA node's cpumask.

[v3]: David requests NUMA_NO_NODE instead of -1

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: David Rientjes <rientjes@google.com>
---
 kernel/irq/manage.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index b0ccd1a..96a18f1 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -301,6 +301,13 @@ setup_affinity(unsigned int irq, struct irq_desc *desc, struct cpumask *mask)
 	}
 
 	cpumask_and(mask, cpu_online_mask, set);
+	if (desc->irq_data.node != NUMA_NO_NODE) {
+		const struct cpumask *nodemask =
+					   cpumask_of_node(desc->irq_data.node);
+		/* make sure at least one of the cpus in nodemask is online */
+		if (cpumask_intersects(mask, nodemask))
+			cpumask_and(mask, mask, nodemask);
+	}
 	ret = chip->irq_set_affinity(&desc->irq_data, mask, false);
 	switch (ret) {
 	case IRQ_SET_MASK_OK:
-- 
1.7.1


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

* [tip:irq/core] genirq: Respect NUMA node affinity in setup_irq_irq affinity()
  2012-03-26 19:02 [PATCH] Use NUMA node cpu mask in irq affinity [v3] Prarit Bhargava
@ 2012-03-29  9:54 ` tip-bot for Prarit Bhargava
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Prarit Bhargava @ 2012-03-29  9:54 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, yinghai, nhorman, tglx, prarit, rientjes

Commit-ID:  241fc640be783f903e74b6d9c68481c01873f758
Gitweb:     http://git.kernel.org/tip/241fc640be783f903e74b6d9c68481c01873f758
Author:     Prarit Bhargava <prarit@redhat.com>
AuthorDate: Mon, 26 Mar 2012 15:02:18 -0400
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 29 Mar 2012 11:31:53 +0200

genirq: Respect NUMA node affinity in setup_irq_irq affinity()

We respect node affinity of devices already in the irq descriptor
allocation, but we ignore it for the initial interrupt affinity
setup, so the interrupt might be routed to a different node.

Restrict the default affinity mask to the node on which the irq
descriptor is allocated.

[ tglx: Massaged changelog ]

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Link: http://lkml.kernel.org/r/1332788538-17425-1-git-send-email-prarit@redhat.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/irq/manage.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index bf606a5..89a3ea8 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -282,7 +282,7 @@ setup_affinity(unsigned int irq, struct irq_desc *desc, struct cpumask *mask)
 {
 	struct irq_chip *chip = irq_desc_get_chip(desc);
 	struct cpumask *set = irq_default_affinity;
-	int ret;
+	int ret, node = desc->irq_data.node;
 
 	/* Excludes PER_CPU and NO_BALANCE interrupts */
 	if (!irq_can_set_affinity(irq))
@@ -301,6 +301,13 @@ setup_affinity(unsigned int irq, struct irq_desc *desc, struct cpumask *mask)
 	}
 
 	cpumask_and(mask, cpu_online_mask, set);
+	if (node != NUMA_NO_NODE) {
+		const struct cpumask *nodemask = cpumask_of_node(node);
+
+		/* make sure at least one of the cpus in nodemask is online */
+		if (cpumask_intersects(mask, nodemask))
+			cpumask_and(mask, mask, nodemask);
+	}
 	ret = chip->irq_set_affinity(&desc->irq_data, mask, false);
 	switch (ret) {
 	case IRQ_SET_MASK_OK:

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

end of thread, other threads:[~2012-03-29  9:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-26 19:02 [PATCH] Use NUMA node cpu mask in irq affinity [v3] Prarit Bhargava
2012-03-29  9:54 ` [tip:irq/core] genirq: Respect NUMA node affinity in setup_irq_irq affinity() tip-bot for Prarit Bhargava

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).