[openib-general] Re: [PATCH] repost: IPoIB queue size tune patch
Shirley Ma
xma at us.ibm.com
Tue Apr 4 16:31:47 PDT 2006
Roland,
Here is the updated patch for review. I have updated the max value to 8k
and min to 32.
Attachment is for you to apply the patch.
Signed-off-by: Shirley Ma <xma at us.ibm.com>
diff -urpN infiniband/ulp/ipoib/ipoib.h infiniband-queue/ulp/ipoib/ipoib.h
--- infiniband/ulp/ipoib/ipoib.h 2006-03-26 11:57:15.000000000
-0800
+++ infiniband-queue/ulp/ipoib/ipoib.h 2006-04-04 16:53:24.702300792
-0700
@@ -338,6 +338,8 @@ static inline void ipoib_unregister_debu
#define ipoib_warn(priv, format, arg...) \
ipoib_printk(KERN_WARNING, priv, format , ## arg)
+extern int ipoib_sendq_size;
+extern int ipoib_recvq_size;
#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
extern int ipoib_debug_level;
diff -urpN infiniband/ulp/ipoib/ipoib_ib.c
infiniband-queue/ulp/ipoib/ipoib_ib.c
--- infiniband/ulp/ipoib/ipoib_ib.c 2006-03-26 11:57:15.000000000
-0800
+++ infiniband-queue/ulp/ipoib/ipoib_ib.c 2006-04-04
16:56:49.475170584 -0700
@@ -161,7 +161,7 @@ static int ipoib_ib_post_receives(struct
struct ipoib_dev_priv *priv = netdev_priv(dev);
int i;
- for (i = 0; i < IPOIB_RX_RING_SIZE; ++i) {
+ for (i = 0; i < ipoib_recvq_size; ++i) {
if (ipoib_alloc_rx_skb(dev, i)) {
ipoib_warn(priv, "failed to allocate receive
buffer %d\n", i);
return -ENOMEM;
@@ -187,7 +187,7 @@ static void ipoib_ib_handle_wc(struct ne
if (wr_id & IPOIB_OP_RECV) {
wr_id &= ~IPOIB_OP_RECV;
- if (wr_id < IPOIB_RX_RING_SIZE) {
+ if (wr_id < ipoib_recvq_size) {
struct sk_buff *skb = priv->rx_ring[wr_id].skb;
dma_addr_t addr =
priv->rx_ring[wr_id].mapping;
@@ -252,9 +252,9 @@ static void ipoib_ib_handle_wc(struct ne
struct ipoib_tx_buf *tx_req;
unsigned long flags;
- if (wr_id >= IPOIB_TX_RING_SIZE) {
+ if (wr_id >= ipoib_sendq_size) {
ipoib_warn(priv, "completion event with wrid %d (>
%d)\n",
- wr_id, IPOIB_TX_RING_SIZE);
+ wr_id, ipoib_sendq_size);
return;
}
@@ -275,7 +275,7 @@ static void ipoib_ib_handle_wc(struct ne
spin_lock_irqsave(&priv->tx_lock, flags);
++priv->tx_tail;
if (netif_queue_stopped(dev) &&
- priv->tx_head - priv->tx_tail <= IPOIB_TX_RING_SIZE /
2)
+ priv->tx_head - priv->tx_tail <= ipoib_sendq_size / 2)
netif_wake_queue(dev);
spin_unlock_irqrestore(&priv->tx_lock, flags);
@@ -344,13 +344,13 @@ void ipoib_send(struct net_device *dev,
* means we have to make sure everything is properly recorded and
* our state is consistent before we call post_send().
*/
- tx_req = &priv->tx_ring[priv->tx_head & (IPOIB_TX_RING_SIZE - 1)];
+ tx_req = &priv->tx_ring[priv->tx_head & (ipoib_sendq_size - 1)];
tx_req->skb = skb;
addr = dma_map_single(priv->ca->dma_device, skb->data, skb->len,
DMA_TO_DEVICE);
pci_unmap_addr_set(tx_req, mapping, addr);
- if (unlikely(post_send(priv, priv->tx_head & (IPOIB_TX_RING_SIZE -
1),
+ if (unlikely(post_send(priv, priv->tx_head & (ipoib_sendq_size -
1),
address->ah, qpn, addr, skb->len))) {
ipoib_warn(priv, "post_send failed\n");
++priv->stats.tx_errors;
@@ -363,7 +363,7 @@ void ipoib_send(struct net_device *dev,
address->last_send = priv->tx_head;
++priv->tx_head;
- if (priv->tx_head - priv->tx_tail == IPOIB_TX_RING_SIZE) {
+ if (priv->tx_head - priv->tx_tail == ipoib_sendq_size) {
ipoib_dbg(priv, "TX ring full, stopping kernel net
queue\n");
netif_stop_queue(dev);
}
@@ -488,7 +488,7 @@ static int recvs_pending(struct net_devi
int pending = 0;
int i;
- for (i = 0; i < IPOIB_RX_RING_SIZE; ++i)
+ for (i = 0; i < ipoib_recvq_size; ++i)
if (priv->rx_ring[i].skb)
++pending;
@@ -527,7 +527,7 @@ int ipoib_ib_dev_stop(struct net_device
*/
while ((int) priv->tx_tail - (int) priv->tx_head <
0) {
tx_req = &priv->tx_ring[priv->tx_tail &
- (IPOIB_TX_RING_SIZE - 1)];
+ (ipoib_sendq_size
- 1)];
dma_unmap_single(priv->ca->dma_device,
pci_unmap_addr(tx_req,
mapping),
tx_req->skb->len,
@@ -536,7 +536,7 @@ int ipoib_ib_dev_stop(struct net_device
++priv->tx_tail;
}
- for (i = 0; i < IPOIB_RX_RING_SIZE; ++i)
+ for (i = 0; i < ipoib_recvq_size; ++i)
if (priv->rx_ring[i].skb) {
dma_unmap_single(priv->ca->dma_device,
pci_unmap_addr(&priv->rx_ring[i],
diff -urpN infiniband/ulp/ipoib/ipoib_main.c
infiniband-queue/ulp/ipoib/ipoib_main.c
--- infiniband/ulp/ipoib/ipoib_main.c 2006-03-28 19:20:21.000000000
-0800
+++ infiniband-queue/ulp/ipoib/ipoib_main.c 2006-04-04
17:17:14.643916624 -0700
@@ -41,6 +41,7 @@
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
+#include <linux/kernel.h>
#include <linux/if_arp.h> /* For ARPHRD_xxx */
@@ -53,6 +54,17 @@ MODULE_AUTHOR("Roland Dreier");
MODULE_DESCRIPTION("IP-over-InfiniBand net driver");
MODULE_LICENSE("Dual BSD/GPL");
+#define IPOIB_MAX_QUEUE_SIZE 8192 /* max is 8k */
+#define IPOIB_MIN_QUEUE_SIZE 32 /* min is 32 */
+
+int ipoib_sendq_size = IPOIB_TX_RING_SIZE;
+int ipoib_recvq_size = IPOIB_RX_RING_SIZE;
+
+module_param_named(sendq_size, ipoib_sendq_size, int, 0444);
+MODULE_PARM_DESC(sendq_size, "Number of wqe in send queue");
+module_param_named(recvq_size, ipoib_recvq_size, int, 0444);
+MODULE_PARM_DESC(recvq_size, "Number of wqe in receive queue");
+
#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
int ipoib_debug_level;
@@ -843,19 +855,39 @@ int ipoib_dev_init(struct net_device *de
/* Allocate RX/TX "rings" to hold queued skbs */
- priv->rx_ring = kzalloc(IPOIB_RX_RING_SIZE * sizeof (struct
ipoib_rx_buf),
+ if (ipoib_recvq_size > IPOIB_MAX_QUEUE_SIZE) {
+ ipoib_recvq_size = IPOIB_MAX_QUEUE_SIZE;
+ printk(KERN_WARNING "%s: ipoib_recvq_size is too big, use
max %d instead\n", ca->name, IPOIB_MAX_QUEUE_SIZE);
+ }
+ if (ipoib_recvq_size < IPOIB_MIN_QUEUE_SIZE) {
+ ipoib_recvq_size = IPOIB_MIN_QUEUE_SIZE;
+ printk(KERN_WARNING "%s: ipoib_recvq_size is too small,
use min %d instead\n", ca->name, IPOIB_MIN_QUEUE_SIZE);
+ }
+ ipoib_recvq_size = roundup_pow_of_two(ipoib_recvq_size);
+ priv->rx_ring = kzalloc(ipoib_recvq_size * sizeof (struct
ipoib_rx_buf),
GFP_KERNEL);
if (!priv->rx_ring) {
printk(KERN_WARNING "%s: failed to allocate RX ring (%d
entries)\n",
- ca->name, IPOIB_RX_RING_SIZE);
+ ca->name, ipoib_sendq_size);
goto out;
}
- priv->tx_ring = kzalloc(IPOIB_TX_RING_SIZE * sizeof (struct
ipoib_tx_buf),
+ if (ipoib_sendq_size > IPOIB_MAX_QUEUE_SIZE) {
+ ipoib_sendq_size = IPOIB_MAX_QUEUE_SIZE;
+ printk(KERN_WARNING "%s: ipoib_sendq_size is too big, use
max %d instead\n", ca->name, IPOIB_MAX_QUEUE_SIZE);
+ }
+ if (ipoib_sendq_size < IPOIB_MIN_QUEUE_SIZE) {
+ ipoib_sendq_size = IPOIB_MIN_QUEUE_SIZE;
+ printk(KERN_WARNING "%s: ipoib_sendq_size is too small,
use min %d instead\n", ca->name, IPOIB_MIN_QUEUE_SIZE);
+ }
+
+ ipoib_sendq_size = roundup_pow_of_two(ipoib_sendq_size);
+
+ priv->tx_ring = kzalloc(ipoib_sendq_size * sizeof (struct
ipoib_tx_buf),
GFP_KERNEL);
if (!priv->tx_ring) {
printk(KERN_WARNING "%s: failed to allocate TX ring (%d
entries)\n",
- ca->name, IPOIB_TX_RING_SIZE);
+ ca->name, ipoib_sendq_size);
goto out_rx_ring_cleanup;
}
@@ -923,7 +955,7 @@ static void ipoib_setup(struct net_devic
dev->hard_header_len = IPOIB_ENCAP_LEN + INFINIBAND_ALEN;
dev->addr_len = INFINIBAND_ALEN;
dev->type = ARPHRD_INFINIBAND;
- dev->tx_queue_len = IPOIB_TX_RING_SIZE * 2;
+ dev->tx_queue_len = ipoib_sendq_size * 2;
dev->features = NETIF_F_VLAN_CHALLENGED | NETIF_F_LLTX;
/* MTU will be reset when mcast join happens */
diff -urpN infiniband/ulp/ipoib/ipoib_verbs.c
infiniband-queue/ulp/ipoib/ipoib_verbs.c
--- infiniband/ulp/ipoib/ipoib_verbs.c 2006-03-26 11:57:15.000000000
-0800
+++ infiniband-queue/ulp/ipoib/ipoib_verbs.c 2006-04-04
16:57:07.098491432 -0700
@@ -159,8 +159,8 @@ int ipoib_transport_dev_init(struct net_
struct ipoib_dev_priv *priv = netdev_priv(dev);
struct ib_qp_init_attr init_attr = {
.cap = {
- .max_send_wr = IPOIB_TX_RING_SIZE,
- .max_recv_wr = IPOIB_RX_RING_SIZE,
+ .max_send_wr = ipoib_sendq_size,
+ .max_recv_wr = ipoib_recvq_size,
.max_send_sge = 1,
.max_recv_sge = 1
},
@@ -175,7 +175,7 @@ int ipoib_transport_dev_init(struct net_
}
priv->cq = ib_create_cq(priv->ca, ipoib_ib_completion, NULL, dev,
- IPOIB_TX_RING_SIZE + IPOIB_RX_RING_SIZE +
1);
+ ipoib_sendq_size + ipoib_recvq_size + 1);
if (IS_ERR(priv->cq)) {
printk(KERN_WARNING "%s: failed to create CQ\n",
ca->name);
goto out_free_pd;
Thanks
Shirley Ma
IBM Linux Technology Center
15300 SW Koll Parkway
Beaverton, OR 97006-6063
Phone(Fax): (503) 578-7638
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20060404/e8aefd34/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: infiniband-queue.patch
Type: application/octet-stream
Size: 8329 bytes
Desc: not available
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20060404/e8aefd34/attachment.obj>
More information about the general
mailing list