LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 1/2] x86_64: get mp_bus_to_node as early
@ 2007-06-29 20:26 Yinghai Lu
2007-07-02 22:34 ` [PATCH 1/4] usb: make the usb_device numa_node to get assigned from controller Yinghai Lu
` (3 more replies)
0 siblings, 4 replies; 18+ messages in thread
From: Yinghai Lu @ 2007-06-29 20:26 UTC (permalink / raw)
To: Andi Kleen, Andrew Morton, Greg KH; +Cc: Linux Kernel Mailing List
[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). 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.
Signed-off-by: Yinghai Lu <yinghai.lu@sun.com>
diff --git a/arch/i386/pci/Makefile b/arch/i386/pci/Makefile
index 44650e0..600d0e7 100644
--- a/arch/i386/pci/Makefile
+++ b/arch/i386/pci/Makefile
@@ -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
diff --git a/arch/i386/pci/acpi.c b/arch/i386/pci/acpi.c
index b33aea8..5f8859f 100644
--- a/arch/i386/pci/acpi.c
+++ b/arch/i386/pci/acpi.c
@@ -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;
}
diff --git a/arch/i386/pci/common.c b/arch/i386/pci/common.c
index 3f78d4d..d47f0a0 100644
--- a/arch/i386/pci/common.c
+++ b/arch/i386/pci/common.c
@@ -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;
diff --git a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c
index f2cb942..50df769 100644
--- a/arch/i386/pci/irq.c
+++ b/arch/i386/pci/irq.c
@@ -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;
diff --git a/arch/i386/pci/legacy.c b/arch/i386/pci/legacy.c
index 149a958..72e1b27 100644
--- a/arch/i386/pci/legacy.c
+++ b/arch/i386/pci/legacy.c
@@ -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;
}
}
diff --git a/arch/x86_64/pci/k8-bus.c b/arch/x86_64/pci/k8-bus.c
index 3acf60d..e03b533 100644
--- a/arch/x86_64/pci/k8-bus.c
+++ b/arch/x86_64/pci/k8-bus.c
@@ -1,7 +1,9 @@
#include <linux/init.h>
#include <linux/pci.h>
+#include <asm/pci-direct.h>
#include <asm/mpspec.h>
#include <linux/cpumask.h>
+#include <asm/topology.h>
/*
* This discovers the pcibus <-> node mapping on AMD K8.
@@ -20,60 +22,93 @@
#define SUBORDINATE_LDT_BUS_NUMBER(dword) ((dword >> 16) & 0xFF)
#define PCI_DEVICE_ID_K8HTCONFIG 0x1100
+#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];
+
+ /* Algorithm a bit dumb, but it shouldn't matter here.
+ even there is no ram installed for node0*/
+ if (!node_online(node))
+ node = 0;
+
+ return node;
+}
+
/**
- * fill_mp_bus_to_cpumask()
+ * early_fill_mp_bus_to_node()
+ * called before pcibios_scan_root and pci_scan_bus
* fills the mp_bus_to_cpumask array based according to the LDT Bus Number
* Registers found in the K8 northbridge
*/
__init static int
-fill_mp_bus_to_cpumask(void)
+early_fill_mp_bus_to_node(void)
{
- struct pci_dev *nb_dev = NULL;
int i, j;
+ unsigned slot;
u32 ldtbus, nid;
+ u32 id;
static int lbnr[3] = {
LDT_BUS_NUMBER_REGISTER_0,
LDT_BUS_NUMBER_REGISTER_1,
LDT_BUS_NUMBER_REGISTER_2
};
- while ((nb_dev = pci_get_device(PCI_VENDOR_ID_AMD,
- PCI_DEVICE_ID_K8HTCONFIG, nb_dev))) {
- pci_read_config_dword(nb_dev, NODE_ID_REGISTER, &nid);
+ memset(mp_bus_to_node, 0, BUS_NR);
+
+ if (!early_pci_allowed())
+ return -1;
+
+ for (slot = 0x18; slot < 0x20; slot++) {
+ id = read_pci_config(0, slot, 0, PCI_VENDOR_ID);
+ if (id != (PCI_VENDOR_ID_AMD | (PCI_DEVICE_ID_K8HTCONFIG<<16)))
+ break;
+ nid = read_pci_config(0, slot, 0, NODE_ID_REGISTER);
for (i = 0; i < NR_LDT_BUS_NUMBER_REGISTERS; i++) {
- pci_read_config_dword(nb_dev, lbnr[i], &ldtbus);
+ ldtbus = read_pci_config(0, slot, 0, lbnr[i]);
/*
* if there are no busses hanging off of the current
* ldt link then both the secondary and subordinate
* bus number fields are set to 0.
- *
+ *
* RED-PEN
* This is slightly broken because it assumes
- * HT node IDs == Linux node ids, which is not always
+ * HT node IDs == Linux node ids, which is not always
* true. However it is probably mostly true.
*/
if (!(SECONDARY_LDT_BUS_NUMBER(ldtbus) == 0
&& SUBORDINATE_LDT_BUS_NUMBER(ldtbus) == 0)) {
for (j = SECONDARY_LDT_BUS_NUMBER(ldtbus);
j <= SUBORDINATE_LDT_BUS_NUMBER(ldtbus);
- j++) {
- struct pci_bus *bus;
- long node = NODE_ID(nid);
- /* Algorithm a bit dumb, but
- it shouldn't matter here */
- bus = pci_find_bus(0, j);
- if (!bus)
- continue;
- if (!node_online(node))
- node = 0;
- bus->sysdata = (void *)node;
- }
+ j++) {
+ int node = NODE_ID(nid);
+ mp_bus_to_node[j] = (unsigned char) node;
+ }
}
}
}
+ for (i=0; i<BUS_NR; i++) {
+ int node = mp_bus_to_node[i];
+ if (node)
+ printk(KERN_DEBUG "bus: %02x to node: %02x\n", i, node);
+ }
return 0;
}
-fs_initcall(fill_mp_bus_to_cpumask);
+postcore_initcall(early_fill_mp_bus_to_node);
diff --git a/include/asm-i386/topology.h b/include/asm-i386/topology.h
index 7fc512d..b2f8ca9 100644
--- a/include/asm-i386/topology.h
+++ b/include/asm-i386/topology.h
@@ -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.
diff --git a/include/asm-x86_64/topology.h b/include/asm-x86_64/topology.h
index 4fd6fb2..3d820d5 100644
--- a/include/asm-x86_64/topology.h
+++ b/include/asm-x86_64/topology.h
@@ -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
diff --git a/arch/i386/pci/mp_bus_to_node.c b/arch/i386/pci/mp_bus_to_node.c
new file mode 100644
index 0000000..bf4e2e9
--- /dev/null
+++ b/arch/i386/pci/mp_bus_to_node.c
@@ -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;
+}
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 1/4] usb: make the usb_device numa_node to get assigned from controller
2007-06-29 20:26 [PATCH 1/2] x86_64: get mp_bus_to_node as early Yinghai Lu
@ 2007-07-02 22:34 ` Yinghai Lu
2007-07-02 22:34 ` [PATCH 2/4] dma: make dma pool to use kmalloc_node Yinghai Lu
` (2 subsequent siblings)
3 siblings, 0 replies; 18+ messages in thread
From: Yinghai Lu @ 2007-07-02 22:34 UTC (permalink / raw)
To: Andi Kleen, Andrew Morton, Greg KH; +Cc: Linux Kernel Mailing List
[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
Signed-off-by: Yinghai Lu <yinghai.lu@sun.com>
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 4a6299b..c611b3c 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -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);
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 2/4] dma: make dma pool to use kmalloc_node
2007-06-29 20:26 [PATCH 1/2] x86_64: get mp_bus_to_node as early Yinghai Lu
2007-07-02 22:34 ` [PATCH 1/4] usb: make the usb_device numa_node to get assigned from controller Yinghai Lu
@ 2007-07-02 22:34 ` Yinghai Lu
2007-07-02 22:36 ` [PATCH 3/4] usb: allocated usb releated dma buffer with kmalloc_node Yinghai Lu
2007-07-02 22:37 ` [PATCH 4/4] net: add usb_alloc_urb_node to use use kmalloc_node Yinghai Lu
3 siblings, 0 replies; 18+ messages in thread
From: Yinghai Lu @ 2007-07-02 22:34 UTC (permalink / raw)
To: Andi Kleen, Andrew Morton, Greg KH; +Cc: Linux Kernel Mailing List
[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
Signed-off-by: Yinghai Lu <yinghai.lu@sun.com>
diff --git a/drivers/base/dmapool.c b/drivers/base/dmapool.c
index 91970e9..7647abf 100644
--- a/drivers/base/dmapool.c
+++ b/drivers/base/dmapool.c
@@ -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);
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 3/4] usb: allocated usb releated dma buffer with kmalloc_node
2007-06-29 20:26 [PATCH 1/2] x86_64: get mp_bus_to_node as early Yinghai Lu
2007-07-02 22:34 ` [PATCH 1/4] usb: make the usb_device numa_node to get assigned from controller Yinghai Lu
2007-07-02 22:34 ` [PATCH 2/4] dma: make dma pool to use kmalloc_node Yinghai Lu
@ 2007-07-02 22:36 ` Yinghai Lu
2007-07-03 5:11 ` Greg KH
2007-07-02 22:37 ` [PATCH 4/4] net: add usb_alloc_urb_node to use use kmalloc_node Yinghai Lu
3 siblings, 1 reply; 18+ messages in thread
From: Yinghai Lu @ 2007-07-02 22:36 UTC (permalink / raw)
To: Andi Kleen, Andrew Morton, Greg KH; +Cc: Linux Kernel Mailing List
[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
Signed-off-by: Yinghai Lu <yinghai.lu@sun.com>
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index dd34823..0454f29 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -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;
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 927a181..60cefbb 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -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);
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 24f10a1..3e63161 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -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 */
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index f9fed34..1f299e0 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -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;
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 8e898e3..007aaf9 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -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;
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index d91b9da..3d25ae1 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -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;
}
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 488d61b..74e67bb 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -476,7 +476,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
if (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) {
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 4/4] net: add usb_alloc_urb_node to use use kmalloc_node
2007-06-29 20:26 [PATCH 1/2] x86_64: get mp_bus_to_node as early Yinghai Lu
` (2 preceding siblings ...)
2007-07-02 22:36 ` [PATCH 3/4] usb: allocated usb releated dma buffer with kmalloc_node Yinghai Lu
@ 2007-07-02 22:37 ` Yinghai Lu
2007-07-03 5:13 ` Greg KH
3 siblings, 1 reply; 18+ messages in thread
From: Yinghai Lu @ 2007-07-02 22:37 UTC (permalink / raw)
To: Andi Kleen, Andrew Morton, Greg KH; +Cc: Linux Kernel Mailing List
[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
Signed-off-by: Yinghai Lu <yinghai.lu@sun.com>
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 24f10a1..ae21c69 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -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;
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index f9fed34..c432b0e 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -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;
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 94ea972..8e11ef1 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -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);
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c
index d353693..938395d 100644
--- a/drivers/usb/storage/onetouch.c
+++ b/drivers/usb/storage/onetouch.c
@@ -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;
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 8e898e3..36cc5ef 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -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;
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index d91b9da..f1f460b 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -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;
diff --git a/drivers/hid/usbhid/usbkbd.c b/drivers/hid/usbhid/usbkbd.c
index 1309787..aafc530 100644
--- a/drivers/hid/usbhid/usbkbd.c
+++ b/drivers/hid/usbhid/usbkbd.c
@@ -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;
diff --git a/drivers/hid/usbhid/usbmouse.c b/drivers/hid/usbhid/usbmouse.c
index 5345c73..d12a3dd 100644
--- a/drivers/hid/usbhid/usbmouse.c
+++ b/drivers/hid/usbhid/usbmouse.c
@@ -143,7 +143,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i
if (!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;
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 94bd38a..a0b63ef 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -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
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 3/4] usb: allocated usb releated dma buffer with kmalloc_node
2007-07-02 22:36 ` [PATCH 3/4] usb: allocated usb releated dma buffer with kmalloc_node Yinghai Lu
@ 2007-07-03 5:11 ` Greg KH
2007-07-03 5:33 ` Yinghai Lu
2007-07-04 0:35 ` [PATCH 4/4] " Yinghai Lu
0 siblings, 2 replies; 18+ messages in thread
From: Greg KH @ 2007-07-03 5:11 UTC (permalink / raw)
To: Yinghai Lu, linux-usb-devel
Cc: Andi Kleen, Andrew Morton, Linux Kernel Mailing List
On Mon, Jul 02, 2007 at 03:36:37PM -0700, Yinghai Lu wrote:
> [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
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
>
> Signed-off-by: Yinghai Lu <yinghai.lu@sun.com>
>
> diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
> index dd34823..0454f29 100644
> --- a/drivers/usb/core/config.c
> +++ b/drivers/usb/core/config.c
> @@ -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;
> diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
> index 927a181..60cefbb 100644
> --- a/drivers/usb/core/devio.c
> +++ b/drivers/usb/core/devio.c
> @@ -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);
> diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index 24f10a1..3e63161 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -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 */
> diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
> index f9fed34..1f299e0 100644
> --- a/drivers/usb/core/message.c
> +++ b/drivers/usb/core/message.c
> @@ -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;
> diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
> index 8e898e3..007aaf9 100644
> --- a/drivers/usb/storage/usb.c
> +++ b/drivers/usb/storage/usb.c
> @@ -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;
> diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
> index d91b9da..3d25ae1 100644
> --- a/drivers/hid/usbhid/hid-core.c
> +++ b/drivers/hid/usbhid/hid-core.c
> @@ -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;
> }
> diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
> index 488d61b..74e67bb 100644
> --- a/drivers/hid/usbhid/hiddev.c
> +++ b/drivers/hid/usbhid/hiddev.c
> @@ -476,7 +476,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
> if (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) {
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 4/4] net: add usb_alloc_urb_node to use use kmalloc_node
2007-07-02 22:37 ` [PATCH 4/4] net: add usb_alloc_urb_node to use use kmalloc_node Yinghai Lu
@ 2007-07-03 5:13 ` Greg KH
2007-07-03 5:17 ` Yinghai Lu
0 siblings, 1 reply; 18+ messages in thread
From: Greg KH @ 2007-07-03 5:13 UTC (permalink / raw)
To: Yinghai Lu, linux-usb-devel
Cc: Andi Kleen, Andrew Morton, Linux Kernel Mailing List
On Mon, Jul 02, 2007 at 03:37:13PM -0700, Yinghai Lu wrote:
> [PATCH 4/4] net: add usb_alloc_urb_node to use use kmalloc_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
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 4/4] net: add usb_alloc_urb_node to use use kmalloc_node
2007-07-03 5:13 ` Greg KH
@ 2007-07-03 5:17 ` Yinghai Lu
2007-07-03 5:22 ` Roland Dreier
2007-07-03 5:59 ` Greg KH
0 siblings, 2 replies; 18+ messages in thread
From: Yinghai Lu @ 2007-07-03 5:17 UTC (permalink / raw)
To: Greg KH
Cc: linux-usb-devel, Andi Kleen, Andrew Morton, Linux Kernel Mailing List
On 7/2/07, Greg KH <greg@kroah.com> wrote:
> On Mon, Jul 02, 2007 at 03:37:13PM -0700, Yinghai Lu wrote:
> > [PATCH 4/4] net: add usb_alloc_urb_node to use use kmalloc_node
>
> Um, 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
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 4/4] net: add usb_alloc_urb_node to use use kmalloc_node
2007-07-03 5:17 ` Yinghai Lu
@ 2007-07-03 5:22 ` Roland Dreier
2007-07-03 5:59 ` Greg KH
1 sibling, 0 replies; 18+ messages in thread
From: Roland Dreier @ 2007-07-03 5:22 UTC (permalink / raw)
To: Yinghai Lu
Cc: Greg KH, linux-usb-devel, Andi Kleen, Andrew Morton,
Linux Kernel Mailing List
> [PATCH 4/4] usb: add usb_alloc_urb_node to use use kmalloc_node
If you're fixing things up, change "use use" to "use" while you're at it...
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 3/4] usb: allocated usb releated dma buffer with kmalloc_node
2007-07-03 5:11 ` Greg KH
@ 2007-07-03 5:33 ` Yinghai Lu
2007-07-03 6:01 ` Greg KH
2007-07-04 0:35 ` [PATCH 4/4] " Yinghai Lu
1 sibling, 1 reply; 18+ messages in thread
From: Yinghai Lu @ 2007-07-03 5:33 UTC (permalink / raw)
To: Greg KH
Cc: linux-usb-devel, Andi Kleen, Andrew Morton, Linux Kernel Mailing List
On 7/2/07, Greg KH <greg@kroah.com> wrote:
> On Mon, Jul 02, 2007 at 03:36:37PM -0700, Yinghai Lu wrote:
> > [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
>
> 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...
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
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 4/4] net: add usb_alloc_urb_node to use use kmalloc_node
2007-07-03 5:17 ` Yinghai Lu
2007-07-03 5:22 ` Roland Dreier
@ 2007-07-03 5:59 ` Greg KH
2007-07-04 6:12 ` Yinghai Lu
1 sibling, 1 reply; 18+ messages in thread
From: Greg KH @ 2007-07-03 5:59 UTC (permalink / raw)
To: Yinghai Lu
Cc: linux-usb-devel, Andi Kleen, Andrew Morton, Linux Kernel Mailing List
On Mon, Jul 02, 2007 at 10:17:56PM -0700, Yinghai Lu wrote:
> On 7/2/07, Greg KH <greg@kroah.com> wrote:
> > On Mon, Jul 02, 2007 at 03:37:13PM -0700, Yinghai Lu wrote:
> > > [PATCH 4/4] net: add usb_alloc_urb_node to use use kmalloc_node
> >
> > Um, 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
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
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 3/4] usb: allocated usb releated dma buffer with kmalloc_node
2007-07-03 5:33 ` Yinghai Lu
@ 2007-07-03 6:01 ` Greg KH
2007-07-03 6:23 ` [linux-usb-devel] " Oliver Neukum
2007-07-04 6:08 ` [PATCH 3/4] usb: allocated usb releated dma buffer with kmalloc_node Yinghai Lu
0 siblings, 2 replies; 18+ messages in thread
From: Greg KH @ 2007-07-03 6:01 UTC (permalink / raw)
To: Yinghai Lu
Cc: linux-usb-devel, Andi Kleen, Andrew Morton, Linux Kernel Mailing List
On Mon, Jul 02, 2007 at 10:33:12PM -0700, Yinghai Lu wrote:
> On 7/2/07, Greg KH <greg@kroah.com> wrote:
> > On Mon, Jul 02, 2007 at 03:36:37PM -0700, Yinghai Lu wrote:
> > > [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
> >
> > 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...
>
> 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)
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
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [linux-usb-devel] [PATCH 3/4] usb: allocated usb releated dma buffer with kmalloc_node
2007-07-03 6:01 ` Greg KH
@ 2007-07-03 6:23 ` Oliver Neukum
2007-07-03 7:03 ` [linux-usb-devel] [PATCH 3/4] usb: allocated usb releated dma buffer with?kmalloc_node Greg KH
2007-07-04 6:08 ` [PATCH 3/4] usb: allocated usb releated dma buffer with kmalloc_node Yinghai Lu
1 sibling, 1 reply; 18+ messages in thread
From: Oliver Neukum @ 2007-07-03 6:23 UTC (permalink / raw)
To: linux-usb-devel
Cc: Greg KH, Yinghai Lu, Linux Kernel Mailing List, Andrew Morton,
Andi Kleen
Am Dienstag, 3. Juli 2007 schrieb Greg KH:
> On Mon, Jul 02, 2007 at 10:33:12PM -0700, Yinghai Lu wrote:
> > On 7/2/07, Greg KH <greg@kroah.com> wrote:
> > > On Mon, Jul 02, 2007 at 03:36:37PM -0700, Yinghai Lu wrote:
> > > > [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
> > >
> > > 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...
> >
> > 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)
>
> 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
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [linux-usb-devel] [PATCH 3/4] usb: allocated usb releated dma buffer with?kmalloc_node
2007-07-03 6:23 ` [linux-usb-devel] " Oliver Neukum
@ 2007-07-03 7:03 ` Greg KH
2007-07-03 7:12 ` Oliver Neukum
0 siblings, 1 reply; 18+ messages in thread
From: Greg KH @ 2007-07-03 7:03 UTC (permalink / raw)
To: Oliver Neukum
Cc: linux-usb-devel, Yinghai Lu, Linux Kernel Mailing List,
Andrew Morton, Andi Kleen
On Tue, Jul 03, 2007 at 08:23:07AM +0200, Oliver Neukum wrote:
> Am Dienstag, 3. Juli 2007 schrieb Greg KH:
> > On Mon, Jul 02, 2007 at 10:33:12PM -0700, Yinghai Lu wrote:
> > > On 7/2/07, Greg KH <greg@kroah.com> wrote:
> > > > On Mon, Jul 02, 2007 at 03:36:37PM -0700, Yinghai Lu wrote:
> > > > > [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
> > > >
> > > > 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...
> > >
> > > 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)
> >
> > 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
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [linux-usb-devel] [PATCH 3/4] usb: allocated usb releated dma buffer with?kmalloc_node
2007-07-03 7:03 ` [linux-usb-devel] [PATCH 3/4] usb: allocated usb releated dma buffer with?kmalloc_node Greg KH
@ 2007-07-03 7:12 ` Oliver Neukum
0 siblings, 0 replies; 18+ messages in thread
From: Oliver Neukum @ 2007-07-03 7:12 UTC (permalink / raw)
To: Greg KH
Cc: linux-usb-devel, Yinghai Lu, Linux Kernel Mailing List,
Andrew Morton, Andi Kleen
Am Dienstag, 3. Juli 2007 schrieb Greg KH:
> > > 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
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 4/4] usb: allocated usb releated dma buffer with kmalloc_node
2007-07-03 5:11 ` Greg KH
2007-07-03 5:33 ` Yinghai Lu
@ 2007-07-04 0:35 ` Yinghai Lu
1 sibling, 0 replies; 18+ messages in thread
From: Yinghai Lu @ 2007-07-04 0:35 UTC (permalink / raw)
To: Greg KH, Andi Kleen, Andrew Morton
Cc: linux-usb-devel, Linux Kernel Mailing List
[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.
Signed-off-by: Yinghai Lu <yinghai.lu@sun.com>
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index dd34823..604a262 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -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;
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 927a181..99dc0c3 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -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);
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 24f10a1..ec49ce5 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -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 */
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index f9fed34..6687807 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -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;
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 8e898e3..52a37a8 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -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;
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index d91b9da..ffa84d0 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -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;
}
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 488d61b..e2a7165 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -476,7 +476,9 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
if (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) {
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 3/4] usb: allocated usb releated dma buffer with kmalloc_node
2007-07-03 6:01 ` Greg KH
2007-07-03 6:23 ` [linux-usb-devel] " Oliver Neukum
@ 2007-07-04 6:08 ` Yinghai Lu
1 sibling, 0 replies; 18+ messages in thread
From: Yinghai Lu @ 2007-07-04 6:08 UTC (permalink / raw)
To: Greg KH
Cc: linux-usb-devel, Andi Kleen, Andrew Morton, Linux Kernel Mailing List
On 7/2/07, Greg KH <greg@kroah.com> wrote:
> 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
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 4/4] net: add usb_alloc_urb_node to use use kmalloc_node
2007-07-03 5:59 ` Greg KH
@ 2007-07-04 6:12 ` Yinghai Lu
0 siblings, 0 replies; 18+ messages in thread
From: Yinghai Lu @ 2007-07-04 6:12 UTC (permalink / raw)
To: Greg KH
Cc: linux-usb-devel, Andi Kleen, Andrew Morton, Linux Kernel Mailing List
On 7/2/07, Greg KH <greg@kroah.com> wrote:
> On Mon, Jul 02, 2007 at 10:17:56PM -0700, Yinghai Lu wrote:
> > [PATCH 4/4] usb: add usb_alloc_urb_node to use use kmalloc_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.
>
Good.
YH
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2007-07-04 6:12 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-29 20:26 [PATCH 1/2] x86_64: get mp_bus_to_node as early Yinghai Lu
2007-07-02 22:34 ` [PATCH 1/4] usb: make the usb_device numa_node to get assigned from controller Yinghai Lu
2007-07-02 22:34 ` [PATCH 2/4] dma: make dma pool to use kmalloc_node Yinghai Lu
2007-07-02 22:36 ` [PATCH 3/4] usb: allocated usb releated dma buffer with kmalloc_node Yinghai Lu
2007-07-03 5:11 ` Greg KH
2007-07-03 5:33 ` Yinghai Lu
2007-07-03 6:01 ` Greg KH
2007-07-03 6:23 ` [linux-usb-devel] " Oliver Neukum
2007-07-03 7:03 ` [linux-usb-devel] [PATCH 3/4] usb: allocated usb releated dma buffer with?kmalloc_node Greg KH
2007-07-03 7:12 ` Oliver Neukum
2007-07-04 6:08 ` [PATCH 3/4] usb: allocated usb releated dma buffer with kmalloc_node Yinghai Lu
2007-07-04 0:35 ` [PATCH 4/4] " Yinghai Lu
2007-07-02 22:37 ` [PATCH 4/4] net: add usb_alloc_urb_node to use use kmalloc_node Yinghai Lu
2007-07-03 5:13 ` Greg KH
2007-07-03 5:17 ` Yinghai Lu
2007-07-03 5:22 ` Roland Dreier
2007-07-03 5:59 ` Greg KH
2007-07-04 6:12 ` Yinghai Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).