| Submitter | Eric Dumazet |
|---|---|
| Date | July 23, 2010, 5:09 a.m. |
| Message ID | <1279861748.2482.13.camel@edumazet-laptop> |
| Download | mbox | patch |
| Permalink | /patch/59732/ |
| State | Accepted |
| Delegated to: | David Miller |
| Headers | show |
Comments
From: Eric Dumazet <eric.dumazet@gmail.com> Date: Fri, 23 Jul 2010 07:09:08 +0200 > [PATCH net-next-2.6] net: pskb_expand_head() optimization > > Move frags[] at the end of struct skb_shared_info, and make > pskb_expand_head() copy only the used part of it instead of whole array. > > This should avoid kmemcheck warnings and speedup pskb_expand_head() as > well, avoiding a lot of cache misses. > > Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Maybe it's just that people aren't running kmemcheck when a pskb_expand_head() triggers, who knows. Anyways, since we skip the ->frag[] array in skb alloc, etc., your patch is of course fine. Applied, thanks! -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Patch
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index f5aa87e..d89876b 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -202,10 +202,11 @@ struct skb_shared_info { */ atomic_t dataref; - skb_frag_t frags[MAX_SKB_FRAGS]; /* Intermediate layers must ensure that destructor_arg * remains valid until skb destructor */ void * destructor_arg; + /* must be last field, see pskb_expand_head() */ + skb_frag_t frags[MAX_SKB_FRAGS]; }; /* We divide dataref into two halves. The higher 16 bits hold references diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 76d33ca..7da58a2 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -817,7 +817,7 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail, memcpy(data + nhead, skb->head, skb->tail - skb->head); #endif memcpy(data + size, skb_end_pointer(skb), - sizeof(struct skb_shared_info)); + offsetof(struct skb_shared_info, frags[skb_shinfo(skb)->nr_frags])); for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) get_page(skb_shinfo(skb)->frags[i].page);