[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1269893945.1958.72.camel@edumazet-laptop>
Date: Mon, 29 Mar 2010 22:19:05 +0200
From: Eric Dumazet <eric.dumazet@...il.com>
To: Paul Moore <paul.moore@...com>
Cc: paulmck@...ux.vnet.ibm.com, David Howells <dhowells@...hat.com>,
netdev@...r.kernel.org
Subject: Re: [PATCH] NETLABEL: Fix an RCU warning
Le lundi 29 mars 2010 à 16:05 -0400, Paul Moore a écrit :
> Okay, is there a recommended approach towards accessing RCU-protected pointers
> both under a RCU read lock and under only a spinlock (or similar lock
> construct)? I know I could do something based on querying the state of the
> RCU/etc. locks but that seems like a hack and could interfere with some of the
> logic used to detect coding problems.
>
Say you use a common function func1(), that use RCU protection, from a
pure reader, and from a pure writer.
pure_reader()
{
rcu_read_lock();
res = func1();
rcu_read_unlock();
}
pure_writer()
{
spin_lock(&some_lock);
res = func1();
spin_unlock(&some_lock);
}
then, func1 could use
func1()
{
..... ptr = rcu_dereference_check(xxx->ptr,
rcu_read_lock_held() ||
lockdep_is_held(&some_lock));
...
}
They are numerous examples in tree.
If some iterators use implicit rcu_dereference(), you'll probably need
to define new iterators, so that full condition can be tested.
rcu_dereference() is a shorthand for
rcu_dereference_check(p, rcu_read_lock_held())
This only deals for pure readers, not potential pure writer :)
--
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