From: Yinghai Lu <Yinghai.Lu@Sun.COM>
To: Andi Kleen <ak@suse.de>,
Andrew Morton <akpm@linux-foundation.org>,
Greg KH <greg@kroah.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH 4/4] net: add usb_alloc_urb_node to use use kmalloc_node
Date: Mon, 02 Jul 2007 15:37:13 -0700 [thread overview]
Message-ID: <200707021537.13840.yinghai.lu@sun.com> (raw)
In-Reply-To: <200706291326.43563.yinghai.lu@sun.com>
[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
next prev parent reply other threads:[~2007-07-02 22:35 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Yinghai Lu [this message]
2007-07-03 5:13 ` [PATCH 4/4] net: add usb_alloc_urb_node to use use kmalloc_node 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200707021537.13840.yinghai.lu@sun.com \
--to=yinghai.lu@sun.com \
--cc=ak@suse.de \
--cc=akpm@linux-foundation.org \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.