All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
To: Christoph Lameter <clameter@sgi.com>
Cc: Andrew Morton <akpm@osdl.org>,
	"Paul E. McKenney" <paulmck@us.ibm.com>,
	Nick Piggin <nickpiggin@yahoo.com.au>,
	linux-mm <linux-mm@kvack.org>
Subject: Re: [PATCH] radix-tree:  fix radix_tree_replace_slot
Date: Tue, 22 Aug 2006 17:24:03 -0400	[thread overview]
Message-ID: <1156281844.5622.39.camel@localhost> (raw)
In-Reply-To: <Pine.LNX.4.64.0608221401520.25753@schroedinger.engr.sgi.com>

On Tue, 2006-08-22 at 14:06 -0700, Christoph Lameter wrote:
> On Tue, 22 Aug 2006, Lee Schermerhorn wrote:
> 
> >   * @item:	new item to store in the slot.
> > + *
> > + * For use with radix_tree_lookup_slot().  Caller must hold tree write locked
> > + * across slot lookup and replacement.
> >   */
> >  static inline void radix_tree_replace_slot(void *pslot, void *item)
> >  {
> >  	void *slot = *(void **)pslot;
> >  	BUG_ON(radix_tree_is_direct_ptr(item));
> > -	rcu_assign_pointer(slot,
> > +	rcu_assign_pointer(*(void **)pslot,
> >  		(void *)((unsigned long)item |
> >  			((unsigned long)slot & RADIX_TREE_DIRECT_PTR)));
>                                         ^^^^ Is this a legit use of slot?
> 
> >  }
> > 
> 
> Would it not be better to change the calling conventions of 
> radix_tree_replace_slot? It should get passsed a void **pslot right?
> 
> static inline void radix_tree_replace_slot(void **pslot, void *item)
> {
> 	BUG_ON(radix_tree_is_direct_ptr(item));
> 	rcu_assign_pointer(*pslot,
> 		(void *)((unsigned long)item |
> 			((unsigned long)*pslot & RADIX_TREE_DIRECT_PTR)));
> }
> 

I did consider that, and I looked at where the value of pslot came from
[radix_tree_lookup_slot()] and all of the casts and other uses of that
value.  I decided to limit the change to the one line that I submitted.
I don't actually recall my reasoning now.  Probably to maintain the
symmetry of _deref_slot() and _replace_slot().

Your suggestion certainly looks cleaner.  Could/should also change
_deref_slot()'s arg to 'void **pslot' and save a cast?

Lee

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2006-08-22 21:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-22 20:25 [PATCH] radix-tree: fix radix_tree_replace_slot Lee Schermerhorn
2006-08-22 21:06 ` Christoph Lameter
2006-08-22 21:24   ` Lee Schermerhorn [this message]
2006-08-24  2:36 ` Nick Piggin
2006-08-24  5:05 ` 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=1156281844.5622.39.camel@localhost \
    --to=lee.schermerhorn@hp.com \
    --cc=akpm@osdl.org \
    --cc=clameter@sgi.com \
    --cc=linux-mm@kvack.org \
    --cc=nickpiggin@yahoo.com.au \
    --cc=paulmck@us.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.