From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: yoshfuji@linux-ipv6.org, netdev@vger.kernel.org, mingo@elte.hu,
akpm@linux-foundation.org, peterz@infradead.org
Subject: Re: What protects rcu_dereference() in __in6_dev_get()?
Date: Fri, 15 Jan 2010 07:53:09 -0800 [thread overview]
Message-ID: <20100115155309.GF6770@linux.vnet.ibm.com> (raw)
In-Reply-To: <4B5089CA.2050202@gmail.com>
On Fri, Jan 15, 2010 at 04:29:14PM +0100, Eric Dumazet wrote:
> Le 15/01/2010 16:15, Paul E. McKenney a écrit :
> > On Fri, Jan 15, 2010 at 06:50:15AM +0100, Eric Dumazet wrote:
> >> __in6_dev_get() is called either with rcu_read_lock()/rcu_read_unlock() protection,
> >> or with the RTNL mutex held.
> >
> > Very good! So I make a lockdep_rtnl_is_held() in net/core/rtnetlink.c:
> >
> > #ifdef CONFIG_PROVE_LOCKING
> > int lockdep_rtnl_is_held(void)
> > {
> > return lockdep_is_held(&rtnl_mutex);
> > }
> > EXPORT_SYMBOL(lockdep_rtnl_is_held);
> > #endif /* #ifdef CONFIG_PROVE_LOCKING */
> >
> > Then I make __in6_dev_get() look as follows:
> >
> > static inline struct inet6_dev *
> > __in6_dev_get(struct net_device *dev)
> > {
> > return rcu_dereference_check(dev->ip6_ptr,
> > rcu_read_lock_held() ||
> > lockdep_rtnl_is_held());
> > }
> >
> > Seem reasonable?
>
> I guess so, but is lockdep_is_held(&mutex) actually cheking this mutex is owned by us ?
Indeed it does! But only if lockdep is enabled. When lockdep is -not-
enabled, rcu_dereference_check() ignores its second argument.
> If another thread is the owner, we could miss a bug.
That s why I created a new lockdep_rtnl_is_held() rather than using the
existing rtnl_is_locked().
Thanx, Paul
prev parent reply other threads:[~2010-01-15 15:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-14 18:32 What protects rcu_dereference() in __in6_dev_get()? Paul E. McKenney
2010-01-15 5:50 ` Eric Dumazet
2010-01-15 15:15 ` Paul E. McKenney
2010-01-15 15:29 ` Eric Dumazet
2010-01-15 15:31 ` Peter Zijlstra
2010-01-15 15:53 ` Paul E. McKenney [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=20100115155309.GF6770@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=eric.dumazet@gmail.com \
--cc=mingo@elte.hu \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=yoshfuji@linux-ipv6.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).