The patch titled radixtree: introduce __radix_tree_lookup_parent() has been added to the -mm tree. Its filename is radixtree-introduce-__radix_tree_lookup_parent.patch See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this ------------------------------------------------------ Subject: radixtree: introduce __radix_tree_lookup_parent() From: Wu Fengguang <wfg@xxxxxxxxxxxxxxxx> Introduce a general lookup function to radix tree. - __radix_tree_lookup_parent(root, index, level) Perform partial lookup, return the @level'th parent of the slot at @index. Signed-off-by: Wu Fengguang <wfg@xxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- include/linux/radix-tree.h | 16 +++++++++ lib/radix-tree.c | 58 +++++++++++++++++------------------ 2 files changed, 44 insertions(+), 30 deletions(-) diff -puN include/linux/radix-tree.h~radixtree-introduce-__radix_tree_lookup_parent include/linux/radix-tree.h --- 25/include/linux/radix-tree.h~radixtree-introduce-__radix_tree_lookup_parent Fri May 26 13:33:44 2006 +++ 25-akpm/include/linux/radix-tree.h Fri May 26 13:33:44 2006 @@ -49,7 +49,8 @@ do { \ } while (0) int radix_tree_insert(struct radix_tree_root *, unsigned long, void *); -void *radix_tree_lookup(struct radix_tree_root *, unsigned long); +void *__radix_tree_lookup_parent(struct radix_tree_root *, + unsigned long, unsigned int); void **radix_tree_lookup_slot(struct radix_tree_root *, unsigned long); void *radix_tree_delete(struct radix_tree_root *, unsigned long); unsigned int @@ -74,4 +75,17 @@ static inline void radix_tree_preload_en preempt_enable(); } +/** + * radix_tree_lookup - perform lookup operation on a radix tree + * @root: radix tree root + * @index: index key + * + * Lookup the item at the position @index in the radix tree @root. + */ +static inline void *radix_tree_lookup(struct radix_tree_root *root, + unsigned long index) +{ + return __radix_tree_lookup_parent(root, index, 0); +} + #endif /* _LINUX_RADIX_TREE_H */ diff -puN lib/radix-tree.c~radixtree-introduce-__radix_tree_lookup_parent lib/radix-tree.c --- 25/lib/radix-tree.c~radixtree-introduce-__radix_tree_lookup_parent Fri May 26 13:33:44 2006 +++ 25-akpm/lib/radix-tree.c Fri May 26 13:33:44 2006 @@ -308,36 +308,46 @@ int radix_tree_insert(struct radix_tree_ } EXPORT_SYMBOL(radix_tree_insert); -static inline void **__lookup_slot(struct radix_tree_root *root, - unsigned long index) +/** + * __radix_tree_lookup_parent - low level lookup routine + * @root: radix tree root + * @index: index key + * @level: stop at that many levels from the tree leaf + * + * Lookup the @level'th parent of the slot at @index in radix tree @root. + * The return value is: + * @level == 0: page at @index; + * @level == 1: the corresponding bottom level tree node; + * @level < height: (@level-1)th parent node of the bottom node + * that contains @index; + * @level >= height: the root node. + */ +void *__radix_tree_lookup_parent(struct radix_tree_root *root, + unsigned long index, unsigned int level) { unsigned int height, shift; - struct radix_tree_node **slot; + struct radix_tree_node *slot; height = root->height; if (index > radix_tree_maxindex(height)) return NULL; - if (height == 0 && root->rnode) - return (void **)&root->rnode; - shift = (height-1) * RADIX_TREE_MAP_SHIFT; - slot = &root->rnode; + slot = root->rnode; - while (height > 0) { - if (*slot == NULL) + while (height > level) { + if (slot == NULL) return NULL; - slot = (struct radix_tree_node **) - ((*slot)->slots + - ((index >> shift) & RADIX_TREE_MAP_MASK)); + slot = slot->slots[(index >> shift) & RADIX_TREE_MAP_MASK]; shift -= RADIX_TREE_MAP_SHIFT; height--; } - return (void **)slot; + return slot; } +EXPORT_SYMBOL(__radix_tree_lookup_parent); /** * radix_tree_lookup_slot - lookup a slot in a radix tree @@ -349,25 +359,15 @@ static inline void **__lookup_slot(struc */ void **radix_tree_lookup_slot(struct radix_tree_root *root, unsigned long index) { - return __lookup_slot(root, index); -} -EXPORT_SYMBOL(radix_tree_lookup_slot); + struct radix_tree_node *node; -/** - * radix_tree_lookup - perform lookup operation on a radix tree - * @root: radix tree root - * @index: index key - * - * Lookup the item at the position @index in the radix tree @root. - */ -void *radix_tree_lookup(struct radix_tree_root *root, unsigned long index) -{ - void **slot; + if (root->height == 0) + return &root->rnode; - slot = __lookup_slot(root, index); - return slot != NULL ? *slot : NULL; + node = __radix_tree_lookup_parent(root, index, 1); + return node ? node->slots + (index & RADIX_TREE_MAP_MASK) : NULL; } -EXPORT_SYMBOL(radix_tree_lookup); +EXPORT_SYMBOL(radix_tree_lookup_slot); /** * radix_tree_tag_set - set a tag on a radix tree node _ Patches currently in -mm which might be from wfg@xxxxxxxxxxxxxxxx are readahead-kconfig-options.patch radixtree-introduce-__radix_tree_lookup_parent.patch radixtree-introduce-radix_tree_scan_hole.patch mm-introduce-probe_pages.patch mm-introduce-pg_readahead.patch readahead-add-look-ahead-support-to-__do_page_cache_readahead.patch readahead-delay-page-release-in-do_generic_mapping_read.patch readahead-insert-cond_resched-calls.patch readahead-minmax_ra_pages.patch readahead-events-accounting.patch readahead-rescue_pages.patch readahead-sysctl-parameters.patch readahead-min-max-sizes.patch readahead-state-based-method-aging-accounting.patch readahead-state-based-method-routines.patch readahead-state-based-method.patch readahead-context-based-method.patch readahead-initial-method-guiding-sizes.patch readahead-initial-method-thrashing-guard-size.patch readahead-initial-method-expected-read-size.patch readahead-initial-method-user-recommended-size.patch readahead-initial-method.patch readahead-backward-prefetching-method.patch readahead-seeking-reads-method.patch readahead-thrashing-recovery-method.patch readahead-call-scheme.patch readahead-laptop-mode.patch readahead-loop-case.patch readahead-nfsd-case.patch readahead-turn-on-by-default.patch readahead-debug-radix-tree-new-functions.patch readahead-debug-traces-showing-accessed-file-names.patch readahead-debug-traces-showing-read-patterns.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html