2008-02-19 11:15:28

by Yinghai Lu

[permalink] [raw]
Subject: [PATCH 5/8] try parent numa_node at first before using default v2


in the device_add, we try to use use parent numa_node.
need to make sure pci root bus's bridge device numa_node is set.
then we could use device->numa_node direclty for all device.
and don't need to call pcibus_to_node().

Signed-off-by: Yinghai Lu <[email protected]>

Index: linux-2.6/drivers/pci/probe.c
===================================================================
--- linux-2.6.orig/drivers/pci/probe.c
+++ linux-2.6/drivers/pci/probe.c
@@ -964,7 +964,6 @@ void pci_device_add(struct pci_dev *dev,
dev->dev.release = pci_release_dev;
pci_dev_get(dev);

- set_dev_node(&dev->dev, pcibus_to_node(bus));
dev->dev.dma_mask = &dev->dma_mask;
dev->dev.dma_parms = &dev->dma_parms;
dev->dev.coherent_dma_mask = 0xffffffffull;
@@ -1116,6 +1115,9 @@ struct pci_bus * pci_create_bus(struct d
goto dev_reg_err;
b->bridge = get_device(dev);

+ if (!parent)
+ set_dev_node(b->bridge, pcibus_to_node(b));
+
b->dev.class = &pcibus_class;
b->dev.parent = b->bridge;
sprintf(b->dev.bus_id, "%04x:%02x", pci_domain_nr(b), bus);
Index: linux-2.6/drivers/base/core.c
===================================================================
--- linux-2.6.orig/drivers/base/core.c
+++ linux-2.6/drivers/base/core.c
@@ -788,6 +788,10 @@ int device_add(struct device *dev)
parent = get_device(dev->parent);
setup_parent(dev, parent);

+ /* use parent numa_node */
+ if (parent)
+ set_dev_node(dev, dev_to_node(parent));
+
/* first, register with generic layer. */
error = kobject_add(&dev->kobj, dev->kobj.parent, "%s", dev->bus_id);
if (error)
@@ -1339,8 +1343,11 @@ int device_move(struct device *dev, stru
dev->parent = new_parent;
if (old_parent)
klist_remove(&dev->knode_parent);
- if (new_parent)
+ if (new_parent) {
klist_add_tail(&dev->knode_parent, &new_parent->klist_children);
+ set_dev_node(dev, dev_to_node(new_parent));
+ }
+
if (!dev->class)
goto out_put;
error = device_move_class_links(dev, old_parent, new_parent);
@@ -1350,9 +1357,12 @@ int device_move(struct device *dev, stru
if (!kobject_move(&dev->kobj, &old_parent->kobj)) {
if (new_parent)
klist_remove(&dev->knode_parent);
- if (old_parent)
+ dev->parent = old_parent;
+ if (old_parent) {
klist_add_tail(&dev->knode_parent,
&old_parent->klist_children);
+ set_dev_node(dev, dev_to_node(old_parent));
+ }
}
cleanup_glue_dir(dev, new_parent_kobj);
put_device(new_parent);


2008-02-19 17:57:16

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 5/8] try parent numa_node at first before using default v2

On Tue, Feb 19, 2008 at 03:20:41AM -0800, Yinghai Lu wrote:
>
> in the device_add, we try to use use parent numa_node.
> need to make sure pci root bus's bridge device numa_node is set.
> then we could use device->numa_node direclty for all device.
> and don't need to call pcibus_to_node().
>
> Signed-off-by: Yinghai Lu <[email protected]>

This should be split into different patches, one for the driver core,
and one for the PCI stuff as they are doing totally different things
here.

thanks,

greg k-h

2008-02-19 19:31:49

by Yinghai Lu

[permalink] [raw]
Subject: Re: [PATCH 5/8] try parent numa_node at first before using default v2

On Tuesday 19 February 2008 09:54:23 am Greg KH wrote:
> On Tue, Feb 19, 2008 at 03:20:41AM -0800, Yinghai Lu wrote:
> >
> > in the device_add, we try to use use parent numa_node.
> > need to make sure pci root bus's bridge device numa_node is set.
> > then we could use device->numa_node direclty for all device.
> > and don't need to call pcibus_to_node().
> >
> > Signed-off-by: Yinghai Lu <[email protected]>
>
> This should be split into different patches, one for the driver core,
> and one for the PCI stuff as they are doing totally different things
> here.

but one for the driver core, rely on the one for pci stuff.
without the one pci stuff, the one for the driver core doesn't work.

last time you already said it's ok. I will dig the mail out if needed.

YH