From 3ccc6c6faaa93da70989177b91c7c3ef0df10937 Mon Sep 17 00:00:00 2001 From: linzhang Date: Mon, 17 Jul 2017 17:25:02 +0800 Subject: [PATCH] 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 Acked-by: Eric Dumazet Signed-off-by: David S. Miller --- net/core/skbuff.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 8b11341ed69a..b352c6bcfb31 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -1719,6 +1719,8 @@ void *__pskb_pull_tail(struct sk_buff *skb, int delta) if (eat) { skb_shinfo(skb)->frags[k].page_offset += eat; skb_frag_size_sub(&skb_shinfo(skb)->frags[k], eat); + if (!i) + goto end; eat = 0; } k++; @@ -1726,6 +1728,7 @@ void *__pskb_pull_tail(struct sk_buff *skb, int delta) } skb_shinfo(skb)->nr_frags = k; +end: skb->tail += delta; skb->data_len -= delta; -- GitLab