+ x86_64-get-mp_bus_to_node-as-early.patch added to -mm tree
[email protected]
tree noticeThe patch titled
x86_64: get mp_bus_to_node as early
has been added to the -mm tree. Its filename is
x86_64-get-mp_bus_to_node-as-early.patch*** Remember to use Documentation/SubmitChecklist when testing your code ***
See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this
------------------------------------------------------
Subject: x86_64: get mp_bus_to_node as early
From: Yinghai Lu <[email protected]>
In struct device, we already have numa_node member. and we can use dev_to_node() /set_dev_node() to get and set numa_node in the device. set_dev_node is called in pci_device_add() with pcibus_to_node(bus). and pci_bus_to_node use bus->sysdata for nodeid.
The problem is when pci_add_device is called, bus->sysdata is not assigned correct nodeid yet. the result will be numa_node always is 0. pcibios_scan_root and pci_scan_root could take sysdata. So we need to get mp_bus_to_node mapping before these two are called. and get_mp_bus_to_node could get correct node for sysdata in root bus.
In scanning of root bus, all child bus will take parent bus sysdata. So all pci_device->dev.numa_node will be assigned correctly automatically. later we could use dev_to_node(&pci_dev->dev) to numa_node, and we could also could make other bus specific device get the correct numa_node too. and in different driver we could use kmalloc_node instead of kmalloc for skbuff/net or urb/usb etc. That could help improve performance with usb or net or sata for AMD K8 two sockets beyond system.
For example:
Two way opteron system and only one HT chain on node 0. USB controller on SB will be on node0. some dma accessing is used with kmalloc/dma_map_single. and these address will be on node1 instead of node0. and even worse, when node1 ram is above 4G, we may need to iommu mapping for usb operation. two way system with one HT chain on different node, we will need to kmalloc/dma_map_single to use ram on corresonding node too. esp for nvidia mcp55/io55 system. the second io55 could have nic/sata/pcie devices.
---
arch/i386/pci/Makefile | 1 arch/i386/pci/acpi.c | 21 ++++---- arch/i386/pci/common.c | 9 +++ arch/i386/pci/irq.c | 4 + arch/i386/pci/legacy.c | 4 + arch/i386/pci/mp_bus_to_node.c | 23 +++++++++ arch/x86_64/pci/k8-bus.c | 79 ++++++++++++++++++++++--------- include/asm-i386/topology.h | 10 +++ include/asm-x86_64/topology.h | 13 +++++ 9 files changed, 130 insertions(+), 34 deletions(-)
arch/i386/pci/Makefile renamed from arch/i386/pci/Makefile~x86_64-get-mp_bus_to_node-as-early +1 -0
@@ -10,5 +10,6 @@ pci-y += legacy.o irq.o pci-$(CONFIG_X86_VISWS) := visws.o fixup.o pci-$(CONFIG_X86_NUMAQ) := numa.o irq.o +pci-$(CONFIG_NUMA) += mp_bus_to_node.o obj-y += $(pci-y) common.o early.o
arch/i386/pci/acpi.c renamed from arch/i386/pci/acpi.c~x86_64-get-mp_bus_to_node-as-early +12 -9
@@ -8,24 +8,27 @@struct pci_bus *__devinit pci_acpi_scan_root (struct acpi_device *device,int domain,int busnum) {struct pci_bus *bus; +#ifdef CONFIG_ACPI_NUMA +int pxm; +int node; +#endif if (domain !=0 ) {printk (KERN_WARNING "PCI: Multiple domains not supported\n" );return NULL ; } - bus =pcibios_scan_root (busnum);#ifdef CONFIG_ACPI_NUMA -if (bus !=NULL ) { -int pxm =acpi_get_pxm (device->handle); -if (pxm >=0 ) { - bus->sysdata = (void *)(unsigned long )pxm_to_node (pxm); -printk ("bus %d -> pxm %d -> node %ld\n" , - busnum, pxm, (long )(bus->sysdata)); - } + pxm =acpi_get_pxm (device->handle); +if (pxm >=0 ) { + node =pxm_to_node (pxm); +printk ("bus %02x -> pxm %d -> node %02x\n" , busnum, pxm, node); +set_mp_bus_to_node (busnum, node); }#endif - + + bus =pcibios_scan_root (busnum); +return bus; }
arch/i386/pci/common.c renamed from arch/i386/pci/common.c~x86_64-get-mp_bus_to_node-as-early +8 -1
@@ -293,6 +293,7 @@ static struct dmi_system_id __devinitdatstruct pci_bus *__devinit pcibios_scan_root (int busnum) {struct pci_bus *bus =NULL ; +long node;dmi_check_system (pciprobe_dmi_table);
@@ -303,9 +304,15 @@ struct pci_bus * __devinit pcibios_scan_ } } + node =get_mp_bus_to_node (busnum); + +#ifdef CONFIG_NUMA +printk (KERN_DEBUG "PCI: Probing PCI hardware (bus %02x) with (node %02lx)\n" , busnum, node); +#else printk (KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n" , busnum); +#endif -return pci_scan_bus_parented (NULL , busnum, &pci_root_ops,NULL ); +return pci_scan_bus_parented (NULL , busnum, &pci_root_ops, (void *)node); }extern u8 pci_cache_line_size;
arch/i386/pci/irq.c renamed from arch/i386/pci/irq.c~x86_64-get-mp_bus_to_node-as-early +3 -1
@@ -136,9 +136,11 @@ static void __init pirq_peer_trick(void) busmap[e->bus] =1 ; }for (i =1 ; i <256 ; i++) { +long node;if (!busmap[i] ||pci_find_bus (0 , i))continue ; -if (pci_scan_bus (i, &pci_root_ops,NULL )) + node =get_mp_bus_to_node (i); +if (pci_scan_bus (i, &pci_root_ops, (void *)node))printk (KERN_INFO "PCI: Discovered primary peer bus %02x [IRQ]\n" , i); } pcibios_last_bus =-1 ;
arch/i386/pci/legacy.c renamed from arch/i386/pci/legacy.c~x86_64-get-mp_bus_to_node-as-early +3 -1
@@ -12,6 +12,7 @@static void __devinit pcibios_fixup_peer_bridges (void ) {int n, devfn; +long node;if (pcibios_last_bus <=0 || pcibios_last_bus >=0xff )return ;
@@ -21,12 +22,13 @@ static void __devinit pcibios_fixup_peeru32 l;if (pci_find_bus (0 , n))continue ; + node =get_mp_bus_to_node (n);for (devfn =0 ; devfn <256 ; devfn +=8 ) {if (!raw_pci_ops->read (0 , n, devfn,PCI_VENDOR_ID ,2 , &l) && l !=0x0000 && l !=0xffff ) {DBG ("Found device at %02x:%02x [%04x]\n" , n, devfn, l);printk (KERN_INFO "PCI: Discovered peer bus %02x\n" , n); -pci_scan_bus (n, &pci_root_ops,NULL ); +pci_scan_bus (n, &pci_root_ops, (void *)node);break ; } }
arch/i386/pci/mp_bus_to_node.c new file +23 -0
@@ -0,0 +1,23 @@ +#include <linux/pci.h> +#include <linux/init.h> +#include <asm/topology.h> + +#define BUS_NR 256 + +static unsigned char mp_bus_to_node[BUS_NR ]; + +void set_mp_bus_to_node (int busnum,int node) +{ +if (busnum >=0 && busnum <BUS_NR ) + mp_bus_to_node[busnum] = (unsigned char ) node; +} + +int get_mp_bus_to_node (int busnum) +{ +int node; + +if (busnum <0 || busnum > (BUS_NR -1 ) ) +return 0 ; + node = mp_bus_to_node[busnum]; +return node; +}
arch/x86_64/pci/k8-bus.c renamed from arch/x86_64/pci/k8-bus.c~x86_64-get-mp_bus_to_node-as-early +57 -22
124 lines not on this page · raw message
include/asm-i386/topology.h renamed from include/asm-i386/topology.h~x86_64-get-mp_bus_to_node-as-early +10 -0
@@ -101,7 +101,17 @@ extern unsigned long node_remap_size[];#define node_has_online_mem (nid) (node_start_pfn[nid] != node_end_pfn[nid]) +int get_mp_bus_to_node (int busnum); +void set_mp_bus_to_node (int busnum,int node); +#else /* !CONFIG_NUMA */ +static inline int get_mp_bus_to_node (int busnum) +{ +return 0 ; +} +static inline void set_mp_bus_to_node (int busnum,int node) +{ +}/* * Other i386 platforms should define their own version of the * above macros here.
include/asm-x86_64/topology.h renamed from include/asm-x86_64/topology.h~x86_64-get-mp_bus_to_node-as-early +13 -0
@@ -53,6 +53,19 @@ extern int __node_distance(int, int); .nr_balance_failed = 0, \ } +int get_mp_bus_to_node (int busnum); +void set_mp_bus_to_node (int busnum,int node); + +#else + +static inline int get_mp_bus_to_node (int busnum) +{ +return 0 ; +} +static inline void set_mp_bus_to_node (int busnum,int node) +{ +} +#endif #ifdef CONFIG_SMP
_
Patches currently in -mm which might be from [email protected] are
serial-assert-dtr-for-serial-console-devices.patch usb-make-the-usb_device-numa_node-to-get-assigned-from.patch x86-64-disable-the-gart-in-shutdown.patch x86_84-move-iommu-declaration-from-proto-to-iommuh.patch x86_64-change-_map_single-to-static-in-pci_gartc-etc.patch x86_64-geode-hw-random-number-generator-depend-on-x86_3.patch x86_64-get-mp_bus_to_node-as-early.patch console-more-buf-for-index-parsing.patch console-console-handover-to-preferred-console.patch serial-convert-early_uart-to-earlycon-for-8250.patch serial-convert-early_uart-to-earlycon-for-8250-fix.patch serial-convert-early_uart-to-earlycon-for-8250-ia64-fix.patch serial-convert-early_uart-to-earlycon-for-8250-fix-3-alias.patch
PATCH 1/4 try parent numa_node at first before using default
[PATCH 1/4] try parent numa_node at first before using default
drivers/base/core.c +5 -1
@@ -547,6 +547,8 @@ static void klist_children_put(struct klist_node *n)void device_initialize (struct device *dev) { +int node; +kobj_set_kset_s (dev, devices_subsys);kobject_init (&dev->kobj); klist_init(&dev->klist_children, klist_children_get,
@@ -557,7 +559,9 @@ void device_initialize(struct device *dev)spin_lock_init (&dev->devres_lock);INIT_LIST_HEAD (&dev->devres_head);device_init_wakeup (dev,0 ); -set_dev_node (dev,-1 ); + + node = dev->parent ?dev_to_node (dev->parent) :-1 ; +set_dev_node (dev, node); }#ifdef CONFIG_SYSFS_DEPRECATED
Re: [PATCH 1/4] try parent numa_node at first before using default
Quoted 18 lines · Yinghai Lu
[PATCH 1/4] try parent
numa_nodeat first before using defaultSigned-off-by Yinghai Lu <[email protected]>drivers/base/core.c +2
-0@@ -547,6 +547,8 @@ static void klist_children_put(struct klist_node *n)void device_initialize (struct device *dev) { +int node; +kobj_set_kset_s (dev, devices_subsys);kobject_init (&dev->kobj); klist_init(&dev->klist_children, klist_children_get,
drivers/base/core.c void device_initialize(struct device *dev) · line 565
Quoted 8 lines
drivers/base/core.c +3
-1@@ -557,7 +559,9 @@ void device_initialize(struct device *dev)spin_lock_init (&dev->devres_lock);INIT_LIST_HEAD (&dev->devres_head);device_init_wakeup (dev,0 ); -set_dev_node (dev,-1 ); + + node = dev->parent ?dev_to_node (dev->parent) :-1 ; +set_dev_node (dev, node); }
What is this going to give us?
Doesn't it mean that all devices will end up on the same node?
thanks,
greg k-h
Re: [PATCH 1/4] try parent numa_node at first before using default
Quoted 21 lines · Greg KH
Quoted 10 lines
drivers/base/core.c +2
-0@@ -547,6 +547,8 @@ static void klist_children_put(struct klist_node *n)void device_initialize (struct device *dev) { +int node; +kobj_set_kset_s (dev, devices_subsys);kobject_init (&dev->kobj); klist_init(&dev->klist_children, klist_children_get,drivers/base/core.c void device_initialize(struct device *dev) · line 565
Quoted 8 lines
drivers/base/core.c +3
-1@@ -557,7 +559,9 @@ void device_initialize(struct device *dev)spin_lock_init (&dev->devres_lock);INIT_LIST_HEAD (&dev->devres_head);device_init_wakeup (dev,0 ); -set_dev_node (dev,-1 ); + + node = dev->parent ?dev_to_node (dev->parent) :-1 ; +set_dev_node (dev, node); }What is this going to give us?
Quoted 1 line
Doesn't it mean that all devices will end up on the same node?
It means that the node for the device is the same as the parent device. F.e. if the parent device is a bus that is connected to node 4 then all the devices hooked up to the bus are allocated on that node.
Re: [PATCH 1/4] try parent numa_node at first before using default
Quoted 23 lines · Christoph Lameter
Quoted 21 lines · Greg KH
Quoted 10 lines
drivers/base/core.c +2
-0@@ -547,6 +547,8 @@ static void klist_children_put(struct klist_node *n)void device_initialize (struct device *dev) { +int node; +kobj_set_kset_s (dev, devices_subsys);kobject_init (&dev->kobj); klist_init(&dev->klist_children, klist_children_get,drivers/base/core.c void device_initialize(struct device *dev) · line 565
Quoted 8 lines
drivers/base/core.c +3
-1@@ -557,7 +559,9 @@ void device_initialize(struct device *dev)spin_lock_init (&dev->devres_lock);INIT_LIST_HEAD (&dev->devres_head);device_init_wakeup (dev,0 ); -set_dev_node (dev,-1 ); + + node = dev->parent ?dev_to_node (dev->parent) :-1 ; +set_dev_node (dev, node); }What is this going to give us?
Quoted 5 lines
Quoted 1 line
Doesn't it mean that all devices will end up on the same node?
It means that the node for the device is the same as the parent device. F.e. if the parent device is a bus that is connected to node 4 then all the devices hooked up to the bus are allocated on that node.
Yes, but is someone setting the parent device node information properly?
And this really needs some more changelog information please. Why is this needed from how things are done today?
thanks,
greg k-h
Re: [PATCH 1/4] try parent numa_node at first before using default
Quoted 9 lines · Greg KH
Quoted 3 lines · Christoph Lameter
It means that the node for the device is the same as the parent device. F.e. if the parent device is a bus that is connected to node 4 then all the devices hooked up to the bus are allocated on that node.
Yes, but is someone setting the parent device node information properly?
And this really needs some more changelog information please. Why is this needed from how things are done today?
please check if you are happy with the changlog
----------------------------------------------------begin--------------------- For pci_device, pcibios_scan_root and pci_scan_root will call pci_device_add. pci_device_add will call device_initialize and set_dev_node(&dev->dev, pcibus_to_node(bus)).
other device such as netdev, and usb_device, set_dev_node is never be used. So that field numa_node always is -1.
So for netdev, it will need to use dev->parent to get pci_device to use it's numa_node. esp in netdev_alloc_skb()
not sure how other device such as infiniband do that.
Actually before patch
[PATCH 1/2] x86_64: get mp_bus_to_node as early
there is a bug about squence of bus->sysdata and using pcibus_to_node. the numa_node of pci_dev->dev is never set correctly...always 0.
So some device have to use pcibus_to_node(to_pci_dev(dev)->bus) directly such as dma_alloc_pages in arch/x86_64/kernel/pci-dma.c.
or hwif_to_node in include/linux/ide.h
with this patch, we could use device->numa_node direclty for all device. -------------------------------------------------end-----------
YH
Re: [PATCH 1/4] try parent numa_node at first before using default
In reply to Greg KHQuoted 5 lines · Greg KH
Quoted 2 lines · Yinghai Lu
[PATCH 1/4] try parent
numa_nodeat first before using defaultWhat is this going to give us?
you can use dev_to_node(netdev->dev) or dev_to_node(usb_device->dev) directly, and don't need to go to find pci_device up to get numa_node.
Quoted 2 lines
Doesn't it mean that all devices will end up on the same node?
yes.
For x86_64, devices under node1 will have 1, and device under node0 will all have 0.
current only pci_dev->dev.numa_node is used.
YH