From patchwork Mon Jun 15 16:08:01 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarek Poplawski X-Patchwork-Id: 28699 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 7DAE7B712C for ; Tue, 16 Jun 2009 02:08:35 +1000 (EST) Received: by ozlabs.org (Postfix) id 636EEDDDA1; Tue, 16 Jun 2009 02:08:35 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 0350CDDDA0 for ; Tue, 16 Jun 2009 02:08:34 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754627AbZFOQIY (ORCPT ); Mon, 15 Jun 2009 12:08:24 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752096AbZFOQIY (ORCPT ); Mon, 15 Jun 2009 12:08:24 -0400 Received: from mail-fx0-f211.google.com ([209.85.220.211]:36200 "EHLO mail-fx0-f211.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751111AbZFOQIX (ORCPT ); Mon, 15 Jun 2009 12:08:23 -0400 Received: by fxm7 with SMTP id 7so13015fxm.37 for ; Mon, 15 Jun 2009 09:08:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=LCbRzqC9CRmuwVDzLmcPq6fE6+gV3C7bAFWFoyzsvs4=; b=wEIXd9duU9XgezKjjijj+5BaWc8evx6erbL8LbHxs07YCAzSgPWogBLX9/SKcdP+IM i2N5QK0zQ5sBcpIS2FaM3C3bbcpLq/x+2CKALQoG8ovCGH/ujMdicKzWCYNllDLuVFkr nlcV3/OGx0lTblmU5/16abvWWPiFqJJbkeIQs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:in-reply-to:user-agent; b=I6EqgYECN1n58wlisOHvyJmqHRvVdhdDTzoPAi2IGdxZFSEiZ3vnQg0zzyF8QOPZ9G I8VAR/KsznAqWyMPsWnfUNwgl4FTlTMQXx0yMDVXfQQGzRlWxt3eU6//2GVe2x/cgJlQ AMc10t0nCNuX58N7wBpBrldrC6KUJa8btLQHY= Received: by 10.204.117.203 with SMTP id s11mr7179837bkq.153.1245082103961; Mon, 15 Jun 2009 09:08:23 -0700 (PDT) Received: from ami.dom.local ([79.162.131.0]) by mx.google.com with ESMTPS id p17sm8123357fka.12.2009.06.15.09.08.21 (version=SSLv3 cipher=RC4-MD5); Mon, 15 Jun 2009 09:08:22 -0700 (PDT) Date: Mon, 15 Jun 2009 18:08:01 +0200 From: Jarek Poplawski To: David Miller Cc: Robert Olsson , Yan Zheng , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 2/1 v2] Re: [BUG] fib_tries related Oops in 2.6.30 Message-ID: <20090615160800.GC2767@ami.dom.local> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20090615065333.GA4378@ff.dom.local> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Alas this top tnode needs even more. Sorry/thanks, Jarek P. -------------------> take 2 ipv4: Fix fib_trie rebalancing, part 2 My previous patch, which explicitly delays freeing of tnodes by adding them to the list to flush them after the update is finished, isn't strict enough. It treats exceptionally tnodes without parent, assuming they are newly created, so "invisible" for the read side yet. But the top tnode doesn't have parent as well, so we have to exclude all exceptions (at least until a better way is found). Additionally we need to move rcu assignment of this node before flushing, so the return type of the trie_rebalance() function is changed. Reported-by: Yan Zheng Signed-off-by: Jarek Poplawski --- net/ipv4/fib_trie.c | 23 ++++++++++------------- 1 files changed, 10 insertions(+), 13 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index d1a39b1..6188043 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c @@ -391,13 +391,8 @@ static inline void tnode_free(struct tnode *tn) static void tnode_free_safe(struct tnode *tn) { BUG_ON(IS_LEAF(tn)); - - if (node_parent((struct node *) tn)) { - tn->tnode_free = tnode_free_head; - tnode_free_head = tn; - } else { - tnode_free(tn); - } + tn->tnode_free = tnode_free_head; + tnode_free_head = tn; } static void tnode_free_flush(void) @@ -1009,7 +1004,7 @@ fib_find_node(struct trie *t, u32 key) return NULL; } -static struct node *trie_rebalance(struct trie *t, struct tnode *tn) +static void trie_rebalance(struct trie *t, struct tnode *tn) { int wasfull; t_key cindex, key; @@ -1033,12 +1028,14 @@ static struct node *trie_rebalance(struct trie *t, struct tnode *tn) } /* Handle last (top) tnode */ - if (IS_TNODE(tn)) { + if (IS_TNODE(tn)) tn = (struct tnode *)resize(t, (struct tnode *)tn); + + rcu_assign_pointer(t->trie, (struct node *)tn); + if (IS_TNODE(tn)) tnode_free_flush(); - } - return (struct node *)tn; + return; } /* only used from updater-side */ @@ -1186,7 +1183,7 @@ static struct list_head *fib_insert_node(struct trie *t, u32 key, int plen) /* Rebalance the trie */ - rcu_assign_pointer(t->trie, trie_rebalance(t, tp)); + trie_rebalance(t, tp); done: return fa_head; } @@ -1605,7 +1602,7 @@ static void trie_leaf_remove(struct trie *t, struct leaf *l) if (tp) { t_key cindex = tkey_extract_bits(l->key, tp->pos, tp->bits); put_child(t, (struct tnode *)tp, cindex, NULL); - rcu_assign_pointer(t->trie, trie_rebalance(t, tp)); + trie_rebalance(t, tp); } else rcu_assign_pointer(t->trie, NULL);