All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
To: Changli Gao <xiaosuo@gmail.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
	David Miller <davem@davemloft.net>,
	netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next-2.6] net: build_ehash_secret() and rt_bind_peer() cleanups
Date: Thu, 19 Aug 2010 12:13:26 -0400	[thread overview]
Message-ID: <20100819161326.GB24357@Krystal> (raw)
In-Reply-To: <AANLkTinpqNa3cgEb=86H0sYXdLmo-RP1G2icJgWpfyN1@mail.gmail.com>

* Changli Gao (xiaosuo@gmail.com) wrote:
> On Thu, Aug 19, 2010 at 11:46 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> > Now cmpxchg() is available on all arches, we can use it in
> > build_ehash_secret() and rt_bind_peer() instead of using spinlocks.
> >
> > Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> > CC: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
> > ---
[...]
> >  void rt_bind_peer(struct rtable *rt, int create)
> >  {
> > -       static DEFINE_SPINLOCK(rt_peer_lock);
> >        struct inet_peer *peer;
> >
> >        peer = inet_getpeer(rt->rt_dst, create);
> >
> > -       spin_lock_bh(&rt_peer_lock);
> > -       if (rt->peer == NULL) {
> > -               rt->peer = peer;
> > -               peer = NULL;
> > -       }
> > -       spin_unlock_bh(&rt_peer_lock);
> > -       if (peer)
> > +       peer = cmpxchg(&rt->peer, NULL, peer);
> > +
> > +       if (unlikely(peer))
> 
> It isn't correct, and should be
>      if (unlikely(cmpxchg(&rt->peer, NULL, peer) != NULL))
> 
> >                inet_putpeer(peer);
> >  }

What do you mean by "It isn't correct" ? Eric code and yours perform the
exact same thing. So I assume this is just a code style issue here.

Thanks,

Mathieu


-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

  parent reply	other threads:[~2010-08-19 16:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-19 15:46 [PATCH net-next-2.6] net: build_ehash_secret() and rt_bind_peer() cleanups Eric Dumazet
2010-08-19 15:58 ` Changli Gao
2010-08-19 16:10   ` [PATCH net-next-2.6 v2] " Eric Dumazet
2010-08-20  7:51     ` David Miller
2010-08-19 16:10   ` [PATCH net-next-2.6] " Changli Gao
2010-08-19 16:13   ` Mathieu Desnoyers [this message]
2010-08-19 16:30     ` Mathieu Desnoyers
2010-08-19 16:28 ` Mathieu Desnoyers

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=20100819161326.GB24357@Krystal \
    --to=mathieu.desnoyers@polymtl.ca \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=xiaosuo@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.