Browse Source

skbuff: optimize the pull_pages code in __pskb_pull_tail()

In the pull_pages code block, if the first frag size > eat,
we can end the loop in advance to avoid extra copy.

Signed-off-by: Lin Zhang <xiaolou4617@gmail.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
linzhang 8 years ago
parent
commit
3ccc6c6faa
1 changed files with 3 additions and 0 deletions
  1. 3 0
      net/core/skbuff.c

+ 3 - 0
net/core/skbuff.c

@@ -1719,6 +1719,8 @@ pull_pages:
 			if (eat) {
 			if (eat) {
 				skb_shinfo(skb)->frags[k].page_offset += eat;
 				skb_shinfo(skb)->frags[k].page_offset += eat;
 				skb_frag_size_sub(&skb_shinfo(skb)->frags[k], eat);
 				skb_frag_size_sub(&skb_shinfo(skb)->frags[k], eat);
+				if (!i)
+					goto end;
 				eat = 0;
 				eat = 0;
 			}
 			}
 			k++;
 			k++;
@@ -1726,6 +1728,7 @@ pull_pages:
 	}
 	}
 	skb_shinfo(skb)->nr_frags = k;
 	skb_shinfo(skb)->nr_frags = k;
 
 
+end:
 	skb->tail     += delta;
 	skb->tail     += delta;
 	skb->data_len -= delta;
 	skb->data_len -= delta;