Commit 66e92fcf authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller

gro: Nasty optimisations for page frags in skb_gro_receive

This patch reverses the direction of the frags array copy in
skb_gro_receive in order simplify the loop conditional.  It
also avoids touching the first element of the original frags
array.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cb18978c
...@@ -2676,21 +2676,26 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb) ...@@ -2676,21 +2676,26 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb)
goto merge; goto merge;
else if (headlen <= offset) { else if (headlen <= offset) {
skb_frag_t *frag; skb_frag_t *frag;
int i; skb_frag_t *frag2;
int i = skb_shinfo(skb)->nr_frags;
int nr_frags = skb_shinfo(p)->nr_frags + i;
offset -= headlen;
if (skb_shinfo(p)->nr_frags + skb_shinfo(skb)->nr_frags > if (nr_frags > MAX_SKB_FRAGS)
MAX_SKB_FRAGS)
return -E2BIG; return -E2BIG;
skb_shinfo(skb)->frags[0].page_offset += offset - headlen; skb_shinfo(p)->nr_frags = nr_frags;
skb_shinfo(skb)->frags[0].size -= offset - headlen; skb_shinfo(skb)->nr_frags = 0;
frag = skb_shinfo(p)->frags + skb_shinfo(p)->nr_frags; frag = skb_shinfo(p)->frags + nr_frags;
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) frag2 = skb_shinfo(skb)->frags + i;
*frag++ = skb_shinfo(skb)->frags[i]; do {
*--frag = *--frag2;
} while (--i);
skb_shinfo(p)->nr_frags += skb_shinfo(skb)->nr_frags; frag->page_offset += offset;
skb_shinfo(skb)->nr_frags = 0; frag->size -= offset;
skb->truesize -= skb->data_len; skb->truesize -= skb->data_len;
skb->len -= skb->data_len; skb->len -= skb->data_len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment