From: "Paul E. McKenney" <paulmck@us.ibm.com>
To: Suzanne Wood <suzannew@cs.pdx.edu>
Cc: herbert@gondor.apana.org.au, 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: Thu, 29 Sep 2005 17:23:46 -0700 [thread overview]
Message-ID: <20050930002346.GP8177@us.ibm.com> (raw)
In-Reply-To: <200509292330.j8TNUSmH019572@rastaban.cs.pdx.edu>
On Thu, Sep 29, 2005 at 04:30:28PM -0700, Suzanne Wood wrote:
> > Date: Fri, 30 Sep 2005 07:28:36 +1000
> > From: Herbert Xu <herbert@gondor.apana.org.au>
>
> > On Thu, Sep 29, 2005 at 09:02:29AM -0700, Suzanne Wood wrote:
> > >
> > > The exchange below suggests that it is equally important
> > > to have the rcu_dereference() in __in_dev_get(), so the
> > > idea of the only difference between in_dev_get and
> > > __in_dev_get being the refcnt may be accepted.
>
> > With __in_dev_get() it's the caller's responsibility to ensure
> > that RCU works correctly. Therefore if any rcu_dereference is
> > needed it should be done by the caller.
>
> This sounds reasonable to me. Does everyone agree?
Is there any case where __in_dev_get() might be called without
needing to be wrapped with rcu_dereference()? If so, then I
agree (FWIW, given my meagre knowledge of Linux networking).
If all __in_dev_get() invocations need to be wrapped in
rcu_dereference(), then it seems to me that there would be
motivation to bury rcu_dereference() in __in_dev_get().
> > Some callers of __in_dev_get() don't need rcu_dereference at all
> > because they're protected by the rtnl.
>
> > BTW, could you please move the rcu_dereference in in_dev_get()
> > into the if clause? The barrier is not needed when ip_ptr is
> > NULL.
>
> The trouble with that may be that there are three events, the
> dereference, the assignment, and the conditional test. The
> rcu_dereference() is meant to assure deferred destruction
> throughout.
One only needs an rcu_dereference() once on the data-flow path from
fetching the RCU-protected pointer to dereferencing that pointer.
If the pointer is NULL, there is no way you can dereference it,
so, technically, Herbert is quite correct.
However, rcu_dereference() only generates a memory barrier on DEC
Alpha, so there is normally no penalty for using it in the NULL-pointer
case. So, when using rcu_dereference() unconditionally simplifies
the code, it may make sense to "just do it".
Thanx, Paul
next prev parent reply other threads:[~2005-09-30 0:23 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-29 23:30 [RFC][PATCH] identify in_dev_get rcu read-side critical sections Suzanne Wood
2005-09-30 0:21 ` Herbert Xu
2005-09-30 0:23 ` Paul E. McKenney [this message]
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
-- 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-10-01 6:56 Suzanne Wood
2005-10-01 7:12 ` Herbert Xu
2005-10-01 18:04 ` Paul E. McKenney
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 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=20050930002346.GP8177@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).