lkml.org 
[lkml]   [2008]   [Feb]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] remove rcu_assign_pointer(NULL) penalty with type/macro safety
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
--
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/

\
 
 \ /
  Last update: 2008-02-14 01:45    [W:0.066 / U:0.032 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site