All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brice Goglin <Brice.Goglin@inria.fr>
To: LKML <linux-kernel@vger.kernel.org>
Cc: netdev@vger.kernel.org
Subject: [RFC] export irq_set/get_affinity() for multiqueue network drivers
Date: Thu, 28 Aug 2008 22:21:53 +0200	[thread overview]
Message-ID: <48B708E1.4070001@inria.fr> (raw)

[-- Attachment #1: Type: text/plain, Size: 655 bytes --]

Hello,

Is there any way to setup IRQ masks from within a driver? myri10ge
currently relies on an external script (writing in
/proc/irq/*/smp_affinity) to bind each queue/MSI-X to a different
processor. By default, Linux will either:
* round-robin the interrupts (killing the benefit of DCA for instance)
* put all IRQs on the same CPU (killing much of the benefit of multislices)

With more and more drivers using multiqueues, I think we need a nice way
to bind MSI-X from within the drivers. I am not sure what's best, the
attached (untested) patch would just export the existing
irq_set_affinity() and add irq_get_affinity(). Comments?

thanks,
Brice


[-- Attachment #2: export_irq_affinity.patch --]
[-- Type: text/x-patch, Size: 1804 bytes --]

[PATCH] export irq_set/get_affinity() to modules

Export irq_set_affinity() and add/export irq_get_affinity() so that
network drivers may access MSI-X interrupt masks to bind multiqueues
to different CPUs. Otherwise Linux will either:
* round-robin the interrupts (killing the benefit of DCA, for instance)
* put all IRQs on the same CPU (killing much of the benefit of multislices)

Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
---
 include/linux/interrupt.h |    3 +++
 kernel/irq/manage.c       |   15 +++++++++++++++
 2 files changed, 18 insertions(+)

--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -107,6 +107,7 @@ extern void enable_irq(unsigned int irq);
 extern cpumask_t irq_default_affinity;
 
 extern int irq_set_affinity(unsigned int irq, cpumask_t cpumask);
+extern int irq_get_affinity(unsigned int irq, cpumask_t *cpumask);
 extern int irq_can_set_affinity(unsigned int irq);
 extern int irq_select_affinity(unsigned int irq);
 
@@ -117,6 +118,8 @@ static inline int irq_set_affinity(unsigned int irq, cpumask_t cpumask)
 	return -EINVAL;
 }
 
+static inline int irq_get_affinity(unsigned int irq)  { return 0; }
+
 static inline int irq_can_set_affinity(unsigned int irq)
 {
 	return 0;
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -96,6 +96,21 @@ int irq_set_affinity(unsigned int irq, cpumask_t cpumask)
 #endif
 	return 0;
 }
+EXPORT_SYMBOL(irq_set_affinity);
+
+int irq_get_affinity(unsigned int irq, cpumask_t *cpumask)
+{
+	struct irq_desc *desc = irq_desc + irq;
+	cpumask_t *mask = &desc->affinity;
+
+#ifdef CONFIG_GENERIC_PENDING_IRQ
+	if (desc->status & IRQ_MOVE_PENDING)
+		mask = &desc->pending_mask;
+#endif
+	memcpy(cpumask, mask, sizeof(*mask);
+	return 0;
+}
+EXPORT_SYMBOL(irq_get_affinity);
 
 #ifndef CONFIG_AUTO_IRQ_AFFINITY
 /*

             reply	other threads:[~2008-08-28 20:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-28 20:21 Brice Goglin [this message]
2008-08-28 20:56 ` [RFC] export irq_set/get_affinity() for multiqueue network drivers David Miller
2008-08-29  7:08   ` Brice Goglin
2008-08-29 12:50 ` Arjan van de Ven
2008-08-29 16:48   ` Andi Kleen
2008-08-29 16:52     ` Arjan van de Ven
2008-08-29 17:14     ` Rick Jones

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=48B708E1.4070001@inria.fr \
    --to=brice.goglin@inria.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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.