From: Patrick McHardy <kaber@trash.net>
To: kuznet@ms2.inr.ac.ru
Cc: netdev@oss.sgi.com
Subject: Re: kfree_skb: unnecessary check ?
Date: Wed, 19 Jun 2002 23:32:19 +0200 [thread overview]
Message-ID: <3D10F863.4070204@trash.net> (raw)
In-Reply-To: 200206192026.AAA17502@sex.inr.ac.ru
kuznet@ms2.inr.ac.ru wrote:
>Hello!
>
>>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:
>>
>
>Does the prefix "atomic" not scare you? :-)
>
>
>>static inline void kfree_skb(struct sk_buff *skb)
>>{
>> if (atomic_read(&skb->users) == 1)
>> __kfree(skb);
>> else
>> atomic_dec(&skb->users);
>>}
>>
>
> else if (atomic_dec_and_test(&skb->users))
> __kfree_skb(skb);
>
>If you still do not understand think why it does not look like:
>
>static inline void kfree_skb(struct sk_buff *skb)
>{
> int users = skb->users;
> if (users == 1)
> __kfree(skb);
> else
> skb->users = users - 1;
>}
>
>Alexey
>
Hehe got it :)
Thanks
Patrick
prev parent reply other threads:[~2002-06-19 21:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
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=3D10F863.4070204@trash.net \
--to=kaber@trash.net \
--cc=kuznet@ms2.inr.ac.ru \
--cc=netdev@oss.sgi.com \
/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).