From: Flavio Leitner <fbl@redhat.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Wei Yongjun <weiyj.lk@gmail.com>,
davem@davemloft.net, yongjun_wei@trendmicro.com.cn,
netdev@vger.kernel.org
Subject: Re: [PATCH] skbuff: remove pointless conditional before kfree_skb()
Date: Tue, 28 Aug 2012 16:17:19 -0300 [thread overview]
Message-ID: <20120828161719.6faca38c@obelix.rh> (raw)
In-Reply-To: <1346163154.3571.6.camel@edumazet-glaptop>
On Tue, 28 Aug 2012 07:12:34 -0700
Eric Dumazet <eric.dumazet@gmail.com> wrote:
> On Tue, 2012-08-28 at 21:10 +0800, Wei Yongjun wrote:
> > From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> >
> > Remove pointless conditional before kfree_skb().
> >
> > Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> > ---
> > include/linux/skbuff.h | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> > index 7632c87..0b846d9 100644
> > --- a/include/linux/skbuff.h
> > +++ b/include/linux/skbuff.h
> > @@ -2464,8 +2464,7 @@ static inline void nf_conntrack_get_reasm(struct sk_buff *skb)
> > }
> > static inline void nf_conntrack_put_reasm(struct sk_buff *skb)
> > {
> > - if (skb)
> > - kfree_skb(skb);
> > + kfree_skb(skb);
> > }
> > #endif
> > #ifdef CONFIG_BRIDGE_NETFILTER
> >
>
>
> Its not exactly pointless.
>
> Its a tradeoff between kernel code size, and ability for cpu to predict
> a branch in kfree_skb()
>
> This test is in hot path, and therefore this patch can potentially have
> a performance impact.
>
> I really think most kfree_skb() calls are done with a non NULL param,
> so the branch prediction is good.
>
> But after this patch, things are totally different.
>
But then the kfree_skb() is somewhat misleading because it does
check for NULL argument. One would have to remember if it's in
hot path or not. So, what about a new macro to pair with
kfree_skb()? That would document the code and would also
make easier to remember about the performance issue.
For instance:
/* kfree_skb() version to be used in hot code path
* as the branch prediction can improve performance
*/
#define kfree_skb_hot(skb) \
if (skb) \
kfree_skb(skb) \
fbl
next prev parent reply other threads:[~2012-08-28 19:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-28 13:10 [PATCH] skbuff: remove pointless conditional before kfree_skb() Wei Yongjun
2012-08-28 14:12 ` Eric Dumazet
2012-08-28 19:17 ` Flavio Leitner [this message]
2012-08-28 20:09 ` Eric Dumazet
2012-08-28 20:39 ` Flavio Leitner
2012-08-29 3:38 ` Eric Dumazet
2012-08-30 17:39 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120828161719.6faca38c@obelix.rh \
--to=fbl@redhat.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=weiyj.lk@gmail.com \
--cc=yongjun_wei@trendmicro.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).