lkml.org 
[lkml]   [2015]   [Nov]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH] net-ipv6: Delete unnecessary checks before the function call "kfree_skb"
    From
    Date
    On Sat, 2015-11-14 at 20:05 +0100, SF Markus Elfring wrote:
    > From: Markus Elfring <elfring@users.sourceforge.net>
    > Date: Sat, 14 Nov 2015 19:55:00 +0100
    >
    > The kfree_skb() function tests whether its argument is NULL and then
    > returns immediately. Thus the test around the calls is not needed.
    >
    > This issue was detected by using the Coccinelle software.
    >
    > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
    > ---
    > net/ipv6/af_inet6.c | 7 ++-----
    > net/ipv6/netfilter/nf_conntrack_reasm.c | 3 +--
    > 2 files changed, 3 insertions(+), 7 deletions(-)
    >
    > diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
    > index 44bb66b..4cd9259 100644
    > --- a/net/ipv6/af_inet6.c
    > +++ b/net/ipv6/af_inet6.c
    > @@ -416,12 +416,9 @@ void inet6_destroy_sock(struct sock *sk)
    > /* Release rx options */
    >
    > skb = xchg(&np->pktoptions, NULL);
    > - if (skb)
    > - kfree_skb(skb);
    > -
    > + kfree_skb(skb);
    > skb = xchg(&np->rxpmtu, NULL);
    > - if (skb)
    > - kfree_skb(skb);
    > + kfree_skb(skb);
    >

    There is no 'issue' here, or not this one.

    In most cases, these pointers are NULL, so the test can be predicted by
    the processor.

    While if the test is done in kfree_skb(), the branch predictor of the
    cpu wont be able to predict things.

    By feeding too many NULL pointers to kfree_skb(), we slow down it.

    Branch misses and hits were considered important years ago...

    But seeing this inet6_destroy_sock() is (ab)using xchg() three times, I
    am not sure author cared that much about performance.





    \
     
     \ /
      Last update: 2015-11-15 04:41    [W:4.563 / U:0.100 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site