netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Andi Kleen <andi@firstfloor.org>,
	robert.olsson@its.uu.se, netdev@vger.kernel.org
Subject: Re: RCU problems in fib_table_insert
Date: Sun, 21 Mar 2010 14:38:03 -0700	[thread overview]
Message-ID: <20100321213803.GE2517@linux.vnet.ibm.com> (raw)
In-Reply-To: <1269206752.3004.9.camel@edumazet-laptop>

On Sun, Mar 21, 2010 at 10:25:52PM +0100, Eric Dumazet wrote:
> Le dimanche 21 mars 2010 à 21:25 +0100, Andi Kleen a écrit :
> > Hi,
> > 
> > I got the following warning at boot with a 2.6.34-rc2ish git kernel
> > with RCU debugging and preemption enabled.
> > 
> > It seems the problem is that not all callers of fib_find_node
> > call it with rcu_read_lock() to stabilize access to the fib. 
> > 
> > I tried to fix it, but especially for fib_table_insert() that's rather 
> > tricky: it does a lot of memory allocations and also route flushing and 
> > other blocking operations while assuming the original fa is RCU stable.
> > 
> > I first tried to move some allocations to the beginning and keep
> > preemption disabled in the rest, but it's difficult with all of them.
> > No patch because of that.
> > 
> > Does the fa need an additional reference count for this problem?
> > Or perhaps some optimistic locking?
> > 
> > -Andi
> 
> No real changes needed, only a lockdep warning...
> 
> Probably a rcu_dereference() should be changed to
> rcu_dereference_check() like we did for __in6_dev_get()
> 
> We hold RTNL or rcu_read_lock
> 
> [PATCH] net: fib_find_node() rcu check
> 
> We hold rcu read lock or RTNL when fib_find_node() is called.
> Shutup lockdep complain.

You beat me to it, Eric.  ;-)

So:

Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

> Reported-by: Andi Kleen <andi@firstfloor.org>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> ---
> diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
> index af5d897..471fe07 100644
> --- a/net/ipv4/fib_trie.c
> +++ b/net/ipv4/fib_trie.c
> @@ -961,7 +961,8 @@ fib_find_node(struct trie *t, u32 key)
>  	struct node *n;
> 
>  	pos = 0;
> -	n = rcu_dereference(t->trie);
> +	n = rcu_dereference_check(t->trie,
> +				  rcu_read_lock_held() || lockdep_rtnl_is_held());
> 
>  	while (n != NULL &&  NODE_TYPE(n) == T_TNODE) {
>  		tn = (struct tnode *) n;
> 
> 

  reply	other threads:[~2010-03-21 21:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-21 20:25 RCU problems in fib_table_insert Andi Kleen
2010-03-21 21:25 ` Eric Dumazet
2010-03-21 21:38   ` Paul E. McKenney [this message]
2010-03-21 21:49     ` Eric Dumazet
2010-03-21 22:57       ` Paul E. McKenney
2010-03-21 21:37 ` Paul E. McKenney
2010-03-22  1:01   ` David Miller
2010-03-22  6:51     ` Paul E. McKenney
2010-03-22  6:18 ` Robert Olsson
2010-03-22  6:51   ` Paul E. McKenney
2010-04-07  6:10     ` Robert Olsson
2010-04-07  6:45       ` Paul E. McKenney

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=20100321213803.GE2517@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=andi@firstfloor.org \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=robert.olsson@its.uu.se \
    /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).