netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RE: [PATCH netdev-2.6 7/10] ixgb: Replace kmalloc with vmalloc to allocate driver local data structures
@ 2004-10-29 12:50 Venkatesan, Ganesh
  2004-10-29 13:08 ` Christoph Hellwig
  0 siblings, 1 reply; 11+ messages in thread
From: Venkatesan, Ganesh @ 2004-10-29 12:50 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: jgarzik, netdev

This is a trade-off between space allocated via kmalloc and vmalloc. My
understanding is that kmalloc space is more limited than vmalloc. Is
this incorrect?

With the original implementation that used kmalloc for all allocations
in the driver, I have noticed allocation failures when the ring sizes
were set to 4096. Switching the allocation of this space from kmalloc to
vmalloc guarantees successful allocation.

What am I missing?

Ganesh.

-----Original Message-----
From: Christoph Hellwig [mailto:hch@infradead.org] 
Sent: Friday, October 29, 2004 5:15 AM
To: Venkatesan, Ganesh
Cc: jgarzik@pobox.com; netdev
Subject: Re: [PATCH netdev-2.6 7/10] ixgb: Replace kmalloc with vmalloc
to allocate driver local data structures

this uses up vmalloc space and thus is a regression.

^ permalink raw reply	[flat|nested] 11+ messages in thread
* RE: [PATCH netdev-2.6 7/10] ixgb: Replace kmalloc with vmalloc to allocate driver local data structures
@ 2004-10-29 15:35 Venkatesan, Ganesh
  2004-10-29 16:41 ` Jon Mason
  0 siblings, 1 reply; 11+ messages in thread
From: Venkatesan, Ganesh @ 2004-10-29 15:35 UTC (permalink / raw)
  To: Jon Mason, Christoph Hellwig; +Cc: jgarzik, netdev


>There seems to be 3 ways around this problem.
>1) change the unsigned long fields in ixgb_buffer to unsigned ints
(this
>decreases the size of the struct enough to use kmalloc)

PATCH netdev-2.6 6/10 does this.

^ permalink raw reply	[flat|nested] 11+ messages in thread
* [PATCH netdev-2.6 7/10] ixgb: Replace kmalloc with vmalloc to allocate driver local data structures
@ 2004-10-29 12:11 Ganesh Venkatesan
  2004-10-29 12:14 ` Christoph Hellwig
  0 siblings, 1 reply; 11+ messages in thread
From: Ganesh Venkatesan @ 2004-10-29 12:11 UTC (permalink / raw)
  To: jgarzik@pobox.com; +Cc: netdev

Signed-off-by: ganesh venkatesan <ganesh.venkatesan@intel.com>

diff -up netdev-2.6/drivers/net/ixgb/ixgb.h netdev-2.6/drivers/net/ixgb.new/ixgb.h
--- netdev-2.6/drivers/net/ixgb/ixgb.h	2004-10-15 13:15:38.000000000 -0700
+++ netdev-2.6/drivers/net/ixgb.new/ixgb.h	2004-10-15 13:15:51.000000000 -0700
@@ -46,6 +46,7 @@
 #include <linux/delay.h>
 #include <linux/timer.h>
 #include <linux/slab.h>
+#include <linux/vmalloc.h>
 #include <linux/interrupt.h>
 #include <linux/string.h>
 #include <linux/pagemap.h>
diff -up netdev-2.6/drivers/net/ixgb/ixgb_main.c netdev-2.6/drivers/net/ixgb.new/ixgb_main.c
--- netdev-2.6/drivers/net/ixgb/ixgb_main.c	2004-10-15 13:15:38.000000000 -0700
+++ netdev-2.6/drivers/net/ixgb.new/ixgb_main.c	2004-10-15 13:15:55.000000000 -0700
@@ -608,8 +608,8 @@ static int ixgb_close(struct net_device 
 	int size;
 
 	size = sizeof(struct ixgb_buffer) * txdr->count;
-	txdr->buffer_info = kmalloc(size, GFP_KERNEL);
 	if (!txdr->buffer_info) {
+	txdr->buffer_info = vmalloc(size);
 		return -ENOMEM;
 	}
 	memset(txdr->buffer_info, 0, size);
@@ -621,7 +620,7 @@ static int ixgb_setup_tx_resources(struc
 
 	txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
 	if (!txdr->desc) {
-		kfree(txdr->buffer_info);
+		vfree(txdr->buffer_info);
 		return -ENOMEM;
 	}
 	memset(txdr->desc, 0, txdr->size);
@@ -697,8 +692,8 @@ static void ixgb_configure_tx(struct ixg
 	int size;
 
 	size = sizeof(struct ixgb_buffer) * rxdr->count;
-	rxdr->buffer_info = kmalloc(size, GFP_KERNEL);
 	if (!rxdr->buffer_info) {
+	rxdr->buffer_info = vmalloc(size);
 		return -ENOMEM;
 	}
 	memset(rxdr->buffer_info, 0, size);
@@ -711,7 +713,7 @@ static int ixgb_setup_rx_resources(struc
 	rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
 
 	if (!rxdr->desc) {
-		kfree(rxdr->buffer_info);
+		vfree(rxdr->buffer_info);
 		return -ENOMEM;
 	}
 	memset(rxdr->desc, 0, rxdr->size);
@@ -865,7 +867,7 @@ static void ixgb_configure_rx(struct ixg
 
 	ixgb_clean_tx_ring(adapter);
 
-	kfree(adapter->tx_ring.buffer_info);
+	vfree(adapter->tx_ring.buffer_info);
 	adapter->tx_ring.buffer_info = NULL;
 
 	pci_free_consistent(pdev, adapter->tx_ring.size,
@@ -931,7 +935,7 @@ static void ixgb_clean_tx_ring(struct ix
 
 	ixgb_clean_rx_ring(adapter);
 
-	kfree(rx_ring->buffer_info);
+	vfree(rx_ring->buffer_info);
 	rx_ring->buffer_info = NULL;
 
 	pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma);

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2004-10-29 18:29 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-29 12:50 [PATCH netdev-2.6 7/10] ixgb: Replace kmalloc with vmalloc to allocate driver local data structures Venkatesan, Ganesh
2004-10-29 13:08 ` Christoph Hellwig
2004-10-29 15:28   ` Jon Mason
2004-10-29 17:02   ` Jeff Garzik
2004-10-29 17:36     ` William Lee Irwin III
2004-10-29 18:26       ` Jeff Garzik
2004-10-29 18:29         ` William Lee Irwin III
  -- strict thread matches above, loose matches on Subject: below --
2004-10-29 15:35 Venkatesan, Ganesh
2004-10-29 16:41 ` Jon Mason
2004-10-29 12:11 Ganesh Venkatesan
2004-10-29 12:14 ` Christoph Hellwig

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).