diff options
author | Matthew Wilcox <willy@linux.intel.com> | 2016-12-14 18:08:40 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-12-14 19:04:10 -0500 |
commit | bc412fca6edc25bbbe28b6449512e15ebb1573ae (patch) | |
tree | f03aa2b485b88b3510f3a97a67c35c66b7df3611 | |
parent | 9498d2bb34b0866829c313569df35e77a83f12eb (diff) |
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.com
Signed-off-by: Matthew Wilcox <willy@infradead.org>
Tested-by: Kirill 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | lib/radix-tree.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/radix-tree.c b/lib/radix-tree.c index a90a4371deb8..368052ac468a 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c | |||
@@ -191,13 +191,12 @@ static inline int any_tag_set(struct radix_tree_node *node, unsigned int tag) | |||
191 | * Returns next bit offset, or size if nothing found. | 191 | * Returns next bit offset, or size if nothing found. |
192 | */ | 192 | */ |
193 | static __always_inline unsigned long | 193 | static __always_inline unsigned long |
194 | radix_tree_find_next_bit(const unsigned long *addr, | 194 | radix_tree_find_next_bit(struct radix_tree_node *node, unsigned int tag, |
195 | unsigned long size, unsigned long offset) | 195 | unsigned long offset) |
196 | { | 196 | { |
197 | if (!__builtin_constant_p(size)) | 197 | const unsigned long *addr = node->tags[tag]; |
198 | return find_next_bit(addr, size, offset); | ||
199 | 198 | ||
200 | if (offset < size) { | 199 | if (offset < RADIX_TREE_MAP_SIZE) { |
201 | unsigned long tmp; | 200 | unsigned long tmp; |
202 | 201 | ||
203 | addr += offset / BITS_PER_LONG; | 202 | addr += offset / BITS_PER_LONG; |
@@ -205,14 +204,14 @@ radix_tree_find_next_bit(const unsigned long *addr, | |||
205 | if (tmp) | 204 | if (tmp) |
206 | return __ffs(tmp) + offset; | 205 | return __ffs(tmp) + offset; |
207 | offset = (offset + BITS_PER_LONG) & ~(BITS_PER_LONG - 1); | 206 | offset = (offset + BITS_PER_LONG) & ~(BITS_PER_LONG - 1); |
208 | while (offset < size) { | 207 | while (offset < RADIX_TREE_MAP_SIZE) { |
209 | tmp = *++addr; | 208 | tmp = *++addr; |
210 | if (tmp) | 209 | if (tmp) |
211 | return __ffs(tmp) + offset; | 210 | return __ffs(tmp) + offset; |
212 | offset += BITS_PER_LONG; | 211 | offset += BITS_PER_LONG; |
213 | } | 212 | } |
214 | } | 213 | } |
215 | return size; | 214 | return RADIX_TREE_MAP_SIZE; |
216 | } | 215 | } |
217 | 216 | ||
218 | #ifndef __KERNEL__ | 217 | #ifndef __KERNEL__ |
@@ -1160,9 +1159,7 @@ void **radix_tree_next_chunk(struct radix_tree_root *root, | |||
1160 | return NULL; | 1159 | return NULL; |
1161 | 1160 | ||
1162 | if (flags & RADIX_TREE_ITER_TAGGED) | 1161 | if (flags & RADIX_TREE_ITER_TAGGED) |
1163 | offset = radix_tree_find_next_bit( | 1162 | offset = radix_tree_find_next_bit(node, tag, |
1164 | node->tags[tag], | ||
1165 | RADIX_TREE_MAP_SIZE, | ||
1166 | offset + 1); | 1163 | offset + 1); |
1167 | else | 1164 | else |
1168 | while (++offset < RADIX_TREE_MAP_SIZE) { | 1165 | while (++offset < RADIX_TREE_MAP_SIZE) { |