Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Paul Moore <paul.moore@hp.com>
Cc: paulmck@linux.vnet.ibm.com, David Howells <dhowells@redhat.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH] NETLABEL: Fix an RCU warning
Date: Mon, 29 Mar 2010 22:19:05 +0200	[thread overview]
Message-ID: <1269893945.1958.72.camel@edumazet-laptop> (raw)
In-Reply-To: <201003291605.48605.paul.moore@hp.com>

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 :)




      reply	other threads:[~2010-03-29 20:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-25 11:06 [PATCH] NETLABEL: Fix an RCU warning David Howells
2010-03-25 11:28 ` Eric Dumazet
2010-03-25 11:37   ` David Howells
2010-03-25 13:32     ` Eric Dumazet
2010-03-25 14:10       ` Paul Moore
2010-03-29 15:24   ` Paul E. McKenney
2010-03-29 15:30     ` Paul Moore
2010-03-29 15:58       ` Paul E. McKenney
2010-03-29 20:05         ` Paul Moore
2010-03-29 20:19           ` Eric Dumazet [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=1269893945.1958.72.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=dhowells@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=paul.moore@hp.com \
    --cc=paulmck@linux.vnet.ibm.com \
    /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