Commit ff04a771 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net : optimize skb_release_data()

Cache skb_shinfo(skb) in a variable to avoid computing it multiple
times.

Reorganize the tests to remove one indentation level.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cec08315
...@@ -491,32 +491,33 @@ static void skb_free_head(struct sk_buff *skb) ...@@ -491,32 +491,33 @@ static void skb_free_head(struct sk_buff *skb)
static void skb_release_data(struct sk_buff *skb) static void skb_release_data(struct sk_buff *skb)
{ {
if (!skb->cloned || struct skb_shared_info *shinfo = skb_shinfo(skb);
!atomic_sub_return(skb->nohdr ? (1 << SKB_DATAREF_SHIFT) + 1 : 1,
&skb_shinfo(skb)->dataref)) {
if (skb_shinfo(skb)->nr_frags) {
int i; int i;
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
skb_frag_unref(skb, i); if (skb->cloned &&
} atomic_sub_return(skb->nohdr ? (1 << SKB_DATAREF_SHIFT) + 1 : 1,
&shinfo->dataref))
return;
for (i = 0; i < shinfo->nr_frags; i++)
__skb_frag_unref(&shinfo->frags[i]);
/* /*
* If skb buf is from userspace, we need to notify the caller * If skb buf is from userspace, we need to notify the caller
* the lower device DMA has done; * the lower device DMA has done;
*/ */
if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) { if (shinfo->tx_flags & SKBTX_DEV_ZEROCOPY) {
struct ubuf_info *uarg; struct ubuf_info *uarg;
uarg = skb_shinfo(skb)->destructor_arg; uarg = shinfo->destructor_arg;
if (uarg->callback) if (uarg->callback)
uarg->callback(uarg, true); uarg->callback(uarg, true);
} }
if (skb_has_frag_list(skb)) if (shinfo->frag_list)
skb_drop_fraglist(skb); kfree_skb_list(shinfo->frag_list);
skb_free_head(skb); skb_free_head(skb);
}
} }
/* /*
......
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