Skip to content

Commit

Permalink
skbuff: optimize the pull_pages code in __pskb_pull_tail()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
linzhang authored and David S. Miller committed Jul 17, 2017
1 parent b3a703c commit 3ccc6c6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -1719,13 +1719,16 @@ 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++;
}
}
skb_shinfo(skb)->nr_frags = k;

end:
skb->tail += delta;
skb->data_len -= delta;

Expand Down

0 comments on commit 3ccc6c6

Please sign in to comment.