LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
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
Date: Wed, 13 Feb 2008 16:53:56 -0800	[thread overview]
Message-ID: <20080213165356.11d02092@extreme> (raw)
In-Reply-To: <20080214004253.GR12393@linux.vnet.ibm.com>

On Wed, 13 Feb 2008 16:42:53 -0800
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com> wrote:

> On Wed, Feb 13, 2008 at 04:27:00PM -0800, Stephen Hemminger wrote:
> > On Wed, 13 Feb 2008 16:14:04 -0800
> > "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> wrote:
> > > On Wed, Feb 13, 2008 at 03:51:58PM -0800, Stephen Hemminger wrote:
> 
> [ . . . ]
> 
> > > > Maybe cast both sides to void * in this case:
> > > > 
> > > > static inline void node_set_parent(struct node *node, struct tnode *ptr)
> > > > {
> > > >  	rcu_assign_pointer((void *) node->parent, (void *)((unsigned long)ptr | NODE_TYPE(node)));
> > > > }
> > > 
> > > That gets me the following:
> > > 
> > > 	net/ipv4/fib_trie.c: In function ‘node_set_parent’:
> > > 	net/ipv4/fib_trie.c:182: error: invalid lvalue in assignment
> > > 
> > > However, as with much in computing, an extra level of indirection fixes
> > > things.  Your call as to whether or not the cure is preferable to the
> > > disease.  ;-)
> > > 
> > > Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> > > ---
> > > 
> > >  fib_trie.c |    4 ++--
> > >  1 file changed, 2 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 16:10:07.000000000 -0800
> > > @@ -179,8 +179,8 @@ 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_pointer((*(void **)&node->parent),
> > > +			   (void *)((unsigned long)ptr | NODE_TYPE(node)));
> > >  }
> > 
> > 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.

  reply	other threads:[~2008-02-14  0:54 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-13 22:00 [PATCH 1/2] remove rcu_assign_pointer(NULL) penalty with type/macro safety Paul E. McKenney
2008-02-13 22:05 ` [PATCH 2/2] add rcu_assign_index() if ever needed Paul E. McKenney
2008-02-14  3:32   ` Gautham R Shenoy
2008-02-14  3:41     ` Andrew Morton
2008-02-14 17:08     ` Paul E. McKenney
2008-02-14 17:24   ` Randy Dunlap
2008-02-14 18:48     ` Paul E. McKenney
2008-02-13 22:11 ` [PATCH 1/2] remove rcu_assign_pointer(NULL) penalty with type/macro safety Andrew Morton
     [not found] ` <20080213143537.1b806790@extreme>
2008-02-13 22:41   ` Paul E. McKenney
     [not found]     ` <20080213144233.05e860cb@extreme>
2008-02-13 23:37       ` Paul E. McKenney
2008-02-13 23:51         ` Stephen Hemminger
2008-02-14  0:14           ` Paul E. McKenney
2008-02-14  0:27             ` Stephen Hemminger
2008-02-14  0:42               ` Paul E. McKenney
2008-02-14  0:53                 ` Stephen Hemminger [this message]
2008-02-14  1:34                   ` Paul E. McKenney
2008-02-14  1:37                     ` Stephen Hemminger
2008-02-13 23:52         ` Andrew Morton
2008-02-13 23:55           ` Stephen Hemminger
2008-02-13 23:57           ` David Miller
2008-02-14  0:09             ` Andrew Morton
2008-02-16  0:40 ` Andrew Morton
2008-02-16  1:23   ` 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=20080213165356.11d02092@extreme \
    --to=shemminger@vyatta.com \
    --cc="stephen.hemminger@vyatta.com"@mail.vyatta.com \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=dipankar@in.ibm.com \
    --cc=ego@in.ibm.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).