[ewg] [PATCH] ipoib_ud_skb_put optimization patch

Shirley Ma mashirle at us.ibm.com
Tue Feb 12 13:18:10 PST 2008


Hello Vlad,

Below is the patch to optimize ipoib_ud_skb_put_frags() call to avoid 
unnecessary calculation. This patch has been touch tested for RC4 build. 
I tried a few hours to generate a patch on top of the 4k mtu patch. 
It's not being successful. I gave up. I am giving the ipoib_ib.c diff here.
Appreciate if you can help here.

thanks
Shirley

Signed-off-by: Shirley Ma <xma at us.ibm.com>
---

diff -urpN ofed/drivers/infiniband/ulp/ipoib/ipoib_ib.c ofed_a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
--- ofed/drivers/infiniband/ulp/ipoib/ipoib_ib.c	2008-02-12 10:53:00.000000000 -0800
+++ ofed_a/drivers/infiniband/ulp/ipoib/ipoib_ib.c	2008-02-12 11:04:54.000000000 -0800
@@ -107,22 +107,17 @@ static void clean_pending_receives(struc
 static void ipoib_ud_skb_put_frags(struct ipoib_dev_priv *priv, struct sk_buff *skb,
 				   unsigned int length)
 {
-	if (ipoib_ud_need_sg(priv->max_ib_mtu)) {
-	 	unsigned int size;
- 		skb_frag_t *frag = &skb_shinfo(skb)->frags[0];
-
-	 	/* put header into skb */
- 		size = min(length, (unsigned)IPOIB_UD_HEAD_SIZE);
- 		skb->tail += size;
- 		skb->len += size;
- 		length -= size;
-
- 		size = min(length, (unsigned) PAGE_SIZE);
- 		frag->size = size;
- 		skb->data_len += size;
- 		skb->truesize += size;
- 		skb->len += size;
- 		length -= size;
+	skb_frag_t *frag = &skb_shinfo(skb)->frags[0];
+	if (skb_shinfo(skb)->nr_frags) {
+		/*
+		 * we know only two buffers here, first buf size is
+		 * IPOIB_UD_HEAD_SIZE
+		 */
+		skb->tail += IPOIB_UD_HEAD_SIZE;
+		frag->size = length - IPOIB_UD_HEAD_SIZE;
+		skb->data_len += frag->size;
+		skb->truesize += frag->size;
+		skb->len += length;
 	} else
 		skb_put(skb, length);
 }





More information about the ewg mailing list