diff options
author | Eric Dumazet <edumazet@google.com> | 2014-09-23 21:39:30 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-09-26 16:53:49 -0400 |
commit | ff04a771ad25fc9ba91690e73465b4d34b6bf8b3 (patch) | |
tree | 4d42ca1c4b28e84e35f8e4cad3ad277287c25cc8 /net/core | |
parent | cec08315190a4461a369d47041a510d104a5d2a2 (diff) |
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: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/skbuff.c | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 512dc7dcbc32..d4fdc649112c 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
@@ -491,32 +491,33 @@ static void skb_free_head(struct sk_buff *skb) | |||
491 | 491 | ||
492 | static void skb_release_data(struct sk_buff *skb) | 492 | static void skb_release_data(struct sk_buff *skb) |
493 | { | 493 | { |
494 | if (!skb->cloned || | 494 | struct skb_shared_info *shinfo = skb_shinfo(skb); |
495 | !atomic_sub_return(skb->nohdr ? (1 << SKB_DATAREF_SHIFT) + 1 : 1, | 495 | int i; |
496 | &skb_shinfo(skb)->dataref)) { | ||
497 | if (skb_shinfo(skb)->nr_frags) { | ||
498 | int i; | ||
499 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) | ||
500 | skb_frag_unref(skb, i); | ||
501 | } | ||
502 | 496 | ||
503 | /* | 497 | if (skb->cloned && |
504 | * If skb buf is from userspace, we need to notify the caller | 498 | atomic_sub_return(skb->nohdr ? (1 << SKB_DATAREF_SHIFT) + 1 : 1, |
505 | * the lower device DMA has done; | 499 | &shinfo->dataref)) |
506 | */ | 500 | return; |
507 | if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) { | ||
508 | struct ubuf_info *uarg; | ||
509 | 501 | ||
510 | uarg = skb_shinfo(skb)->destructor_arg; | 502 | for (i = 0; i < shinfo->nr_frags; i++) |
511 | if (uarg->callback) | 503 | __skb_frag_unref(&shinfo->frags[i]); |
512 | uarg->callback(uarg, true); | ||
513 | } | ||
514 | 504 | ||
515 | if (skb_has_frag_list(skb)) | 505 | /* |
516 | skb_drop_fraglist(skb); | 506 | * If skb buf is from userspace, we need to notify the caller |
507 | * the lower device DMA has done; | ||
508 | */ | ||
509 | if (shinfo->tx_flags & SKBTX_DEV_ZEROCOPY) { | ||
510 | struct ubuf_info *uarg; | ||
517 | 511 | ||
518 | skb_free_head(skb); | 512 | uarg = shinfo->destructor_arg; |
513 | if (uarg->callback) | ||
514 | uarg->callback(uarg, true); | ||
519 | } | 515 | } |
516 | |||
517 | if (shinfo->frag_list) | ||
518 | kfree_skb_list(shinfo->frag_list); | ||
519 | |||
520 | skb_free_head(skb); | ||
520 | } | 521 | } |
521 | 522 | ||
522 | /* | 523 | /* |