Skip to content

Commit

Permalink
gro: Open-code frags copy in skb_gro_receive
Browse files Browse the repository at this point in the history
gcc does a poor job at generating code for the memcpy of the frags
array in skb_gro_receive, which is the primary purpose of that
function when merging frags.  In particular, it can't utilise the
alignment information of the source and destination.  This patch
open-codes the copy so we process words instead of bytes.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
herbertx authored and davem330 committed May 27, 2009
1 parent 0fb2787 commit 42da699
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -2673,6 +2673,9 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb)
if (skb_shinfo(p)->frag_list)
goto merge;
else if (skb_headlen(skb) <= skb_gro_offset(skb)) {
skb_frag_t *frag;
int i;

if (skb_shinfo(p)->nr_frags + skb_shinfo(skb)->nr_frags >
MAX_SKB_FRAGS)
return -E2BIG;
Expand All @@ -2682,9 +2685,9 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb)
skb_shinfo(skb)->frags[0].size -=
skb_gro_offset(skb) - skb_headlen(skb);

memcpy(skb_shinfo(p)->frags + skb_shinfo(p)->nr_frags,
skb_shinfo(skb)->frags,
skb_shinfo(skb)->nr_frags * sizeof(skb_frag_t));
frag = skb_shinfo(p)->frags + skb_shinfo(p)->nr_frags;
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
*frag++ = skb_shinfo(skb)->frags[i];

skb_shinfo(p)->nr_frags += skb_shinfo(skb)->nr_frags;
skb_shinfo(skb)->nr_frags = 0;
Expand Down

0 comments on commit 42da699

Please sign in to comment.