2008-02-20 08:40:12

by Yinghai Lu

[permalink] [raw]
Subject: [PATCH 0/4] make dev_to_node return online node or -1

Please check update on dev_to_node().

YH


2008-02-20 08:40:35

by Yinghai Lu

[permalink] [raw]
Subject: [PATCH 1/4] make dev_to_node return online node



some numa system ( with multi HT chains) may return node without ram. aka it
is not online.
try to get one online node.

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

diff --git a/include/linux/device.h b/include/linux/device.h
index 2258d89..7f1a4d7 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -478,7 +478,12 @@ struct device {
#ifdef CONFIG_NUMA
static inline int dev_to_node(struct device *dev)
{
- return dev->numa_node;
+ int node;
+ node = dev->numa_node;
+
+ if (node != -1 && !node_online(node))
+ node = numa_node_id();
+ return node;
}
static inline void set_dev_node(struct device *dev, int node)
{

2008-02-20 08:40:50

by Yinghai Lu

[permalink] [raw]
Subject: [PATCH 3/4] ide: use dev_to_node instead of pcibus_to_node


when node0 doesn't have RAM, could have problem because pcibus_to_node may
return 0. So use update dev_to_node to get online node.

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

Index: linux-2.6/include/linux/ide.h
===================================================================
--- linux-2.6.orig/include/linux/ide.h
+++ linux-2.6/include/linux/ide.h
@@ -1294,8 +1294,7 @@ static inline void ide_dump_identify(u8

static inline int hwif_to_node(ide_hwif_t *hwif)
{
- struct pci_dev *dev = to_pci_dev(hwif->dev);
- return hwif->dev ? pcibus_to_node(dev->bus) : -1;
+ return hwif->dev ? dev_to_node(hwif->dev) : -1;
}

static inline ide_drive_t *ide_get_paired_drive(ide_drive_t *drive)


2008-02-20 08:41:08

by Yinghai Lu

[permalink] [raw]
Subject: [PATCH 4/4] driver: use dev_to_node in pci_call_probe

to make sure get one online node.

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

Index: linux-2.6/drivers/pci/pci-driver.c
===================================================================
--- linux-2.6.orig/drivers/pci/pci-driver.c
+++ linux-2.6/drivers/pci/pci-driver.c
@@ -181,8 +181,8 @@ static int pci_call_probe(struct pci_dri
any need to change it. */
struct mempolicy *oldpol;
cpumask_t oldmask = current->cpus_allowed;
- int node = pcibus_to_node(dev->bus);
- if (node >= 0 && node_online(node))
+ int node = dev_to_node(&dev->dev);
+ if (node >= 0)
set_cpus_allowed(current, node_to_cpumask(node));
/* And set default memory allocation policy */
oldpol = current->mempolicy;

2008-02-20 08:41:35

by Yinghai Lu

[permalink] [raw]
Subject: [PATCH 2/4] x86_64: fix dma_alloc_pages v2


one system with two nodes and two ht links on every node.
the bios already have _pxm for two links.

when no ram installed for node1 will have panic.

reason: the device on second chain will get node = 1 from dev_to_node...via
pci_acpi_scan_root.
but node1 doesn't have ram installed.
in dma_alloc_pages it will pass check with first_node(node_online_map)...
and will have problem with __alloc_pages in alloc_pages_node.

this patch will use updated dev_to node, so remove check about fist_node etc

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

Index: linux-2.6/arch/x86/kernel/pci-dma_64.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/pci-dma_64.c
+++ linux-2.6/arch/x86/kernel/pci-dma_64.c
@@ -53,12 +53,6 @@ dma_alloc_pages(struct device *dev, gfp_
int node;

node = dev_to_node(dev);
- if (node == -1)
- node = numa_node_id();
-
- if (node < first_node(node_online_map))
- node = first_node(node_online_map);
-
page = alloc_pages_node(node, gfp, order);
return page ? page_address(page) : NULL;
}

2008-02-20 09:59:03

by Yinghai Lu

[permalink] [raw]
Subject: Re: [PATCH 2/4] x86_64: fix dma_alloc_pages v2

please use this one instead.

because v1 already in mm, and that doesn't depends on 1/4 here.

[PATCH 2/4] x86_64: fix dma_alloc_pages fix

this patch will use updated dev_to node, because dev_to_node already make sure
it have node online

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

diff --git a/arch/x86/kernel/pci-dma_64.c b/arch/x86/kernel/pci-dma_64.c
index 931b51a..375cb2b 100644
--- a/arch/x86/kernel/pci-dma_64.c
+++ b/arch/x86/kernel/pci-dma_64.c
@@ -53,8 +53,6 @@ dma_alloc_pages(struct device *dev, gfp_t gfp, unsigned order)
int node;

node = dev_to_node(dev);
- if (node == -1 || !node_online(node))
- node = numa_node_id();

page = alloc_pages_node(node, gfp, order);
return page ? page_address(page) : NULL;

2008-02-20 20:33:54

by Yinghai Lu

[permalink] [raw]
Subject: Re: [PATCH 1/4] make dev_to_node return online node

please use this one instead. this one is less intrusive, and pcibus_to_node will work too
and don't need other changes.

YH

---

[PATCH] make dev_to_node return online node v2

some numa system ( with multi HT chains) may return node without ram. aka it
is not online.
try to get one online node, otherwise return -1

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

diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index c163ad1..2c1a651 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -213,6 +213,9 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int do
set_mp_bus_to_node(busnum, node);
else
node = get_mp_bus_to_node(busnum);
+
+ if (node != -1 && !node_online(node))
+ node = -1;
#endif

/* Allocate per-root-bus (not per bus) arch-specific data.