Skip to contentSkip to conversation

net: make net and forcedeth to use kmalloc_node

PATCH In review Yinghai Lu 7 participants 14 messages Jun 29, 2007 – Jul 4, 2007

Subsystems (2)
lore
Share & tools
lore

Yinghai Lu

author
#0 lore raw

PATCH 2/2 net: make net and forcedeth to use kmalloc_node

[PATCH 2/2] net: make net and forcedeth to use kmalloc_node

drivers/net/forcedeth.c +16 -7
index 42ba1c0..6d53b52 100644
@@ -1383,7 +1383,7 @@ static int nv_alloc_rx(struct net_device *dev)
 		less_rx = np->last_rx.orig;
 
 	while (np->put_rx.orig != less_rx) {
-		struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz + NV_RX_ALLOC_PAD);
+		struct sk_buff *skb = dev_alloc_skb_node(np->rx_buf_sz + NV_RX_ALLOC_PAD, dev_to_node(&dev->dev));
 		if (skb) {
 			np->put_rx_ctx->skb = skb;
 			np->put_rx_ctx->dma = pci_map_single(np->pci_dev,
@@ -1415,7 +1415,7 @@ static int nv_alloc_rx_optimized(struct net_device *dev)
 		less_rx = np->last_rx.ex;
 
 	while (np->put_rx.ex != less_rx) {
-		struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz + NV_RX_ALLOC_PAD);
+		struct sk_buff *skb = dev_alloc_skb_node(np->rx_buf_sz + NV_RX_ALLOC_PAD, dev_to_node(&dev->dev));
 		if (skb) {
 			np->put_rx_ctx->skb = skb;
 			np->put_rx_ctx->dma = pci_map_single(np->pci_dev,
@@ -3976,8 +3976,8 @@ static int nv_set_ringparam(struct net_device *dev, struct ethtool_ringparam* ri
 					    sizeof(struct ring_desc_ex) * (ring->rx_pending + ring->tx_pending),
 					    &ring_addr);
 	}
-	rx_skbuff = kmalloc(sizeof(struct nv_skb_map) * ring->rx_pending, GFP_KERNEL);
-	tx_skbuff = kmalloc(sizeof(struct nv_skb_map) * ring->tx_pending, GFP_KERNEL);
+	rx_skbuff = kmalloc_node(sizeof(struct nv_skb_map) * ring->rx_pending, GFP_KERNEL, dev_to_node(&dev->dev));
+	tx_skbuff = kmalloc_node(sizeof(struct nv_skb_map) * ring->tx_pending, GFP_KERNEL, dev_to_node(&dev->dev));
 	if (!rxtx_ring || !rx_skbuff || !tx_skbuff) {
 		/* fall back to old rings */
 		if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
@@ -4372,7 +4372,7 @@ static int nv_loopback_test(struct net_device *dev)
 
 	/* setup packet for tx */
 	pkt_len = ETH_DATA_LEN;
-	tx_skb = dev_alloc_skb(pkt_len);
+	tx_skb = dev_alloc_skb_node(pkt_len, dev_to_node(&dev->dev));
 	if (!tx_skb) {
 		printk(KERN_ERR "dev_alloc_skb() failed during loopback test"
 			 " of %s\n", dev->name);
@@ -4976,6 +4976,7 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
 	dev->base_addr = (unsigned long)np->base;
 
 	dev->irq = pci_dev->irq;
+	printk(KERN_INFO "nv_probe: numa_node : %02d\n", dev_to_node(&pci_dev->dev));
 
 	np->rx_ring_size = RX_RING_DEFAULT;
 	np->tx_ring_size = TX_RING_DEFAULT;
@@ -4995,8 +4996,9 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
 			goto out_unmap;
 		np->tx_ring.ex = &np->rx_ring.ex[np->rx_ring_size];
 	}
-	np->rx_skb = kmalloc(sizeof(struct nv_skb_map) * np->rx_ring_size, GFP_KERNEL);
-	np->tx_skb = kmalloc(sizeof(struct nv_skb_map) * np->tx_ring_size, GFP_KERNEL);
+	np->rx_skb = kmalloc_node(sizeof(struct nv_skb_map) * np->rx_ring_size, GFP_KERNEL, dev_to_node(&pci_dev->dev));
+	np->tx_skb = kmalloc_node(sizeof(struct nv_skb_map) * np->tx_ring_size, GFP_KERNEL, dev_to_node(&pci_dev->dev));
+
 	if (!np->rx_skb || !np->tx_skb)
 		goto out_freering;
 	memset(np->rx_skb, 0, sizeof(struct nv_skb_map) * np->rx_ring_size);
@@ -5204,6 +5206,13 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
 	np->autoneg = 1;
 
 	err = register_netdev(dev);
+
+	/*
+	 * store numa_node in dev->dev, so we don't need to use
+	 * netdev_priv(dev)->pci_dev->dev
+	 */
+	set_dev_node(&dev->dev, dev_to_node(&pci_dev->dev));
+
 	if (err) {
 		printk(KERN_INFO "forcedeth: unable to register netdev: %d\n", err);
 		goto out_error;
include/linux/skbuff.h +26 -0
index 6f0b2f7..747588c 100644
@@ -333,11 +333,22 @@ static inline struct sk_buff *alloc_skb(unsigned int size,
 	return __alloc_skb(size, priority, 0, -1);
 }
 
+static inline struct sk_buff *alloc_skb_node(unsigned int size,
+					gfp_t priority, int node)
+{
+	return __alloc_skb(size, priority, 0, node);
+}
+
 static inline struct sk_buff *alloc_skb_fclone(unsigned int size,
 					       gfp_t priority)
 {
 	return __alloc_skb(size, priority, 1, -1);
 }
+static inline struct sk_buff *alloc_skb_fclone_node(unsigned int size,
+					       gfp_t priority, int node)
+{
+	return __alloc_skb(size, priority, 1, node);
+}
 
 extern void	       kfree_skbmem(struct sk_buff *skb);
 extern struct sk_buff *skb_clone(struct sk_buff *skb,
@@ -1282,6 +1293,16 @@ static inline struct sk_buff *__dev_alloc_skb(unsigned int length,
 	return skb;
 }
 
+static inline struct sk_buff *__dev_alloc_skb_node(unsigned int length,
+					      gfp_t gfp_mask, int node)
+{
+	struct sk_buff *skb = alloc_skb_node(length + NET_SKB_PAD, gfp_mask, node);
+	if (likely(skb))
+		skb_reserve(skb, NET_SKB_PAD);
+	return skb;
+}
+
+
 /**
  *	dev_alloc_skb - allocate an skbuff for receiving
  *	@length: length to allocate
@@ -1299,6 +1320,11 @@ static inline struct sk_buff *dev_alloc_skb(unsigned int length)
 	return __dev_alloc_skb(length, GFP_ATOMIC);
 }
 
+static inline struct sk_buff *dev_alloc_skb_node(unsigned int length, int node)
+{
+	return __dev_alloc_skb_node(length, GFP_ATOMIC, node);
+}
+
 extern struct sk_buff *__netdev_alloc_skb(struct net_device *dev,
 		unsigned int length, gfp_t gfp_mask);
 
#1 lore raw
Quoted 1 line · On Fri, 29 Jun 2007 13:30:36 -0700 Yinghai Lu <[email protected]> wrote:

[PATCH 2/2] net: make net and forcedeth to use kmalloc_node

Please copy [email protected] on net patches.

This patch modifies a net driver as well as the networking core. These subsytems have different maintainers who run different development trees. Consequently I must split your patch into two and change their titles and changelogs appropriately.

Please do this for us in future, thanks.

drivers/net/forcedeth.c static int nv_alloc_rx(struct net_device *dev) · line 1386

Quoted 10 lines
drivers/net/forcedeth.c +1 -1
index 42ba1c0..6d53b52 100644
@@ -1383,7 +1383,7 @@ static int nv_alloc_rx(struct net_device *dev)
 		less_rx = np->last_rx.orig;
 
 	while (np->put_rx.orig != less_rx) {
-		struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz + NV_RX_ALLOC_PAD);
+		struct sk_buff *skb = dev_alloc_skb_node(np->rx_buf_sz + NV_RX_ALLOC_PAD, dev_to_node(&dev->dev));

If we're going to do this then it would probably make sense to change dev_alloc_skb_node() so that it takes a `struct net_device *' rather than a bare node-id. That's a call which the net guys will need to make, which is why we cc them on our emails.

drivers/net/forcedeth.c static int nv_alloc_rx_optimized(struct net_device *dev) · line 1418

Quoted 9 lines
drivers/net/forcedeth.c +1 -1
 		if (skb) {
 			np->put_rx_ctx->skb = skb;
 			np->put_rx_ctx->dma = pci_map_single(np->pci_dev,
@@ -1415,7 +1415,7 @@ static int nv_alloc_rx_optimized(struct net_device *dev)
 		less_rx = np->last_rx.ex;
 
 	while (np->put_rx.ex != less_rx) {
-		struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz + NV_RX_ALLOC_PAD);
+		struct sk_buff *skb = dev_alloc_skb_node(np->rx_buf_sz + NV_RX_ALLOC_PAD, dev_to_node(&dev->dev));

It might help to edit code in an 80-col xterm.

Please run scritps/checkpatch.pl across all your diffs. Its suggestions are by no means compulsory, but they do provide things for you to check up and and have a think about, thanks.

I won't apply this (these) patches because I expect API changes.

#2 lore raw
Quoted 22 lines · On Tue, 3 Jul 2007 11:58:40 -0700 Andrew Morton <[email protected]>…
Quoted 1 line · On Fri, 29 Jun 2007 13:30:36 -0700 Yinghai Lu <[email protected]> wrote:

[PATCH 2/2] net: make net and forcedeth to use kmalloc_node

Please copy [email protected] on net patches.

This patch modifies a net driver as well as the networking core. These subsytems have different maintainers who run different development trees. Consequently I must split your patch into two and change their titles and changelogs appropriately.

Please do this for us in future, thanks.

Quoted 7 lines
drivers/net/forcedeth.c +0 -0
index 42ba1c0..6d53b52 100644
@@ -1383,7 +1383,7 @@ static int nv_alloc_rx(struct net_device *dev)
 		less_rx = np->last_rx.orig;
 
Quoted 8 lines

drivers/net/forcedeth.c static int nv_alloc_rx(struct net_device *dev) · line 1386

Quoted 3 lines
drivers/net/forcedeth.c +1 -1
 	while (np->put_rx.orig != less_rx) {
-		struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz + NV_RX_ALLOC_PAD);
+		struct sk_buff *skb = dev_alloc_skb_node(np->rx_buf_sz + NV_RX_ALLOC_PAD, dev_to_node(&dev->dev));

If we're going to do this then it would probably make sense to change dev_alloc_skb_node() so that it takes a `struct net_device *' rather than a bare node-id. That's a call which the net guys will need to make, which is why we cc them on our emails.

The driver should use netdev_alloc_skb. That routine is supposed to be overriden on architecture's that need per node changes.

Quoted 23 lines

drivers/net/forcedeth.c static int nv_alloc_rx_optimized(struct net_device *dev) · line 1418

Quoted 9 lines
drivers/net/forcedeth.c +1 -1
 		if (skb) {
 			np->put_rx_ctx->skb = skb;
 			np->put_rx_ctx->dma = pci_map_single(np->pci_dev,
@@ -1415,7 +1415,7 @@ static int nv_alloc_rx_optimized(struct net_device *dev)
 		less_rx = np->last_rx.ex;
 
 	while (np->put_rx.ex != less_rx) {
-		struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz + NV_RX_ALLOC_PAD);
+		struct sk_buff *skb = dev_alloc_skb_node(np->rx_buf_sz + NV_RX_ALLOC_PAD, dev_to_node(&dev->dev));

It might help to edit code in an 80-col xterm.

Please run scritps/checkpatch.pl across all your diffs. Its suggestions are by no means compulsory, but they do provide things for you to check up and and have a think about, thanks.

I won't apply this (these) patches because I expect API changes.

-
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 1 line
Stephen Hemminger <[email protected]>
author
#3 lore raw
Quoted 31 lines · Stephen Hemminger
Quoted 20 lines · On Tue, 3 Jul 2007 11:58:40 -0700 Andrew Morton <[email protected]>…
Quoted 1 line · On Fri, 29 Jun 2007 13:30:36 -0700 Yinghai Lu <[email protected]> wrote:

[PATCH 2/2] net: make net and forcedeth to use kmalloc_node

Please copy [email protected] on net patches.

This patch modifies a net driver as well as the networking core. These
subsytems have different maintainers who run different development trees. Consequently I must split your patch into two and change their titles and changelogs appropriately.

Please do this for us in future, thanks.

Quoted 7 lines
drivers/net/forcedeth.c +0 -0
index 42ba1c0..6d53b52 100644
@@ -1383,7 +1383,7 @@ static int nv_alloc_rx(struct net_device *dev)
 		less_rx = np->last_rx.orig;
 
Quoted 7 lines

drivers/net/forcedeth.c static int nv_alloc_rx(struct net_device *dev) · line 1386

Quoted 3 lines
drivers/net/forcedeth.c +1 -1
 	while (np->put_rx.orig != less_rx) {
-		struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz + NV_RX_ALLOC_PAD);
+		struct sk_buff *skb = dev_alloc_skb_node(np->rx_buf_sz + NV_RX_ALLOC_PAD, dev_to_node(&dev->dev));

If we're going to do this then it would probably make sense to change dev_alloc_skb_node() so that it takes a `struct net_device *' rather than a bare node-id. That's a call which the net guys will need to make, which is why we cc them on our emails.

Quoted 2 lines

The driver should use netdev_alloc_skb. That routine is supposed to be overriden on architecture's that need per node changes.

do you mean:
use dev_alloc_skb_node for numa arch.
and other non numa will use macro or static inline to dev_alloc_skb

YH

#4 lore raw
Quoted 33 lines · On Tue, 03 Jul 2007 14:28:50 -0700 Yinghai Lu <[email protected]> wrote:
Quoted 32 lines · Stephen Hemminger
Quoted 28 lines · On Tue, 3 Jul 2007 11:58:40 -0700 Andrew Morton <[email protected]>…
Quoted 1 line · On Fri, 29 Jun 2007 13:30:36 -0700 Yinghai Lu <[email protected]> wrote:

[PATCH 2/2] net: make net and forcedeth to use kmalloc_node

Please copy [email protected] on net patches.

This patch modifies a net driver as well as the networking core. These subsytems have different maintainers who run different development trees. Consequently I must split your patch into two and change their titles and changelogs appropriately.

Please do this for us in future, thanks.

drivers/net/forcedeth.c static int nv_alloc_rx(struct net_device *dev) · line 1386

Quoted 10 lines
drivers/net/forcedeth.c +1 -1
index 42ba1c0..6d53b52 100644
@@ -1383,7 +1383,7 @@ static int nv_alloc_rx(struct net_device *dev)
 		less_rx = np->last_rx.orig;
 
 	while (np->put_rx.orig != less_rx) {
-		struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz + NV_RX_ALLOC_PAD);
+		struct sk_buff *skb = dev_alloc_skb_node(np->rx_buf_sz + NV_RX_ALLOC_PAD, dev_to_node(&dev->dev));

If we're going to do this then it would probably make sense to change dev_alloc_skb_node() so that it takes a `struct net_device *' rather than a bare node-id. That's a call which the net guys will need to make, which is why we cc them on our emails.

Quoted 5 lines
Quoted 2 lines

The driver should use netdev_alloc_skb. That routine is supposed to be overriden on architecture's that need per node changes.

do you mean:
use dev_alloc_skb_node for numa arch.

Look at __netdev_alloc_skb() source. It does all the necessary dev_to_node() stuff.

dev_alloc_skb is the old routine and kept around only because not all usage has been converted yet. It should probably be deprecated at some point.

Signature · 1 line
Stephen Hemminger <[email protected]>
author
#5 lore raw

PATCH 2/4 net: use numa_node in net_devcice->dev instead of parent

[PATCH 2/4] net: use numa_node in net_devcice->dev instead of parent

net/core/skbuff.c +1 -1
index 27cfe5f..005cc1c 100644
@@ -217,7 +217,7 @@ nodata:
 struct sk_buff *__netdev_alloc_skb(struct net_device *dev,
 		unsigned int length, gfp_t gfp_mask)
 {
-	int node = dev->dev.parent ? dev_to_node(dev->dev.parent) : -1;
+	int node = dev_to_node(&dev->dev);
 	struct sk_buff *skb;
 
 	skb = __alloc_skb(length + NET_SKB_PAD, gfp_mask, 0, node);
#6 lore raw

Re: [PATCH 2/4] net: use numa_node in net_devcice->dev instead of parent

net/core/skbuff.c nodata: · line 220

Quoted 13 lines · Yinghai Lu

[PATCH 2/4] net: use numa_node in net_devcice->dev instead of parent

net/core/skbuff.c +1 -1
index 27cfe5f..005cc1c 100644
@@ -217,7 +217,7 @@ nodata:
 struct sk_buff *__netdev_alloc_skb(struct net_device *dev,
 		unsigned int length, gfp_t gfp_mask)
 {
-	int node = dev->dev.parent ? dev_to_node(dev->dev.parent) : -1;
+	int node = dev_to_node(&dev->dev);

This looks wrong to me unless the device model has once again changed silently. When I wrote this code &dev->dev was a device allocated as part of the netdevice and the parent is the pci (or whatever) device that has the node information.

maintainer
#7 lore raw

Re: [PATCH 2/4] net: use numa_node in net_devcice->dev instead of parent

From: Christoph Hellwig <[email protected]>
Date: Wed, 4 Jul 2007 09:51:20 +0100

Quoted 19 lines · Yinghai Lu

net/core/skbuff.c nodata: · line 220

Quoted 13 lines

[PATCH 2/4] net: use numa_node in net_devcice->dev instead of parent

net/core/skbuff.c +1 -1
index 27cfe5f..005cc1c 100644
@@ -217,7 +217,7 @@ nodata:
 struct sk_buff *__netdev_alloc_skb(struct net_device *dev,
 		unsigned int length, gfp_t gfp_mask)
 {
-	int node = dev->dev.parent ? dev_to_node(dev->dev.parent) : -1;
+	int node = dev_to_node(&dev->dev);

This looks wrong to me unless the device model has once again changed silently. When I wrote this code &dev->dev was a device allocated as part of the netdevice and the parent is the pci (or whatever) device that has the node information.

Correct, this change is completely bogus.

#8 lore raw

Re: [PATCH 2/4] net: use numa_node in net_devcice->dev instead of parent

Quoted 4 lines · David Miller

From: Christoph Hellwig <[email protected]>
Date: Wed, 4 Jul 2007 09:51:20 +0100

Quoted 1 line · Yinghai Lu

...

Quoted 11 lines
Quoted 10 lines

net/core/skbuff.c nodata: · line 220

Quoted 5 lines

struct sk_buff *__netdev_alloc_skb(struct net_device *dev,

net/core/skbuff.c +1 -1
 		unsigned int length, gfp_t gfp_mask)
 {
-	int node = dev->dev.parent ? dev_to_node(dev->dev.parent) : -1;
+	int node = dev_to_node(&dev->dev);

This looks wrong to me unless the device model has once again changed silently. When I wrote this code &dev->dev was a device allocated as part of the netdevice and the parent is the pci (or whatever) device that has the node information.

Quoted 1 line

Correct, this change is completely bogus.

I've got a question from a network driver writer's perspective: In drivers which sit on top of a midlayer/ multi-protocol infrastructure, should dev->dev.parent be the lowlevel's pci_dev.dev or the midlayer's whatever_abstracted_dev.dev?

(Example: eth1394 network driver sits on top of ieee1394 = FireWire midlayer, this sits on top of ohci1394 = PCI driver for FireWire controllers.)

I guess it should be the lowlevel's pci_dev.dev, unless the midlayer cares to set
set_dev_node(&midlayer_dev.dev, dev_to_node(midlayer_dev.dev.parent));

And either way, for full effect of NUMA awareness in the highlevel network driver, the midlayer should be NUMA aware too...

Signature · 3 lines
Stefan Richter
-=====-=-=== -=== --=--
http://arcgraph.de/sr/
#9 lore raw

Re: [PATCH 2/4] net: use numa_node in net_devcice->dev instead of parent

In reply to David Miller
Quoted 23 lines · David Miller

From: Christoph Hellwig <[email protected]>
Date: Wed, 4 Jul 2007 09:51:20 +0100

Quoted 19 lines · Yinghai Lu

net/core/skbuff.c nodata: · line 220

Quoted 13 lines

[PATCH 2/4] net: use numa_node in net_devcice->dev instead of parent

net/core/skbuff.c +1 -1
index 27cfe5f..005cc1c 100644
@@ -217,7 +217,7 @@ nodata:
 struct sk_buff *__netdev_alloc_skb(struct net_device *dev,
            unsigned int length, gfp_t gfp_mask)
 {
-   int node = dev->dev.parent ? dev_to_node(dev->dev.parent) : -1;
+   int node = dev_to_node(&dev->dev);

This looks wrong to me unless the device model has once again changed silently. When I wrote this code &dev->dev was a device allocated as part of the netdevice and the parent is the pci (or whatever) device that has the node information.

Quoted 2 lines

Correct, this change is completely bogus.
-

please check that with

http://lkml.org/lkml/2007/7/3/419

[PATCH 1/4] try parent numa_node at first before using default

YH

author
#10 lore raw

PATCH 3/4 net: make forcedeth to use kmalloc_node and __netdev_alloc_skb for skb allocation

In reply to Stephen Hemminger

[PATCH 3/4] net: make forcedeth to use kmalloc_node and __netdev_alloc_skb for skb allocation

drivers/net/forcedeth.c +16 -7
index 42ba1c0..aa188f4 100644
@@ -1383,7 +1383,8 @@ static int nv_alloc_rx(struct net_device *dev)
 		less_rx = np->last_rx.orig;
 
 	while (np->put_rx.orig != less_rx) {
-		struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz + NV_RX_ALLOC_PAD);
+		struct sk_buff *skb = __netdev_alloc_skb(dev, np->rx_buf_sz +
+						NV_RX_ALLOC_PAD, GFP_ATOMIC);
 		if (skb) {
 			np->put_rx_ctx->skb = skb;
 			np->put_rx_ctx->dma = pci_map_single(np->pci_dev,
@@ -1415,7 +1416,8 @@ static int nv_alloc_rx_optimized(struct net_device *dev)
 		less_rx = np->last_rx.ex;
 
 	while (np->put_rx.ex != less_rx) {
-		struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz + NV_RX_ALLOC_PAD);
+		struct sk_buff *skb = __netdev_alloc_skb(dev, np->rx_buf_sz +
+						NV_RX_ALLOC_PAD, GFP_ATOMIC);
 		if (skb) {
 			np->put_rx_ctx->skb = skb;
 			np->put_rx_ctx->dma = pci_map_single(np->pci_dev,
@@ -3976,8 +3978,10 @@ static int nv_set_ringparam(struct net_device *dev, struct ethtool_ringparam* ri
 					    sizeof(struct ring_desc_ex) * (ring->rx_pending + ring->tx_pending),
 					    &ring_addr);
 	}
-	rx_skbuff = kmalloc(sizeof(struct nv_skb_map) * ring->rx_pending, GFP_KERNEL);
-	tx_skbuff = kmalloc(sizeof(struct nv_skb_map) * ring->tx_pending, GFP_KERNEL);
+	rx_skbuff = kmalloc_node(sizeof(struct nv_skb_map) * ring->rx_pending,
+				 GFP_KERNEL, dev_to_node(&dev->dev));
+	tx_skbuff = kmalloc_node(sizeof(struct nv_skb_map) * ring->tx_pending,
+				 GFP_KERNEL, dev_to_node(&dev->dev));
 	if (!rxtx_ring || !rx_skbuff || !tx_skbuff) {
 		/* fall back to old rings */
 		if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
@@ -4372,7 +4376,7 @@ static int nv_loopback_test(struct net_device *dev)
 
 	/* setup packet for tx */
 	pkt_len = ETH_DATA_LEN;
-	tx_skb = dev_alloc_skb(pkt_len);
+	tx_skb = __netdev_alloc_skb(dev, pkt_len, GFP_ATOMIC);
 	if (!tx_skb) {
 		printk(KERN_ERR "dev_alloc_skb() failed during loopback test"
 			 " of %s\n", dev->name);
@@ -4976,6 +4980,8 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
 	dev->base_addr = (unsigned long)np->base;
 
 	dev->irq = pci_dev->irq;
+	printk(KERN_INFO "nv_probe: numa_node : %02d\n",
+		dev_to_node(&pci_dev->dev));
 
 	np->rx_ring_size = RX_RING_DEFAULT;
 	np->tx_ring_size = TX_RING_DEFAULT;
@@ -4995,8 +5001,11 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
 			goto out_unmap;
 		np->tx_ring.ex = &np->rx_ring.ex[np->rx_ring_size];
 	}
-	np->rx_skb = kmalloc(sizeof(struct nv_skb_map) * np->rx_ring_size, GFP_KERNEL);
-	np->tx_skb = kmalloc(sizeof(struct nv_skb_map) * np->tx_ring_size, GFP_KERNEL);
+	np->rx_skb = kmalloc_node(sizeof(struct nv_skb_map) * np->rx_ring_size,
+				  GFP_KERNEL, dev_to_node(&pci_dev->dev));
+	np->tx_skb = kmalloc_node(sizeof(struct nv_skb_map) * np->tx_ring_size,
+				  GFP_KERNEL, dev_to_node(&pci_dev->dev));
+
 	if (!np->rx_skb || !np->tx_skb)
 		goto out_freering;
 	memset(np->rx_skb, 0, sizeof(struct nv_skb_map) * np->rx_ring_size);
author
#11 lore raw
In reply to Andrew Morton
Quoted 5 lines · Andrew Morton
Quoted 1 line · On Fri, 29 Jun 2007 13:30:36 -0700 Yinghai Lu <[email protected]> wrote:

[PATCH 2/2] net: make net and forcedeth to use kmalloc_node

Quoted 7 lines

Please copy [email protected] on net patches.

It might help to edit code in an 80-col xterm.

Please run scritps/checkpatch.pl across all your diffs. Its suggestions are by no means compulsory, but they do provide things for you to check up and and have a think about, thanks.

I see. later.

Thanks

Yinghai Lu

#12 lore raw
In reply to Andrew Morton
Quoted 9 lines · Andrew Morton

drivers/net/forcedeth.c static int nv_alloc_rx(struct net_device *dev) · line 1386

Quoted 4 lines
drivers/net/forcedeth.c +1 -1
 	while (np->put_rx.orig != less_rx) {
-		struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz + NV_RX_ALLOC_PAD);
+		struct sk_buff *skb = dev_alloc_skb_node(np->rx_buf_sz + NV_RX_ALLOC_PAD, dev_to_node(&dev->dev));

If we're going to do this then it would probably make sense to change dev_alloc_skb_node() so that it takes a `struct net_device *' rather than a bare node-id. That's a call which the net guys will need to make, which is why we cc them on our emails.

That thing is called netdev_alloc_skb and already exists. And it's indeed what they should be using in the rx path.

#13 lore raw
Quoted 11 lines · Christoph Hellwig
Quoted 9 lines · Andrew Morton

Review

Quoted 4 lines
    while (np->put_rx.orig != less_rx) {
(quoted diff) +1 -1
-           struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz + NV_RX_ALLOC_PAD);
+           struct sk_buff *skb = dev_alloc_skb_node(np->rx_buf_sz + NV_RX_ALLOC_PAD, dev_to_node(&dev->dev));

If we're going to do this then it would probably make sense to change dev_alloc_skb_node() so that it takes a `struct net_device *' rather than a bare node-id. That's a call which the net guys will need to make, which is why we cc them on our emails.

Quoted 4 lines

That thing is called netdev_alloc_skb and already exists. And it's indeed what they should be using in the rx path.

-

please check
http://lkml.org/lkml/2007/7/3/418

[PATCH 3/4] net: make forcedeth to use kmalloc_node and __netdev_alloc_skb for skb allocation

but need to replace __netdev_alloc_skb to netdev_alloc_skb.

YH