From: Lee Schermerhorn Adopt Christoph's suggestion to change calling conventions of radix_tree_replace_slot(). Make similar change to radix_tree_defer_slot(). Both now take a 'void **pslot' argument. Not only does this simplify the code of these two functions, but the arg type now matches the return type of radix_tree_lookup_slot(). Tested with reverted page migration, but I don't know that I was exercising any direct pointers. Note: this will require changes to migrate_page_move_mapping() to avoid compiler warnings if/when we back out the work around patch for the problem in '_replace_slot() fixed by a prior patch. The migrate code is [will then be] the only user of the direct slot replacement APIs. Also, fix '_deref_slot() and '_lookup_slot() return comments for Randy. Signed-off-by: Lee Schermerhorn Cc: Nick Piggin Signed-off-by: Andrew Morton --- include/linux/radix-tree.h | 14 ++++++-------- lib/radix-tree.c | 4 ++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff -puN include/linux/radix-tree.h~cleanup-radix_tree_derefreplace_slot-calling-conventions include/linux/radix-tree.h --- a/include/linux/radix-tree.h~cleanup-radix_tree_derefreplace_slot-calling-conventions +++ a/include/linux/radix-tree.h @@ -122,17 +122,16 @@ do { \ /** * radix_tree_deref_slot - dereference a slot * @pslot: pointer to slot, returned by radix_tree_lookup_slot - * @returns: item that was stored in that slot with any direct pointer flag + * Returns: item that was stored in that slot with any direct pointer flag * removed. * * For use with radix_tree_lookup_slot(). Caller must hold tree at least read * locked across slot lookup and dereference. More likely, will be used with * radix_tree_replace_slot(), as well, so caller will hold tree write locked. */ -static inline void *radix_tree_deref_slot(void *pslot) +static inline void *radix_tree_deref_slot(void **pslot) { - void *slot = *(void **)pslot; - return radix_tree_direct_to_ptr(slot); + return radix_tree_direct_to_ptr(*pslot); } /** * radix_tree_replace_slot - replace item in a slot @@ -142,13 +141,12 @@ static inline void *radix_tree_deref_slo * 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) +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(*(void **)pslot, + rcu_assign_pointer(*pslot, (void *)((unsigned long)item | - ((unsigned long)slot & RADIX_TREE_DIRECT_PTR))); + ((unsigned long)*pslot & RADIX_TREE_DIRECT_PTR))); } int radix_tree_insert(struct radix_tree_root *, unsigned long, void *); diff -puN lib/radix-tree.c~cleanup-radix_tree_derefreplace_slot-calling-conventions lib/radix-tree.c --- a/lib/radix-tree.c~cleanup-radix_tree_derefreplace_slot-calling-conventions +++ a/lib/radix-tree.c @@ -331,8 +331,8 @@ EXPORT_SYMBOL(radix_tree_insert); * @root: radix tree root * @index: index key * - * Lookup the slot corresponding to the position @index in the radix tree - * @root. This is useful for update-if-exists operations. + * Returns: the slot corresponding to the position @index in the + * radix tree @root. This is useful for update-if-exists operations. * * This function cannot be called under rcu_read_lock, it must be * excluded from writers, as must the returned slot for subsequent _