提交 bc412fca 编写于 作者: M Matthew Wilcox 提交者: Linus Torvalds

radix-tree: make radix_tree_find_next_bit more useful

Since this function is specialised to the radix tree, pass in the node
and tag to calculate the address of the bitmap in
radix_tree_find_next_bit() instead of the caller.  Likewise, there is no
need to pass in the size of the bitmap.

Link: http://lkml.kernel.org/r/1480369871-5271-52-git-send-email-mawilcox@linuxonhyperv.comSigned-off-by: NMatthew Wilcox <willy@infradead.org>
Tested-by: NKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Konstantin Khlebnikov <koct9i@gmail.com>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
Cc: Matthew Wilcox <mawilcox@microsoft.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 9498d2bb
...@@ -191,13 +191,12 @@ static inline int any_tag_set(struct radix_tree_node *node, unsigned int tag) ...@@ -191,13 +191,12 @@ static inline int any_tag_set(struct radix_tree_node *node, unsigned int tag)
* Returns next bit offset, or size if nothing found. * Returns next bit offset, or size if nothing found.
*/ */
static __always_inline unsigned long static __always_inline unsigned long
radix_tree_find_next_bit(const unsigned long *addr, radix_tree_find_next_bit(struct radix_tree_node *node, unsigned int tag,
unsigned long size, unsigned long offset) unsigned long offset)
{ {
if (!__builtin_constant_p(size)) const unsigned long *addr = node->tags[tag];
return find_next_bit(addr, size, offset);
if (offset < size) { if (offset < RADIX_TREE_MAP_SIZE) {
unsigned long tmp; unsigned long tmp;
addr += offset / BITS_PER_LONG; addr += offset / BITS_PER_LONG;
...@@ -205,14 +204,14 @@ radix_tree_find_next_bit(const unsigned long *addr, ...@@ -205,14 +204,14 @@ radix_tree_find_next_bit(const unsigned long *addr,
if (tmp) if (tmp)
return __ffs(tmp) + offset; return __ffs(tmp) + offset;
offset = (offset + BITS_PER_LONG) & ~(BITS_PER_LONG - 1); offset = (offset + BITS_PER_LONG) & ~(BITS_PER_LONG - 1);
while (offset < size) { while (offset < RADIX_TREE_MAP_SIZE) {
tmp = *++addr; tmp = *++addr;
if (tmp) if (tmp)
return __ffs(tmp) + offset; return __ffs(tmp) + offset;
offset += BITS_PER_LONG; offset += BITS_PER_LONG;
} }
} }
return size; return RADIX_TREE_MAP_SIZE;
} }
#ifndef __KERNEL__ #ifndef __KERNEL__
...@@ -1160,9 +1159,7 @@ void **radix_tree_next_chunk(struct radix_tree_root *root, ...@@ -1160,9 +1159,7 @@ void **radix_tree_next_chunk(struct radix_tree_root *root,
return NULL; return NULL;
if (flags & RADIX_TREE_ITER_TAGGED) if (flags & RADIX_TREE_ITER_TAGGED)
offset = radix_tree_find_next_bit( offset = radix_tree_find_next_bit(node, tag,
node->tags[tag],
RADIX_TREE_MAP_SIZE,
offset + 1); offset + 1);
else else
while (++offset < RADIX_TREE_MAP_SIZE) { while (++offset < RADIX_TREE_MAP_SIZE) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册