[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20100115155309.GF6770@linux.vnet.ibm.com>
Date: Fri, 15 Jan 2010 07:53:09 -0800
From: "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
To: Eric Dumazet <eric.dumazet@...il.com>
Cc: yoshfuji@...ux-ipv6.org, netdev@...r.kernel.org, mingo@...e.hu,
akpm@...ux-foundation.org, peterz@...radead.org
Subject: Re: What protects rcu_dereference() in __in6_dev_get()?
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
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists