public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <ak@suse.de>
To: christoph@lameter.com, akpm@osdl.org, linux-kernel@vger.kernel.org
Cc: linux-pci@vger.kernel.org, gregkh@suse.de
Subject: [PATCH] Run PCI driver initialization on local node
Date: Wed, 6 Jul 2005 15:32:48 +0200	[thread overview]
Message-ID: <20050706133248.GG21330@wotan.suse.de> (raw)


Run PCI driver initialization on local node

Instead of adding messy kmalloc_node()s everywhere run the 
PCI driver probe on the node local to the device.
Then the normal NUMA aware allocators do the right thing.

This would not have helped for IDE, but should for 
other more clean drivers that do more initialization in probe().
It won't help for drivers that do most of the work
on first open (like many network drivers)

Signed-off-by: Andi Kleen <ak@suse.de> 
cc: christoph@lameter.com

Index: linux/drivers/pci/pci-driver.c
===================================================================
--- linux.orig/drivers/pci/pci-driver.c
+++ linux/drivers/pci/pci-driver.c
@@ -167,6 +167,27 @@ const struct pci_device_id *pci_match_de
 	return NULL;
 }
 
+static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev, 
+			  const struct pci_device_id *id)
+{
+	int error;
+#ifdef CONFIG_NUMA
+	/* Execute driver initialization on node where the 
+	   device's bus is attached to.  This way the driver likely
+	   allocates its local memory on the right node without
+	   any need to change it. */
+	cpumask_t oldmask = current->cpus_allowed;
+	int node = pcibus_to_node(dev->bus);
+	if (node >= 0 && node_online(node))
+	    set_cpus_allowed(current, node_to_cpumask(node));	
+#endif
+	error = drv->probe(dev, id);
+#ifdef CONFIG_NUMA
+	set_cpus_allowed(current, oldmask);
+#endif
+	return error;
+}
+
 /**
  * __pci_device_probe()
  * 
@@ -184,7 +205,7 @@ __pci_device_probe(struct pci_driver *dr
 
 		id = pci_match_device(drv, pci_dev);
 		if (id)
-			error = drv->probe(pci_dev, id);
+			error = pci_call_probe(drv, pci_dev, id);
 		if (error >= 0) {
 			pci_dev->driver = drv;
 			error = 0;

             reply	other threads:[~2005-07-06 18:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-06 13:32 Andi Kleen [this message]
2005-07-06 16:35 ` [PATCH] Run PCI driver initialization on local node Christoph Lameter
2005-07-06 17:56   ` Andi Kleen
2005-07-06 18:01     ` Christoph Lameter
2005-07-06 18:13       ` Andi Kleen
2005-07-06 18:28         ` Christoph Lameter
2005-07-06 19:31         ` Christoph Lameter
2005-07-06 19:33     ` Christoph Lameter
2005-07-07 10:39       ` Andi Kleen
2005-07-07 13:52         ` Christoph Lameter
2005-07-07 14:13           ` Andi Kleen

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=20050706133248.GG21330@wotan.suse.de \
    --to=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=christoph@lameter.com \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox