[ofa-general] [PATCH] Use vmalloc to alloc the rx_ring

David J. Wilder dwilder at us.ibm.com
Wed Jul 30 22:50:38 PDT 2008


This patch was built on Roland's git.

To prevent failures of the rx_ring allocations when using non-srq
and large recv_queue_size (1K or larger).  
vmalloc is used instead of kcalloc. vmalloc uses order 0 allocations.


Signed-off-by: David Wilder <dwilder at us.ibm.com>
---
 drivers/infiniband/ulp/ipoib/ipoib_cm.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
index 0f2d304..0040dbc 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
@@ -202,7 +202,7 @@ static void ipoib_cm_free_rx_ring(struct net_device *dev,
 			dev_kfree_skb_any(rx_ring[i].skb);
 		}
 
-	kfree(rx_ring);
+	vfree(rx_ring);
 }
 
 static void ipoib_cm_start_rx_drain(struct ipoib_dev_priv *priv)
@@ -352,9 +352,13 @@ static int ipoib_cm_nonsrq_init_rx(struct net_device *dev, struct ib_cm_id *cm_i
 	int ret;
 	int i;
 
-	rx->rx_ring = kcalloc(ipoib_recvq_size, sizeof *rx->rx_ring, GFP_KERNEL);
-	if (!rx->rx_ring)
+	rx->rx_ring = vmalloc( ipoib_recvq_size * sizeof *rx->rx_ring);
+
+	if (!rx->rx_ring){
+		printk(KERN_WARNING "ipoib_cm:Allocation of rx_ring failed, %s",
+			"try using a lower value of recv_queue_size.\n");
 		return -ENOMEM;
+	}
 
 	t = kmalloc(sizeof *t, GFP_KERNEL);
 	if (!t) {
@@ -1494,7 +1498,7 @@ static void ipoib_cm_create_srq(struct net_device *dev, int max_sge)
 		return;
 	}
 
-	priv->cm.srq_ring = kzalloc(ipoib_recvq_size * sizeof *priv->cm.srq_ring,
+	priv->cm.srq_ring = vmalloc(ipoib_recvq_size * sizeof *priv->cm.srq_ring);
 				    GFP_KERNEL);
 	if (!priv->cm.srq_ring) {
 		printk(KERN_WARNING "%s: failed to allocate CM SRQ ring (%d entries)\n",
@@ -1502,6 +1506,7 @@ static void ipoib_cm_create_srq(struct net_device *dev, int max_sge)
 		ib_destroy_srq(priv->cm.srq);
 		priv->cm.srq = NULL;
 	}
+	memset(rx_ring, 0, ipoib_recvq_size * sizeof *priv->cm.srq_ring);
 }
 
 int ipoib_cm_dev_init(struct net_device *dev)





More information about the general mailing list