netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* kfree_skb: unnecessary check ?
@ 2002-06-19 16:53 Patrick McHardy
  2002-06-19 19:51 ` Thomas 'Dent' Mirlacher
  2002-06-19 20:26 ` kuznet
  0 siblings, 2 replies; 4+ messages in thread
From: Patrick McHardy @ 2002-06-19 16:53 UTC (permalink / raw)
  To: netdev

Hi everyone.

In skbuff.h one sees:

static inline void kfree_skb(struct sk_buff *skb)
{
        if (atomic_read(&skb->users) == 1 || 
atomic_dec_and_test(&skb->users))
                __kfree_skb(skb);
}

Is atomic_dec_and_test really necessary ? atomic_dec_and_test only 
returns true if its argument has hit zero, so it was 1 before.
If atomic_dec is only a bit cheaper than atomic_dec_and_test (which i 
guess it is), wouldn't it make more sense to use something like this:

static inline void kfree_skb(struct sk_buff *skb)
{
    if (atomic_read(&skb->users) == 1)
        __kfree(skb);
    else
        atomic_dec(&skb->users);
}

Bye,
Patrick

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-06-19 21:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-19 16:53 kfree_skb: unnecessary check ? Patrick McHardy
2002-06-19 19:51 ` Thomas 'Dent' Mirlacher
2002-06-19 20:26 ` kuznet
2002-06-19 21:32   ` Patrick McHardy

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).