Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934841AbYBNBiF (ORCPT ); Wed, 13 Feb 2008 20:38:05 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1761330AbYBNBhs (ORCPT ); Wed, 13 Feb 2008 20:37:48 -0500 Received: from mail.vyatta.com ([216.93.170.194]:40254 "EHLO mail.vyatta.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758073AbYBNBhq (ORCPT ); Wed, 13 Feb 2008 20:37:46 -0500 X-Spam-Flag: NO X-Spam-Score: -2.25 Date: Wed, 13 Feb 2008 17:37:39 -0800 From: Stephen Hemminger To: paulmck@linux.vnet.ibm.com Cc: Stephen Hemminger <"stephen.hemminger@vyatta.com"@mail.vyatta.com>, linux-kernel@vger.kernel.org, davem@davemloft.net, netdev@vger.kernel.org, dipankar@in.ibm.com, ego@in.ibm.com, herbert@gondor.apana.org.au, akpm@linux-foundation.org Subject: Re: [PATCH 1/2] remove rcu_assign_pointer(NULL) penalty with type/macro safety Message-ID: <20080213173739.1823ac4f@extreme> In-Reply-To: <20080214013427.GT12393@linux.vnet.ibm.com> References: <20080213220024.GA30729@linux.vnet.ibm.com> <20080213143537.1b806790@extreme> <20080213224134.GK12393@linux.vnet.ibm.com> <20080213144233.05e860cb@extreme> <20080213233744.GO12393@linux.vnet.ibm.com> <20080213155158.1b621359@extreme> <20080214001404.GQ12393@linux.vnet.ibm.com> <20080213162700.0a32000d@extreme> <20080214004253.GR12393@linux.vnet.ibm.com> <20080213165356.11d02092@extreme> <20080214013427.GT12393@linux.vnet.ibm.com> Organization: Vyatta X-Mailer: Claws Mail 3.3.0 (GTK+ 2.12.8; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2622 Lines: 68 On Wed, 13 Feb 2008 17:34:27 -0800 "Paul E. McKenney" wrote: > On Wed, Feb 13, 2008 at 04:53:56PM -0800, Stephen Hemminger wrote: > > On Wed, 13 Feb 2008 16:42:53 -0800 > > "Paul E. McKenney" wrote: > > > On Wed, Feb 13, 2008 at 04:27:00PM -0800, Stephen Hemminger wrote: > > [ . . . ] > > > > > That is heading towards ugly... Maybe not using the macro at all (for this case) would be best: > > > > > > > > static inline void node_set_parent(struct node *node, struct tnode *ptr) > > > > { > > > > smp_wmb(); > > > > node->parent = (unsigned long)ptr | NODE_TYPE(node); > > > > } > > > > > > Or, alternatively, the rcu_assign_index() patch sent earlier to avoid > > > the bare memory barrier? > > > > > > Thanx, Paul > > > > I am fine with rcu_assign_index(), and add a comment in node_set_parent. > > OK, how about the following? > > Signed-off-by: Paul E. McKenney > --- > > fib_trie.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff -urpNa -X dontdiff linux-2.6.25-rc1/net/ipv4/fib_trie.c linux-2.6.25-rc1-fib_trie-warn.compile/net/ipv4/fib_trie.c > --- linux-2.6.25-rc1/net/ipv4/fib_trie.c 2008-02-13 14:38:12.000000000 -0800 > +++ linux-2.6.25-rc1-fib_trie-warn.compile/net/ipv4/fib_trie.c 2008-02-13 17:31:16.000000000 -0800 > @@ -96,6 +96,14 @@ typedef unsigned int t_key; > #define IS_TNODE(n) (!(n->parent & T_LEAF)) > #define IS_LEAF(n) (n->parent & T_LEAF) > > +/* > + * The "parent" fields in struct node and struct leaf are really pointers, > + * but with the possibility that the T_LEAF bit is set. Therefore, both > + * the C compiler and RCU see them as integers rather than pointers. > + * This in turn means that rcu_assign_index() must be used to assign > + * values to these fields, rather than the usual rcu_assign_pointer(). > + */ > + > struct node { > unsigned long parent; > t_key key; > @@ -179,8 +187,7 @@ static inline struct tnode *node_parent_ > > static inline void node_set_parent(struct node *node, struct tnode *ptr) > { > - rcu_assign_pointer(node->parent, > - (unsigned long)ptr | NODE_TYPE(node)); > + rcu_assign_index(node->parent, (unsigned long)ptr | NODE_TYPE(node)); > } > > static inline struct node *tnode_get_child(struct tnode *tn, unsigned int i) Yes, thats great. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/