linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@us.ibm.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Suzanne Wood <suzannew@cs.pdx.edu>,
	Robert.Olsson@data.slu.se, davem@davemloft.net,
	linux-kernel@vger.kernel.org, netdev@oss.sgi.com,
	walpole@cs.pdx.edu
Subject: Re: [RFC][PATCH] identify in_dev_get rcu read-side critical sections
Date: Sat, 1 Oct 2005 11:04:41 -0700	[thread overview]
Message-ID: <20051001180441.GA1578@us.ibm.com> (raw)
In-Reply-To: <20051001071248.GA15990@gondor.apana.org.au>

On Sat, Oct 01, 2005 at 05:12:48PM +1000, Herbert Xu wrote:
> On Fri, Sep 30, 2005 at 11:56:41PM -0700, Suzanne Wood wrote:
> > 
> > But it is interesting to have discarded what was developed yesterday
> > to minimize rcu_dereference impact:
> >
> > >> ----- Original message  -----
> > >> From: Herbert Xu <herbert@gondor.apana.org.au>
> > >> Date: Fri, 30 Sep 2005 11:19:07 +1000
> > >> 
> > >> On Thu, Sep 29, 2005 at 06:16:03PM -0700, Paul E. McKenney wrote:
> > >>> 
> > >>> OK, how about this instead?
> > >>> 
> > >>> rcu_read_lock();
> > >>> in_dev = dev->ip_ptr;
> > >>> if (in_dev) {
> > >>> atomic_inc(&rcu_dereference(in_dev)->refcnt);
> > >>> }
> > >>> rcu_read_unlock();
> > >>> return in_dev;
> > >> 
> > >> Looks great. 
> > 
> > while adding a function call level by wrapping  __in_dev_get_rcu
> > with in_dev_get as suggested here.
> 
> It might look different, but it should compile to the same result.
> GCC should be smart enough to combine the two branches and produce a
> memory barrier only when in_dev is not NULL.
>  
> > The other thing I'd hoped to address in pktgen.c was 
> > removing the __in_dev_put() which decrements refcnt 
> > while __in_dev_get_rcu() does not increment.
> 
> Well spotted.
> 
> Here is a patch on top of the last one to fix this bogus decrement.

Both this and Herbert's prior patch look good to me!

							Thanx, Paul

> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
> 
> Thanks,
> -- 
> Visit Openswan at http://www.openswan.org/
> Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

> diff --git a/net/core/pktgen.c b/net/core/pktgen.c
> --- a/net/core/pktgen.c
> +++ b/net/core/pktgen.c
> @@ -1673,7 +1673,6 @@ static void pktgen_setup_inject(struct p
>  					pkt_dev->saddr_min = in_dev->ifa_list->ifa_address;
>  					pkt_dev->saddr_max = pkt_dev->saddr_min;
>  				}
> -				__in_dev_put(in_dev);	
>  			}
>  			rcu_read_unlock();
>  		}


  reply	other threads:[~2005-10-01 18:03 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-01  6:56 [RFC][PATCH] identify in_dev_get rcu read-side critical sections Suzanne Wood
2005-10-01  7:12 ` Herbert Xu
2005-10-01 18:04   ` Paul E. McKenney [this message]
  -- strict thread matches above, loose matches on Subject: below --
2005-10-01 18:37 Suzanne Wood
2005-10-01 19:29 ` Herbert Xu
2005-10-01 18:00 Suzanne Wood
2005-09-30  1:06 Suzanne Wood
2005-10-01  1:13 ` Herbert Xu
2005-09-29 23:59 Suzanne Wood
2005-09-30  0:23 ` Herbert Xu
2005-09-29 23:39 Suzanne Wood
2005-09-29 23:30 Suzanne Wood
2005-09-30  0:21 ` Herbert Xu
2005-09-30  0:23 ` Paul E. McKenney
2005-09-30  0:27   ` Herbert Xu
2005-09-30  0:36     ` Paul E. McKenney
2005-09-30  1:04       ` Herbert Xu
2005-09-30  1:16         ` Paul E. McKenney
2005-09-30  1:19           ` Herbert Xu
2005-09-29 16:02 Suzanne Wood
2005-09-29 21:28 ` Herbert Xu
2005-09-28  0:22 Suzanne Wood
2005-09-08 17:12 Suzanne Wood
2005-09-27 20:56 ` David S. Miller
2005-09-28  2:55   ` Herbert Xu
2005-09-28 14:51     ` Paul E. McKenney
2005-09-28 22:11       ` Herbert Xu

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=20051001180441.GA1578@us.ibm.com \
    --to=paulmck@us.ibm.com \
    --cc=Robert.Olsson@data.slu.se \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@oss.sgi.com \
    --cc=suzannew@cs.pdx.edu \
    --cc=walpole@cs.pdx.edu \
    /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).