From: Jarek Poplawski <jarkao2@gmail.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Linux Netdev List <netdev@vger.kernel.org>
Subject: Re: [PATCH] inetpeer: optimizations
Date: Sun, 6 Dec 2009 19:22:10 +0100 [thread overview]
Message-ID: <20091206182210.GA3870@ami.dom.local> (raw)
In-Reply-To: <4B1B6F87.6050201@gmail.com>
On Sun, Dec 06, 2009 at 09:47:03AM +0100, Eric Dumazet wrote:
> Jarek Poplawski a écrit :
> > Eric Dumazet wrote, On 12/05/2009 01:11 PM:
> >
> >> - Use atomic_dec_and_test() in inet_putpeer()
> >
> > atomic_dec_and_lock()?
>
> Yes :)
>
> >
> >> This takes/dirties the lock only if necessary.
> > ...
> >
> >> void inet_putpeer(struct inet_peer *p)
> >> {
> >> - spin_lock_bh(&inet_peer_unused_lock);
> >> - if (atomic_dec_and_test(&p->refcnt)) {
> >> - list_add_tail(&p->unused, &unused_peers);
> >> + local_bh_disable();
> >> + if (atomic_dec_and_lock(&p->refcnt, &unused_peers.lock)) {
> >
> > Why not:
> > if (atomic_dec_and_test(&p->refcnt)) {
> > spin_lock_bh(&inet_peer_unused_lock);
> > ...
>
> Because we have to take the lock before doing the final 1 -> 0 refcount transition.
>
> (Another thread could do the 0 -> 1 transition)
AFAICS this lock here can only to prevent double linking to the
unused_peers list during such transitions. If so, it could be replaced
with the list_empty(&p->unused) test before list_add_tail(), and
atomic_dec_test() without the lock would be enough (unless I miss
something ;-).
Jarek P.
next prev parent reply other threads:[~2009-12-06 18:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-05 12:11 [PATCH] inetpeer: optimizations Eric Dumazet
2009-12-05 21:29 ` Jarek Poplawski
2009-12-06 8:47 ` Eric Dumazet
2009-12-06 14:18 ` Jarek Poplawski
2009-12-06 18:22 ` Jarek Poplawski [this message]
2009-12-06 18:53 ` Jarek Poplawski
2009-12-06 18:58 ` Eric Dumazet
2009-12-06 20:18 ` Jarek Poplawski
2009-12-09 4:46 ` 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=20091206182210.GA3870@ami.dom.local \
--to=jarkao2@gmail.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=netdev@vger.kernel.org \
/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).