x86_64: get mp_bus_to_node as early
Subsystems (5)
PATCH 1/2 x86_64: get mp_bus_to_node as early
[PATCH 1/2] x86_64: get mp_bus_to_node as early
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). andpci_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 getmp_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 allpci_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 -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 +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 +8 -1
@@ -293,6 +293,7 @@ static struct dmi_system_id __devinitdata pciprobe_dmi_table[] = {struct 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_root(int busnum) } } + 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 +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 +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_peer_bridges(void)u32 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/x86_64/pci/k8-bus.c +57 -22
124 lines not on this page · raw message
include/asm-i386/topology.h +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 +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
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; +}
PATCH 1/4 usb: make the usb_device numa_node to get assigned from controller
[PATCH 1/4] usb: make the usb_device numa_node to get assigned from controller
So we can use dev_to_node(&usb_dev->dev) later in kmalloc_node to dma buffer
drivers/usb/core/usb.c +1 -0
@@ -253,6 +253,7 @@ usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1) dev->dev.bus = &usb_bus_type; dev->dev.type = &usb_device_type; dev->dev.dma_mask = bus->controller->dma_mask; +set_dev_node (&dev->dev,dev_to_node (bus->controller)); dev->state =USB_STATE_ATTACHED ;INIT_LIST_HEAD (&dev->ep0.urb_list);
PATCH 2/4 dma: make dma pool to use kmalloc_node
In reply to Yinghai Lu[PATCH 2/4] dma: make dma pool to use kmalloc_node
Using dev_to_node(&dev->dev) to get node, and kmalloc_node to dma buffer on corresding node dma pool
drivers/base/dmapool.c +1 -1
@@ -127,7 +127,7 @@ dma_pool_create (const char *name, struct device *dev, }else if (allocation < size)return NULL ; -if (!(retval =kmalloc (sizeof *retval,GFP_KERNEL ))) +if (!(retval =kmalloc_node (sizeof *retval,GFP_KERNEL ,dev_to_node (dev))))return retval;strlcpy (retval->name, name,sizeof retval->name);
PATCH 3/4 usb: allocated usb releated dma buffer with kmalloc_node
In reply to Yinghai Lu[PATCH 3/4] usb: allocated usb releated dma buffer with kmalloc_node
For amd64 based two way system. USB always on node0. but dma buffer for urb allocated via kmalloc always get ram on node1. So change to kmalloc_node to get dma_buffer on corresponding node
drivers/usb/core/config.c +2 -2
@@ -504,7 +504,7 @@ int usb_get_configuration(struct usb_device *dev)if (!dev->rawdescriptors) goto err2; - buffer =kmalloc (USB_DT_CONFIG_SIZE ,GFP_KERNEL ); + buffer =kmalloc_node (USB_DT_CONFIG_SIZE ,GFP_KERNEL ,dev_to_node (&dev->dev));if (!buffer) goto err2; desc = (struct usb_config_descriptor *)buffer;
@@ -531,7 +531,7 @@ int usb_get_configuration(struct usb_device *dev) USB_DT_CONFIG_SIZE);/* Now that we know the length, get the whole thing */ - bigbuffer =kmalloc (length,GFP_KERNEL ); + bigbuffer =kmalloc_node (length,GFP_KERNEL ,dev_to_node (&dev->dev));if (!bigbuffer) { result = -ENOMEM ; goto err;
drivers/usb/core/devio.c +4 -4
@@ -718,7 +718,7 @@ static int proc_bulk(struct dev_state *ps, void __user *arg) len1 = bulk.len;if (len1 >MAX_USBFS_BUFFER_SIZE )return -EINVAL ; -if (!(tbuf =kmalloc (len1,GFP_KERNEL ))) +if (!(tbuf =kmalloc_node (len1,GFP_KERNEL ,dev_to_node (&dev->dev))))return -ENOMEM ; tmo = bulk.timeout;if (bulk.ep &0x80 ) {
@@ -938,7 +938,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,/* min 8 byte setup packet, max 8 byte setup plus an arbitrary data stage */ if (uurb->buffer_length <8 || uurb->buffer_length > (8 +MAX_USBFS_BUFFER_SIZE ))return -EINVAL ; -if (!(dr =kmalloc (sizeof (struct usb_ctrlrequest ),GFP_KERNEL ))) +if (!(dr =kmalloc_node (sizeof (struct usb_ctrlrequest ),GFP_KERNEL ,dev_to_node (&ps->dev->dev))))return -ENOMEM ;if (copy_from_user (dr, uurb->buffer,8 )) {kfree (dr);
@@ -990,7 +990,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, != USB_ENDPOINT_XFER_ISOC)return -EINVAL ; isofrmlen =sizeof (struct usbdevfs_iso_packet_desc ) * uurb->number_of_packets; -if (!(isopkt =kmalloc (isofrmlen,GFP_KERNEL ))) +if (!(isopkt =kmalloc_node (isofrmlen,GFP_KERNEL ,dev_to_node (&ps->dev->dev))))return -ENOMEM ;if (copy_from_user (isopkt, iso_frame_desc, isofrmlen)) {kfree (isopkt);
@@ -1032,7 +1032,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,kfree (dr);return -ENOMEM ; } -if (!(as->urb->transfer_buffer =kmalloc (uurb->buffer_length,GFP_KERNEL ))) { +if (!(as->urb->transfer_buffer =kmalloc_node (uurb->buffer_length,GFP_KERNEL ,dev_to_node (&ps->dev->dev)))) {kfree (isopkt);kfree (dr);free_async (as);
drivers/usb/core/hcd.c +0 -0
drivers/usb/core/hub.c +6 -6
@@ -449,7 +449,7 @@ void usb_hub_tt_clear_buffer (struct usb_device *udev, int pipe)* since each TT has "at least two" buffers that can need it (and * there can be many TTs per hub). even if they're uncommon. */ -if ((clear =kmalloc (sizeof *clear,GFP_ATOMIC )) ==NULL ) { +if ((clear =kmalloc_node (sizeof *clear,GFP_ATOMIC ,dev_to_node (&udev->dev))) ==NULL ) {dev_err (&udev->dev,"can't save CLEAR_TT_BUFFER state\n" );/* FIXME recover somehow ... RESET_TT? */ return ;
@@ -611,7 +611,7 @@ static int hub_configure(struct usb_hub *hub, goto fail; } - hub->status =kmalloc (sizeof (*hub->status),GFP_KERNEL ); + hub->status =kmalloc_node (sizeof (*hub->status),GFP_KERNEL ,dev_to_node (&hdev->dev));if (!hub->status) { message ="can't kmalloc hub status buffer" ; ret = -ENOMEM ;
@@ -619,7 +619,7 @@ static int hub_configure(struct usb_hub *hub, }mutex_init (&hub->status_mutex); - hub->descriptor =kmalloc (sizeof (*hub->descriptor),GFP_KERNEL ); + hub->descriptor =kmalloc_node (sizeof (*hub->descriptor),GFP_KERNEL ,dev_to_node (&hdev->dev));if (!hub->descriptor) { message ="can't kmalloc hub descriptor" ; ret = -ENOMEM ;
@@ -2213,7 +2213,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,int r =0 ;#define GET_DESCRIPTOR_BUFSIZE 64 - buf =kmalloc (GET_DESCRIPTOR_BUFSIZE ,GFP_NOIO ); + buf =kmalloc_node (GET_DESCRIPTOR_BUFSIZE ,GFP_NOIO ,dev_to_node (&udev->dev));if (!buf) { retval = -ENOMEM ;continue ;
@@ -2343,7 +2343,7 @@ check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1)struct usb_qualifier_descriptor *qual;int status; - qual =kmalloc (sizeof *qual,GFP_KERNEL ); + qual =kmalloc_node (sizeof *qual,GFP_KERNEL ,dev_to_node (&udev->dev));if (qual ==NULL )return ;
@@ -2894,7 +2894,7 @@ static int config_descriptors_changed(struct usb_device *udev)if (len <le16_to_cpu (udev->config[index].desc.wTotalLength)) len =le16_to_cpu (udev->config[index].desc.wTotalLength); } - buf =kmalloc (len,GFP_KERNEL ); + buf =kmalloc_node (len,GFP_KERNEL ,dev_to_node (&udev->dev));if (buf ==NULL ) {dev_err (&udev->dev,"no mem to re-read configs after reset\n" );/* assume the worst */
drivers/usb/core/message.c +7 -7
@@ -120,7 +120,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,int usb_control_msg (struct usb_device *dev,unsigned int pipe,__u8 request,__u8 requesttype,__u16 value,__u16 index,void *data,__u16 size,int timeout) { -struct usb_ctrlrequest *dr =kmalloc (sizeof (struct usb_ctrlrequest ),GFP_NOIO ); +struct usb_ctrlrequest *dr =kmalloc_node (sizeof (struct usb_ctrlrequest ),GFP_NOIO ,dev_to_node (&dev->dev));int ret;if (!dr)
@@ -765,7 +765,7 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)if (size <=0 || !buf || !index)return -EINVAL ; buf[0 ] =0 ; - tbuf =kmalloc (256 ,GFP_KERNEL ); + tbuf =kmalloc_node (256 ,GFP_KERNEL ,dev_to_node (&dev->dev));if (!tbuf)return -ENOMEM ;
@@ -828,9 +828,9 @@ char *usb_cache_string(struct usb_device *udev, int index)char *smallbuf =NULL ;int len; -if (index >0 && (buf =kmalloc (256 ,GFP_KERNEL )) !=NULL ) { +if (index >0 && (buf =kmalloc_node (256 ,GFP_KERNEL ,dev_to_node (&udev->dev))) !=NULL ) {if ((len =usb_string (udev, index, buf,256 )) >0 ) { -if ((smallbuf =kmalloc (++len,GFP_KERNEL )) ==NULL ) +if ((smallbuf =kmalloc_node (++len,GFP_KERNEL ,dev_to_node (&udev->dev))) ==NULL )return buf;memcpy (smallbuf, buf, len); }
@@ -864,7 +864,7 @@ int usb_get_device_descriptor(struct usb_device *dev, unsigned int size)if (size >sizeof (*desc))return -EINVAL ; - desc =kmalloc (sizeof (*desc),GFP_NOIO ); + desc =kmalloc_node (sizeof (*desc),GFP_NOIO ,dev_to_node (&dev->dev));if (!desc)return -ENOMEM ;
@@ -900,7 +900,7 @@ int usb_get_device_descriptor(struct usb_device *dev, unsigned int size)int usb_get_status (struct usb_device *dev,int type,int target,void *data) {int ret; -u16 *status =kmalloc (sizeof (*status),GFP_KERNEL ); +u16 *status =kmalloc_node (sizeof (*status),GFP_KERNEL ,dev_to_node (&dev->dev));if (!status)return -ENOMEM ;
@@ -1630,7 +1630,7 @@ int usb_driver_set_configuration(struct usb_device *udev, int config) {struct set_config_request *req; - req =kmalloc (sizeof (*req),GFP_KERNEL ); + req =kmalloc_node (sizeof (*req),GFP_KERNEL ,dev_to_node (&udev->dev));if (!req)return -ENOMEM ; req->udev = udev;
drivers/usb/storage/usb.c +1 -1
@@ -470,7 +470,7 @@ static int associate_dev(struct us_data *us, struct usb_interface *intf)return -ENOMEM ; } - us->sensebuf =kmalloc (US_SENSE_SIZE ,GFP_KERNEL ); + us->sensebuf =kmalloc_node (US_SENSE_SIZE ,GFP_KERNEL ,dev_to_node (&us->pusb_dev->dev));if (!us->sensebuf) {US_DEBUGP ("Sense buffer allocation failed\n" );return -ENOMEM ;
drivers/hid/usbhid/hid-core.c +1 -1
@@ -759,7 +759,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)return NULL ; } -if (!(rdesc =kmalloc (rsize,GFP_KERNEL ))) { +if (!(rdesc =kmalloc_node (rsize,GFP_KERNEL ,dev_to_node (&dev->dev)))) {dbg ("couldn't allocate rdesc memory" );return NULL ; }
drivers/hid/usbhid/hiddev.c +1 -1
@@ -476,7 +476,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmdif (get_user (idx, (int __user *)arg))return -EFAULT ; -if ((buf =kmalloc (HID_STRING_SIZE ,GFP_KERNEL )) ==NULL ) +if ((buf =kmalloc_node (HID_STRING_SIZE ,GFP_KERNEL ,dev_to_node (&dev->dev))) ==NULL )return -ENOMEM ;if ((len =usb_string (dev, idx, buf,HID_STRING_SIZE -1 )) <0 ) {
Re: [PATCH 3/4] usb: allocated usb releated dma buffer with kmalloc_node
Quoted 5 lines · Yinghai Lu
[PATCH 3/4] usb: allocated usb releated dma buffer with
kmalloc_nodeFor amd64 based two way system. USB always on node0. but dma buffer for urb allocated via kmalloc always get ram on node1. So change to
kmalloc_nodeto getdma_bufferon corresponding node
Are all of these changes really necessary? You are doing this for some allocations that take a _long_ time when sending to the device due to the speed of the device.
I could possibly see this making a difference on some drivers, but for the core, and for the basic USB structures, I can't imagine it is really worth it.
Or do you have numbers showing the differences here?
Patch included fully below for the benifit of the usb list, which you should have cc:ed...
thanks,
greg k-h
Quoted 224 lines
Signed-off-by Yinghai Lu <[email protected]>drivers/usb/core/config.c +2
-2@@ -504,7 +504,7 @@ int usb_get_configuration(struct usb_device *dev)if (!dev->rawdescriptors) goto err2; - buffer =kmalloc (USB_DT_CONFIG_SIZE ,GFP_KERNEL ); + buffer =kmalloc_node (USB_DT_CONFIG_SIZE ,GFP_KERNEL ,dev_to_node (&dev->dev));if (!buffer) goto err2; desc = (struct usb_config_descriptor *)buffer;@@ -531,7 +531,7 @@ int usb_get_configuration(struct usb_device *dev) USB_DT_CONFIG_SIZE);/* Now that we know the length, get the whole thing */ - bigbuffer =kmalloc (length,GFP_KERNEL ); + bigbuffer =kmalloc_node (length,GFP_KERNEL ,dev_to_node (&dev->dev));if (!bigbuffer) { result = -ENOMEM ; goto err;drivers/usb/core/devio.c +4
-4@@ -718,7 +718,7 @@ static int proc_bulk(struct dev_state *ps, void __user *arg) len1 = bulk.len;if (len1 >MAX_USBFS_BUFFER_SIZE )return -EINVAL ; -if (!(tbuf =kmalloc (len1,GFP_KERNEL ))) +if (!(tbuf =kmalloc_node (len1,GFP_KERNEL ,dev_to_node (&dev->dev))))return -ENOMEM ; tmo = bulk.timeout;if (bulk.ep &0x80 ) {@@ -938,7 +938,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,/* min 8 byte setup packet, max 8 byte setup plus an arbitrary data stage */ if (uurb->buffer_length <8 || uurb->buffer_length > (8 +MAX_USBFS_BUFFER_SIZE ))return -EINVAL ; -if (!(dr =kmalloc (sizeof (struct usb_ctrlrequest ),GFP_KERNEL ))) +if (!(dr =kmalloc_node (sizeof (struct usb_ctrlrequest ),GFP_KERNEL ,dev_to_node (&ps->dev->dev))))return -ENOMEM ;if (copy_from_user (dr, uurb->buffer,8 )) {kfree (dr);@@ -990,7 +990,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, != USB_ENDPOINT_XFER_ISOC)return -EINVAL ; isofrmlen =sizeof (struct usbdevfs_iso_packet_desc ) * uurb->number_of_packets; -if (!(isopkt =kmalloc (isofrmlen,GFP_KERNEL ))) +if (!(isopkt =kmalloc_node (isofrmlen,GFP_KERNEL ,dev_to_node (&ps->dev->dev))))return -ENOMEM ;if (copy_from_user (isopkt, iso_frame_desc, isofrmlen)) {kfree (isopkt);@@ -1032,7 +1032,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,kfree (dr);return -ENOMEM ; } -if (!(as->urb->transfer_buffer =kmalloc (uurb->buffer_length,GFP_KERNEL ))) { +if (!(as->urb->transfer_buffer =kmalloc_node (uurb->buffer_length,GFP_KERNEL ,dev_to_node (&ps->dev->dev)))) {kfree (isopkt);kfree (dr);free_async (as);drivers/usb/core/hcd.c +0
-0drivers/usb/core/hub.c +6
-6@@ -449,7 +449,7 @@ void usb_hub_tt_clear_buffer (struct usb_device *udev, int pipe)* since each TT has "at least two" buffers that can need it (and * there can be many TTs per hub). even if they're uncommon. */ -if ((clear =kmalloc (sizeof *clear,GFP_ATOMIC )) ==NULL ) { +if ((clear =kmalloc_node (sizeof *clear,GFP_ATOMIC ,dev_to_node (&udev->dev))) ==NULL ) {dev_err (&udev->dev,"can't save CLEAR_TT_BUFFER state\n" );/* FIXME recover somehow ... RESET_TT? */ return ;@@ -611,7 +611,7 @@ static int hub_configure(struct usb_hub *hub, goto fail; } - hub->status =kmalloc (sizeof (*hub->status),GFP_KERNEL ); + hub->status =kmalloc_node (sizeof (*hub->status),GFP_KERNEL ,dev_to_node (&hdev->dev));if (!hub->status) { message ="can't kmalloc hub status buffer" ; ret = -ENOMEM ;@@ -619,7 +619,7 @@ static int hub_configure(struct usb_hub *hub, }mutex_init (&hub->status_mutex); - hub->descriptor =kmalloc (sizeof (*hub->descriptor),GFP_KERNEL ); + hub->descriptor =kmalloc_node (sizeof (*hub->descriptor),GFP_KERNEL ,dev_to_node (&hdev->dev));if (!hub->descriptor) { message ="can't kmalloc hub descriptor" ; ret = -ENOMEM ;@@ -2213,7 +2213,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,int r =0 ;#define GET_DESCRIPTOR_BUFSIZE 64 - buf =kmalloc (GET_DESCRIPTOR_BUFSIZE ,GFP_NOIO ); + buf =kmalloc_node (GET_DESCRIPTOR_BUFSIZE ,GFP_NOIO ,dev_to_node (&udev->dev));if (!buf) { retval = -ENOMEM ;continue ;@@ -2343,7 +2343,7 @@ check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1)struct usb_qualifier_descriptor *qual;int status; - qual =kmalloc (sizeof *qual,GFP_KERNEL ); + qual =kmalloc_node (sizeof *qual,GFP_KERNEL ,dev_to_node (&udev->dev));if (qual ==NULL )return ;@@ -2894,7 +2894,7 @@ static int config_descriptors_changed(struct usb_device *udev)if (len <le16_to_cpu (udev->config[index].desc.wTotalLength)) len =le16_to_cpu (udev->config[index].desc.wTotalLength); } - buf =kmalloc (len,GFP_KERNEL ); + buf =kmalloc_node (len,GFP_KERNEL ,dev_to_node (&udev->dev));if (buf ==NULL ) {dev_err (&udev->dev,"no mem to re-read configs after reset\n" );/* assume the worst */ drivers/usb/core/message.c +7
-7@@ -120,7 +120,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,int usb_control_msg (struct usb_device *dev,unsigned int pipe,__u8 request,__u8 requesttype,__u16 value,__u16 index,void *data,__u16 size,int timeout) { -struct usb_ctrlrequest *dr =kmalloc (sizeof (struct usb_ctrlrequest ),GFP_NOIO ); +struct usb_ctrlrequest *dr =kmalloc_node (sizeof (struct usb_ctrlrequest ),GFP_NOIO ,dev_to_node (&dev->dev));int ret;if (!dr)@@ -765,7 +765,7 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)if (size <=0 || !buf || !index)return -EINVAL ; buf[0 ] =0 ; - tbuf =kmalloc (256 ,GFP_KERNEL ); + tbuf =kmalloc_node (256 ,GFP_KERNEL ,dev_to_node (&dev->dev));if (!tbuf)return -ENOMEM ;@@ -828,9 +828,9 @@ char *usb_cache_string(struct usb_device *udev, int index)char *smallbuf =NULL ;int len; -if (index >0 && (buf =kmalloc (256 ,GFP_KERNEL )) !=NULL ) { +if (index >0 && (buf =kmalloc_node (256 ,GFP_KERNEL ,dev_to_node (&udev->dev))) !=NULL ) {if ((len =usb_string (udev, index, buf,256 )) >0 ) { -if ((smallbuf =kmalloc (++len,GFP_KERNEL )) ==NULL ) +if ((smallbuf =kmalloc_node (++len,GFP_KERNEL ,dev_to_node (&udev->dev))) ==NULL )return buf;memcpy (smallbuf, buf, len); }@@ -864,7 +864,7 @@ int usb_get_device_descriptor(struct usb_device *dev, unsigned int size)if (size >sizeof (*desc))return -EINVAL ; - desc =kmalloc (sizeof (*desc),GFP_NOIO ); + desc =kmalloc_node (sizeof (*desc),GFP_NOIO ,dev_to_node (&dev->dev));if (!desc)return -ENOMEM ;@@ -900,7 +900,7 @@ int usb_get_device_descriptor(struct usb_device *dev, unsigned int size)int usb_get_status (struct usb_device *dev,int type,int target,void *data) {int ret; -u16 *status =kmalloc (sizeof (*status),GFP_KERNEL ); +u16 *status =kmalloc_node (sizeof (*status),GFP_KERNEL ,dev_to_node (&dev->dev));if (!status)return -ENOMEM ;@@ -1630,7 +1630,7 @@ int usb_driver_set_configuration(struct usb_device *udev, int config) {struct set_config_request *req; - req =kmalloc (sizeof (*req),GFP_KERNEL ); + req =kmalloc_node (sizeof (*req),GFP_KERNEL ,dev_to_node (&udev->dev));if (!req)return -ENOMEM ; req->udev = udev;drivers/usb/storage/usb.c +1
-1@@ -470,7 +470,7 @@ static int associate_dev(struct us_data *us, struct usb_interface *intf)return -ENOMEM ; } - us->sensebuf =kmalloc (US_SENSE_SIZE ,GFP_KERNEL ); + us->sensebuf =kmalloc_node (US_SENSE_SIZE ,GFP_KERNEL ,dev_to_node (&us->pusb_dev->dev));if (!us->sensebuf) {US_DEBUGP ("Sense buffer allocation failed\n" );return -ENOMEM ;drivers/hid/usbhid/hid-core.c +1
-1@@ -759,7 +759,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)return NULL ; } -if (!(rdesc =kmalloc (rsize,GFP_KERNEL ))) { +if (!(rdesc =kmalloc_node (rsize,GFP_KERNEL ,dev_to_node (&dev->dev)))) {dbg ("couldn't allocate rdesc memory" );return NULL ; }drivers/hid/usbhid/hiddev.c +1
-1@@ -476,7 +476,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmdif (get_user (idx, (int __user *)arg))return -EFAULT ; -if ((buf =kmalloc (HID_STRING_SIZE ,GFP_KERNEL )) ==NULL ) +if ((buf =kmalloc_node (HID_STRING_SIZE ,GFP_KERNEL ,dev_to_node (&dev->dev))) ==NULL )return -ENOMEM ;if ((len =usb_string (dev, idx, buf,HID_STRING_SIZE -1 )) <0 ) {
Re: [PATCH 3/4] usb: allocated usb releated dma buffer with kmalloc_node
Quoted 11 lines · Greg KH
Quoted 5 lines · Yinghai Lu
[PATCH 3/4] usb: allocated usb releated dma buffer with
kmalloc_nodeFor amd64 based two way system. USB always on node0. but dma buffer for urb allocated via kmalloc always get ram on node1. So change to
kmalloc_nodeto getdma_bufferon corresponding nodeAre all of these changes really necessary? You are doing this for some allocations that take a _long_ time when sending to the device due to the speed of the device.
Quoted 8 lines
I could possibly see this making a difference on some drivers, but for the core, and for the basic USB structures, I can't imagine it is really worth it.
Or do you have numbers showing the differences here?
Patch included fully below for the benifit of the usb list, which you should have cc:ed...
dma buffer could be allocated via alloc_pages_coherent. or kmalloc/dma_map_single.alloc_pages_coherent get the dma_buffer on corresponding node. but kmalloc/dma_map_single always get dma_buffer on last node. or say device is on HT chain node0, it will get dma buffer on node 7 of 8 socket system.
also on two way system with 4G+4G RAM conf. device on node 0 will get dma_buffer above 4G, and if the dma_mask is less 32bit, will need extra iommu mapping.
In my mcp55+io55 system, it show dma_map_single is keepping called by usb input: keyboard/mouse (8/0x40 bytes), and forcedeth. (0x670bytes)
YH
Re: [PATCH 3/4] usb: allocated usb releated dma buffer with kmalloc_node
Quoted 23 lines · Yinghai Lu
Quoted 13 lines · Greg KH
Quoted 3 lines · Yinghai Lu
[PATCH 3/4] usb: allocated usb releated dma buffer with
kmalloc_nodeFor amd64 based two way system. USB always on node0. but dma buffer for
urb
Quoted 1 line
allocated via kmalloc always get ram on node1. So change to
kmalloc_nodeto
Quoted 1 line
get
dma_bufferon corresponding nodeAre all of these changes really necessary? You are doing this for some allocations that take a _long_ time when sending to the device due to the speed of the device.
Quoted 8 lines
I could possibly see this making a difference on some drivers, but for the core, and for the basic USB structures, I can't imagine it is really worth it.
Or do you have numbers showing the differences here?
Patch included fully below for the benifit of the usb list, which you should have cc:ed...
Quoted 11 lines
dma buffer could be allocated via
alloc_pages_coherent. or kmalloc/dma_map_single.
alloc_pages_coherentget thedma_bufferon corresponding node. but kmalloc/dma_map_single always getdma_bufferon last node. or say device is on HT chain node0, it will get dma buffer on node 7 of 8 socket system.
also on two way system with 4G+4G RAM conf. device on node 0 will getdma_bufferabove 4G, and if thedma_maskis less 32bit, will need extra iommu mapping.
In my mcp55+io55 system, it showdma_map_singleis keepping called by usb input: keyboard/mouse (8/0x40 bytes), and forcedeth. (0x670bytes)
Ok, so two drivers might need this, but not the whole usb core, right?
And even if you do have another usb mapping, is that a real problem? USB keyboards and mice are very slow.
thanks,
greg k-h
Re: [linux-usb-devel] [PATCH 3/4] usb: allocated usb releated dma buffer with kmalloc_node
Am Dienstag, 3. Juli 2007 schrieb Greg KH:
Quoted 36 lines · Yinghai Lu
Quoted 23 lines · Greg KH
Quoted 13 lines · Yinghai Lu
Quoted 3 lines
[PATCH 3/4] usb: allocated usb releated dma buffer with
kmalloc_nodeFor amd64 based two way system. USB always on node0. but dma buffer for
urb
Quoted 1 line
allocated via kmalloc always get ram on node1. So change to
kmalloc_nodeto
Quoted 1 line
get
dma_bufferon corresponding nodeAre all of these changes really necessary? You are doing this for some allocations that take a _long_ time when sending to the device due to the speed of the device.
Quoted 8 lines
I could possibly see this making a difference on some drivers, but for the core, and for the basic USB structures, I can't imagine it is really worth it.
Or do you have numbers showing the differences here?
Patch included fully below for the benifit of the usb list, which you should have cc:ed...
Quoted 11 lines
dma buffer could be allocated via
alloc_pages_coherent. or kmalloc/dma_map_single.
alloc_pages_coherentget thedma_bufferon corresponding node. but kmalloc/dma_map_single always getdma_bufferon last node. or say device is on HT chain node0, it will get dma buffer on node 7 of 8 socket system.
also on two way system with 4G+4G RAM conf. device on node 0 will getdma_bufferabove 4G, and if thedma_maskis less 32bit, will need extra iommu mapping.
In my mcp55+io55 system, it showdma_map_singleis keepping called by usb input: keyboard/mouse (8/0x40 bytes), and forcedeth. (0x670bytes)
Quoted 1 line
Ok, so two drivers might need this, but not the whole usb core, right?
If those two drivers need the extended allocator, why not use it where it is beneficial, even if the benefit is small?
Regards
Oliver
Re: [linux-usb-devel] [PATCH 3/4] usb: allocated usb releated dma buffer with?kmalloc_node
Quoted 37 lines · Oliver Neukum
Am Dienstag, 3. Juli 2007 schrieb Greg KH:
Quoted 36 lines · Yinghai Lu
Quoted 34 lines · Greg KH
Quoted 13 lines · Yinghai Lu
Quoted 3 lines
[PATCH 3/4] usb: allocated usb releated dma buffer with
kmalloc_nodeFor amd64 based two way system. USB always on node0. but dma buffer for
urb
Quoted 1 line
allocated via kmalloc always get ram on node1. So change to
kmalloc_nodeto
Quoted 1 line
get
dma_bufferon corresponding nodeAre all of these changes really necessary? You are doing this for some allocations that take a _long_ time when sending to the device due to the speed of the device.
Quoted 8 lines
I could possibly see this making a difference on some drivers, but for the core, and for the basic USB structures, I can't imagine it is really worth it.
Or do you have numbers showing the differences here?
Patch included fully below for the benifit of the usb list, which you should have cc:ed...
dma buffer could be allocated via
alloc_pages_coherent. or kmalloc/dma_map_single.
alloc_pages_coherentget thedma_bufferon corresponding node. but kmalloc/dma_map_single always getdma_bufferon last node. or say device is on HT chain node0, it will get dma buffer on node 7 of 8 socket system.
also on two way system with 4G+4G RAM conf. device on node 0 will getdma_bufferabove 4G, and if thedma_maskis less 32bit, will need extra iommu mapping.
In my mcp55+io55 system, it showdma_map_singleis keepping called by usb input: keyboard/mouse (8/0x40 bytes), and forcedeth. (0x670bytes)
Quoted 4 lines
Quoted 1 line
Ok, so two drivers might need this, but not the whole usb core, right?
If those two drivers need the extended allocator, why not use it where it is beneficial, even if the benefit is small?
What is the benefit? Speed isn't an issue here, so what is?
thanks,
greg k-h
Re: [linux-usb-devel] [PATCH 3/4] usb: allocated usb releated dma buffer with?kmalloc_node
Am Dienstag, 3. Juli 2007 schrieb Greg KH:
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Ok, so two drivers might need this, but not the whole usb core, right?
If those two drivers need the extended allocator, why not use it where it is beneficial, even if the benefit is small?
What is the benefit? Speed isn't an issue here, so what is?
Speed is always an issue. Every cycle used in the kernel is lost to user space.
Regards
Oliver
Re: [PATCH 3/4] usb: allocated usb releated dma buffer with kmalloc_node
In reply to Greg KHQuoted 5 lines · Greg KH
On Mon, Jul 02, 2007 at 10:33:12PM -0700, Yinghai Lu wrote:
Ok, so two drivers might need this, but not the whole usb core, right?And even if you do have another usb mapping, is that a real problem? USB keyboards and mice are very slow.
Some other USB media may need that too.
if you have one two way system and put all dimm on node1 and use memtest to look at performance. you may agree to reduce the cross node mem access as less as possible.
YH
PATCH 4/4 usb: allocated usb releated dma buffer with kmalloc_node
In reply to Greg KH[PATCH 4/4] usb: allocated usb releated dma buffer with kmalloc_node
For amd64 based two way system. USB always on node0. but dma buffer for urb allocated via kmalloc always get ram on node1. So change to kmalloc_node to get dma_buffer on corresponding node.
drivers/usb/core/config.c +4 -2
@@ -504,7 +504,8 @@ int usb_get_configuration(struct usb_device *dev)if (!dev->rawdescriptors) goto err2; - buffer =kmalloc (USB_DT_CONFIG_SIZE ,GFP_KERNEL ); + buffer =kmalloc_node (USB_DT_CONFIG_SIZE ,GFP_KERNEL , +dev_to_node (&dev->dev));if (!buffer) goto err2; desc = (struct usb_config_descriptor *)buffer;
@@ -531,7 +532,8 @@ int usb_get_configuration(struct usb_device *dev) USB_DT_CONFIG_SIZE);/* Now that we know the length, get the whole thing */ - bigbuffer =kmalloc (length,GFP_KERNEL ); + bigbuffer =kmalloc_node (length,GFP_KERNEL , +dev_to_node (&dev->dev));if (!bigbuffer) { result = -ENOMEM ; goto err;
drivers/usb/core/devio.c +11 -4
@@ -718,7 +718,8 @@ static int proc_bulk(struct dev_state *ps, void __user *arg) len1 = bulk.len;if (len1 >MAX_USBFS_BUFFER_SIZE )return -EINVAL ; -if (!(tbuf =kmalloc (len1,GFP_KERNEL ))) + tbuf =kmalloc_node (len1,GFP_KERNEL ,dev_to_node (&dev->dev)); +if (!tbuf)return -ENOMEM ; tmo = bulk.timeout;if (bulk.ep &0x80 ) {
@@ -938,7 +939,9 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,/* min 8 byte setup packet, max 8 byte setup plus an arbitrary data stage */ if (uurb->buffer_length <8 || uurb->buffer_length > (8 +MAX_USBFS_BUFFER_SIZE ))return -EINVAL ; -if (!(dr =kmalloc (sizeof (struct usb_ctrlrequest ),GFP_KERNEL ))) + dr =kmalloc_node (sizeof (struct usb_ctrlrequest ),GFP_KERNEL , +dev_to_node (&ps->dev->dev)); +if (!dr)return -ENOMEM ;if (copy_from_user (dr, uurb->buffer,8 )) {kfree (dr);
@@ -990,7 +993,9 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, != USB_ENDPOINT_XFER_ISOC)return -EINVAL ; isofrmlen =sizeof (struct usbdevfs_iso_packet_desc ) * uurb->number_of_packets; -if (!(isopkt =kmalloc (isofrmlen,GFP_KERNEL ))) + isopkt =kmalloc_node (isofrmlen,GFP_KERNEL , +dev_to_node (&ps->dev->dev)); +if (!isopkt)return -ENOMEM ;if (copy_from_user (isopkt, iso_frame_desc, isofrmlen)) {kfree (isopkt);
@@ -1032,7 +1037,9 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,kfree (dr);return -ENOMEM ; } -if (!(as->urb->transfer_buffer =kmalloc (uurb->buffer_length,GFP_KERNEL ))) { + as->urb->transfer_buffer =kmalloc_node (uurb->buffer_length, +GFP_KERNEL ,dev_to_node (&ps->dev->dev)); +if (!as->urb->transfer_buffer) {kfree (isopkt);kfree (dr);free_async (as);
drivers/usb/core/hub.c +11 -6
@@ -449,7 +449,9 @@ void usb_hub_tt_clear_buffer (struct usb_device *udev, int pipe)* since each TT has "at least two" buffers that can need it (and * there can be many TTs per hub). even if they're uncommon. */ -if ((clear =kmalloc (sizeof *clear,GFP_ATOMIC )) ==NULL ) { + clear =kmalloc_node (sizeof *clear,GFP_ATOMIC , +dev_to_node (&udev->dev)); +if (clear ==NULL ) {dev_err (&udev->dev,"can't save CLEAR_TT_BUFFER state\n" );/* FIXME recover somehow ... RESET_TT? */ return ;
@@ -611,7 +613,8 @@ static int hub_configure(struct usb_hub *hub, goto fail; } - hub->status =kmalloc (sizeof (*hub->status),GFP_KERNEL ); + hub->status =kmalloc_node (sizeof (*hub->status),GFP_KERNEL , +dev_to_node (&hdev->dev));if (!hub->status) { message ="can't kmalloc hub status buffer" ; ret = -ENOMEM ;
@@ -619,7 +622,8 @@ static int hub_configure(struct usb_hub *hub, }mutex_init (&hub->status_mutex); - hub->descriptor =kmalloc (sizeof (*hub->descriptor),GFP_KERNEL ); + hub->descriptor =kmalloc_node (sizeof (*hub->descriptor),GFP_KERNEL , +dev_to_node (&hdev->dev));if (!hub->descriptor) { message ="can't kmalloc hub descriptor" ; ret = -ENOMEM ;
@@ -2213,7 +2217,8 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,int r =0 ;#define GET_DESCRIPTOR_BUFSIZE 64 - buf =kmalloc (GET_DESCRIPTOR_BUFSIZE ,GFP_NOIO ); + buf =kmalloc_node (GET_DESCRIPTOR_BUFSIZE ,GFP_NOIO , +dev_to_node (&udev->dev));if (!buf) { retval = -ENOMEM ;continue ;
@@ -2343,7 +2348,7 @@ check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1)struct usb_qualifier_descriptor *qual;int status; - qual =kmalloc (sizeof *qual,GFP_KERNEL ); + qual =kmalloc_node (sizeof *qual,GFP_KERNEL ,dev_to_node (&udev->dev));if (qual ==NULL )return ;
@@ -2894,7 +2899,7 @@ static int config_descriptors_changed(struct usb_device *udev)if (len <le16_to_cpu (udev->config[index].desc.wTotalLength)) len =le16_to_cpu (udev->config[index].desc.wTotalLength); } - buf =kmalloc (len,GFP_KERNEL ); + buf =kmalloc_node (len,GFP_KERNEL ,dev_to_node (&udev->dev));if (buf ==NULL ) {dev_err (&udev->dev,"no mem to re-read configs after reset\n" );/* assume the worst */
drivers/usb/core/message.c +21 -12
@@ -120,9 +120,11 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,int usb_control_msg (struct usb_device *dev,unsigned int pipe,__u8 request,__u8 requesttype,__u16 value,__u16 index,void *data,__u16 size,int timeout) { -struct usb_ctrlrequest *dr =kmalloc (sizeof (struct usb_ctrlrequest ),GFP_NOIO ); +struct usb_ctrlrequest *dr;int ret; - + + dr =kmalloc_node (sizeof (struct usb_ctrlrequest ),GFP_NOIO , +dev_to_node (&dev->dev));if (!dr)return -ENOMEM ;
@@ -765,7 +767,7 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)if (size <=0 || !buf || !index)return -EINVAL ; buf[0 ] =0 ; - tbuf =kmalloc (256 ,GFP_KERNEL ); + tbuf =kmalloc_node (256 ,GFP_KERNEL ,dev_to_node (&dev->dev));if (!tbuf)return -ENOMEM ;
@@ -828,13 +830,19 @@ char *usb_cache_string(struct usb_device *udev, int index)char *smallbuf =NULL ;int len; -if (index >0 && (buf =kmalloc (256 ,GFP_KERNEL )) !=NULL ) { -if ((len =usb_string (udev, index, buf,256 )) >0 ) { -if ((smallbuf =kmalloc (++len,GFP_KERNEL )) ==NULL ) -return buf; -memcpy (smallbuf, buf, len); +if (index >0 ) { + buf =kmalloc_node (256 ,GFP_KERNEL ,dev_to_node (&udev->dev)); +if (buf !=NULL ) { + len =usb_string (udev, index, buf,256 ); +if (len >0 ) { + smallbuf =kmalloc_node (++len,GFP_KERNEL , +dev_to_node (&udev->dev)); +if (smallbuf ==NULL ) +return buf; +memcpy (smallbuf, buf, len); + } +kfree (buf); } -kfree (buf); }return smallbuf; }
@@ -864,7 +872,7 @@ int usb_get_device_descriptor(struct usb_device *dev, unsigned int size)if (size >sizeof (*desc))return -EINVAL ; - desc =kmalloc (sizeof (*desc),GFP_NOIO ); + desc =kmalloc_node (sizeof (*desc),GFP_NOIO ,dev_to_node (&dev->dev));if (!desc)return -ENOMEM ;
@@ -900,7 +908,8 @@ int usb_get_device_descriptor(struct usb_device *dev, unsigned int size)int usb_get_status (struct usb_device *dev,int type,int target,void *data) {int ret; -u16 *status =kmalloc (sizeof (*status),GFP_KERNEL ); +u16 *status =kmalloc_node (sizeof (*status),GFP_KERNEL , +dev_to_node (&dev->dev));if (!status)return -ENOMEM ;
@@ -1630,7 +1639,7 @@ int usb_driver_set_configuration(struct usb_device *udev, int config) {struct set_config_request *req; - req =kmalloc (sizeof (*req),GFP_KERNEL ); + req =kmalloc_node (sizeof (*req),GFP_KERNEL ,dev_to_node (&udev->dev));if (!req)return -ENOMEM ; req->udev = udev;
drivers/usb/storage/usb.c +2 -1
@@ -470,7 +470,8 @@ static int associate_dev(struct us_data *us, struct usb_interface *intf)return -ENOMEM ; } - us->sensebuf =kmalloc (US_SENSE_SIZE ,GFP_KERNEL ); + us->sensebuf =kmalloc_node (US_SENSE_SIZE ,GFP_KERNEL , +dev_to_node (&us->pusb_dev->dev));if (!us->sensebuf) {US_DEBUGP ("Sense buffer allocation failed\n" );return -ENOMEM ;
drivers/hid/usbhid/hid-core.c +2 -1
@@ -759,7 +759,8 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)return NULL ; } -if (!(rdesc =kmalloc (rsize,GFP_KERNEL ))) { + rdesc =kmalloc_node (rsize,GFP_KERNEL ,dev_to_node (&dev->dev)); +if (!rdesc) {dbg ("couldn't allocate rdesc memory" );return NULL ; }
drivers/hid/usbhid/hiddev.c +3 -1
@@ -476,7 +476,9 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmdif (get_user (idx, (int __user *)arg))return -EFAULT ; -if ((buf =kmalloc (HID_STRING_SIZE ,GFP_KERNEL )) ==NULL ) + buf =kmalloc_node (HID_STRING_SIZE ,GFP_KERNEL , +dev_to_node (&dev->dev)); +if (buf ==NULL )return -ENOMEM ;if ((len =usb_string (dev, idx, buf,HID_STRING_SIZE -1 )) <0 ) {
PATCH 4/4 net: add usb_alloc_urb_node to use use kmalloc_node
In reply to Yinghai Lu[PATCH 4/4] net: add usb_alloc_urb_node to use use kmalloc_node
For amd64 based two way system. USB always on node0. but urb allocated via kmalloc always get ram on node1. So change to kmalloc_node to get urb on corresponding node
drivers/usb/core/hub.c +1 -1
@@ -818,7 +818,7 @@ static int hub_configure(struct usb_hub *hub,if (maxp >sizeof (*hub->buffer)) maxp =sizeof (*hub->buffer); - hub->urb =usb_alloc_urb (0 ,GFP_KERNEL ); + hub->urb =usb_alloc_urb_node (0 ,GFP_KERNEL ,dev_to_node (&hdev->dev));if (!hub->urb) { message ="couldn't allocate interrupt urb" ; ret = -ENOMEM ;
drivers/usb/core/message.c +3 -3
@@ -77,7 +77,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,int retv;int length; - urb =usb_alloc_urb (0 ,GFP_NOIO ); + urb =usb_alloc_urb_node (0 ,GFP_NOIO ,dev_to_node (&usb_dev->dev));if (!urb)return -ENOMEM ;
@@ -215,7 +215,7 @@ int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,if (!ep || len <0 )return -EINVAL ; - urb =usb_alloc_urb (0 ,GFP_KERNEL ); + urb =usb_alloc_urb_node (0 ,GFP_KERNEL ,dev_to_node (&usb_dev->dev));if (!urb)return -ENOMEM ;
@@ -391,7 +391,7 @@ int usb_sg_init (for (i =0 ; i < io->entries; i++) {unsigned len; - io->urbs [i] =usb_alloc_urb (0 , mem_flags); + io->urbs [i] =usb_alloc_urb_node (0 , mem_flags,dev_to_node (&dev->dev));if (!io->urbs [i]) { io->entries = i; goto nomem;
drivers/usb/core/urb.c +8 -3
@@ -53,13 +53,13 @@ void usb_init_urb(struct urb *urb)* * The driver must call usb_free_urb() when it is finished with the urb. */ -struct urb *usb_alloc_urb (int iso_packets,gfp_t mem_flags) +struct urb *usb_alloc_urb_node (int iso_packets,gfp_t mem_flags,int node) {struct urb *urb; - urb =kmalloc (sizeof (struct urb ) + + urb =kmalloc_node (sizeof (struct urb ) + iso_packets *sizeof (struct usb_iso_packet_descriptor ), - mem_flags); + mem_flags, node);if (!urb) {err ("alloc_urb: kmalloc failed" );return NULL ;
@@ -67,6 +67,10 @@ struct urb *usb_alloc_urb(int iso_packets, gfp_t mem_flags)usb_init_urb (urb);return urb; } +struct urb *usb_alloc_urb (int iso_packets,gfp_t mem_flags) +{ +return usb_alloc_urb_node (iso_packets, mem_flags,-1 ); +}/** * usb_free_urb - frees the memory used by a urb when all users of it are finished
@@ -479,6 +483,7 @@ void usb_kill_urb(struct urb *urb) }EXPORT_SYMBOL (usb_init_urb); +EXPORT_SYMBOL (usb_alloc_urb_node);EXPORT_SYMBOL (usb_alloc_urb);EXPORT_SYMBOL (usb_free_urb);EXPORT_SYMBOL (usb_get_urb);
drivers/usb/storage/onetouch.c +1 -1
@@ -157,7 +157,7 @@ int onetouch_connect_input(struct us_data *ss)if (!onetouch->data) goto fail1; - onetouch->irq =usb_alloc_urb (0 ,GFP_KERNEL ); + onetouch->irq =usb_alloc_urb_node (0 ,GFP_KERNEL ,dev_to_node (&udev->dev));if (!onetouch->irq) goto fail2;
drivers/usb/storage/usb.c +1 -1
@@ -781,7 +781,7 @@ static int usb_stor_acquire_resources(struct us_data *us)int p;struct task_struct *th; - us->current_urb =usb_alloc_urb (0 ,GFP_KERNEL ); + us->current_urb =usb_alloc_urb_node (0 ,GFP_KERNEL ,dev_to_node (&us->pusb_dev->dev));if (!us->current_urb) {US_DEBUGP ("URB allocation failed\n" );return -ENOMEM ;
drivers/hid/usbhid/hid-core.c +3 -3
@@ -840,7 +840,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)if (usb_endpoint_dir_in (endpoint)) {if (usbhid->urbin)continue ; -if (!(usbhid->urbin =usb_alloc_urb (0 ,GFP_KERNEL ))) +if (!(usbhid->urbin =usb_alloc_urb_node (0 ,GFP_KERNEL ,dev_to_node (&dev->dev)))) goto fail; pipe =usb_rcvintpipe (dev, endpoint->bEndpointAddress); usb_fill_int_urb(usbhid->urbin, dev, pipe, usbhid->inbuf, insize,
@@ -850,7 +850,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) }else {if (usbhid->urbout)continue ; -if (!(usbhid->urbout =usb_alloc_urb (0 ,GFP_KERNEL ))) +if (!(usbhid->urbout =usb_alloc_urb_node (0 ,GFP_KERNEL ,dev_to_node (&dev->dev)))) goto fail; pipe =usb_sndintpipe (dev, endpoint->bEndpointAddress); usb_fill_int_urb(usbhid->urbout, dev, pipe, usbhid->outbuf, 0,
@@ -910,7 +910,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)if (usb_string (dev, dev->descriptor.iSerialNumber, hid->uniq,64 ) <=0 ) hid->uniq[0 ] =0 ; - usbhid->urbctrl =usb_alloc_urb (0 ,GFP_KERNEL ); + usbhid->urbctrl =usb_alloc_urb_node (0 ,GFP_KERNEL ,dev_to_node (&dev->dev));if (!usbhid->urbctrl) goto fail;
drivers/hid/usbhid/usbkbd.c +2 -2
@@ -192,9 +192,9 @@ static void usb_kbd_close(struct input_dev *dev)static int usb_kbd_alloc_mem (struct usb_device *dev,struct usb_kbd *kbd) { -if (!(kbd->irq =usb_alloc_urb (0 ,GFP_KERNEL ))) +if (!(kbd->irq =usb_alloc_urb_node (0 ,GFP_KERNEL ,dev_to_node (&dev->dev))))return -1 ; -if (!(kbd->led =usb_alloc_urb (0 ,GFP_KERNEL ))) +if (!(kbd->led =usb_alloc_urb_node (0 ,GFP_KERNEL ,dev_to_node (&dev->dev))))return -1 ;if (!(kbd->new =usb_buffer_alloc (dev,8 ,GFP_ATOMIC , &kbd->new_dma)))return -1 ;
drivers/hid/usbhid/usbmouse.c +1 -1
@@ -143,7 +143,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_iif (!mouse->data) goto fail1; - mouse->irq =usb_alloc_urb (0 ,GFP_KERNEL ); + mouse->irq =usb_alloc_urb_node (0 ,GFP_KERNEL ,dev_to_node (&dev->dev));if (!mouse->irq) goto fail2;
include/linux/usb.h +1 -0
@@ -1263,6 +1263,7 @@ static inline void usb_fill_int_urb (struct urb *urb, }extern void usb_init_urb (struct urb *urb); +extern struct urb *usb_alloc_urb_node (int iso_packets,gfp_t mem_flags,int node);extern struct urb *usb_alloc_urb (int iso_packets,gfp_t mem_flags);extern void usb_free_urb (struct urb *urb);#define usb_put_urb usb_free_urb
Re: [PATCH 4/4] net: add usb_alloc_urb_node to use use kmalloc_node
Quoted 1 line · Yinghai Lu
[PATCH 4/4] net: add
usb_alloc_urb_nodeto use usekmalloc_node
Um, your subject doesn't match the patch below. You might want to verify it again...
I'll not apply any of these until the subject gets straightened out from the body of the patch, and you can show a real benifit for these changes.
thanks,
greg k-h
Re: [PATCH 4/4] net: add usb_alloc_urb_node to use use kmalloc_node
Quoted 6 lines · Greg KH
Quoted 1 line · Yinghai Lu
[PATCH 4/4] net: add
usb_alloc_urb_nodeto use usekmalloc_nodeUm, your subject doesn't match the patch below. You might want to verify it again...
it should be
[PATCH 4/4] usb: add usb_alloc_urb_node to use use kmalloc_node
YH
Re: [PATCH 4/4] net: add usb_alloc_urb_node to use use kmalloc_node
Quoted 1 line
[PATCH 4/4] usb: add
usb_alloc_urb_nodeto use usekmalloc_node
If you're fixing things up, change "use use" to "use" while you're at it...
Re: [PATCH 4/4] net: add usb_alloc_urb_node to use use kmalloc_node
In reply to Yinghai LuQuoted 11 lines · Yinghai Lu
Quoted 6 lines · Greg KH
Quoted 1 line · Yinghai Lu
[PATCH 4/4] net: add
usb_alloc_urb_nodeto use usekmalloc_nodeUm, your subject doesn't match the patch below. You might want to verify it again...
it should be
[PATCH 4/4] usb: add
usb_alloc_urb_nodeto use usekmalloc_node
On the linux-usb-devel list we are discussing how usb_alloc_urb is being reworked to look totally different, so this change will conflict with that.
Also, any real numbers to justify these changes? I know how slow USB really is and I'd be supprised if this matters.
thanks,
greg k-h
Re: [PATCH 4/4] net: add usb_alloc_urb_node to use use kmalloc_node
Quoted 7 lines · Greg KH
Quoted 1 line · Yinghai Lu
[PATCH 4/4] usb: add
usb_alloc_urb_nodeto use usekmalloc_nodeOn the linux-usb-devel list we are discussing how
usb_alloc_urbis being reworked to look totally different, so this change will conflict with that.
Good.
YH