mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] lib/radix-tree.c: use generic find_next_bit()
@ 2020-01-04  4:24 Yury Norov
  0 siblings, 0 replies; only message in thread
From: Yury Norov @ 2020-01-04  4:24 UTC (permalink / raw)
  To: Richard Fontana, Allison Randal, Greg Kroah-Hartman,
	Matthew Wilcox (Oracle),
	Armijn Hemel, Yury Norov, Thomas Gleixner, linux-kernel

lib/radix-tree.c has its own version of find_next_bit(). This patch
switches it to generic one.

Testing with tools/testing/radix-tree shows no significant difference.

Before:
$ time ./main
random seed 1578108797
running tests
XArray: 21151073 of 21151073 tests passed
vvv Ignore these warnings
assertion failed at idr.c:269
assertion failed at idr.c:206
^^^ Warnings over
IDA: 39122827 of 39122827 tests passed
tests completed

real	1m28.290s
user	2m29.610s
sys	0m32.256s
yury:radix-tree$ mutt
4440 kept, 0 deleted.

After:
$ time ./main
random seed 1578108654
running tests
XArray: 21151073 of 21151073 tests passed
qvvv Ignore these warnings
assertion failed at idr.c:269
assertion failed at idr.c:206
^^^ Warnings over
IDA: 40991309 of 40991309 tests passed
tests completed

real	1m29.035s
user	2m31.481s
sys	0m33.006s

Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
 lib/radix-tree.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)

diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index c8fa1d2745302..23f86281133da 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -189,24 +189,7 @@ static __always_inline unsigned long
 radix_tree_find_next_bit(struct radix_tree_node *node, unsigned int tag,
 			 unsigned long offset)
 {
-	const unsigned long *addr = node->tags[tag];
-
-	if (offset < RADIX_TREE_MAP_SIZE) {
-		unsigned long tmp;
-
-		addr += offset / BITS_PER_LONG;
-		tmp = *addr >> (offset % BITS_PER_LONG);
-		if (tmp)
-			return __ffs(tmp) + offset;
-		offset = (offset + BITS_PER_LONG) & ~(BITS_PER_LONG - 1);
-		while (offset < RADIX_TREE_MAP_SIZE) {
-			tmp = *++addr;
-			if (tmp)
-				return __ffs(tmp) + offset;
-			offset += BITS_PER_LONG;
-		}
-	}
-	return RADIX_TREE_MAP_SIZE;
+	return find_next_bit(node->tags[tag], RADIX_TREE_MAP_SIZE, offset);
 }
 
 static unsigned int iter_offset(const struct radix_tree_iter *iter)
-- 
2.20.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-01-04  4:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-04  4:24 [PATCH] lib/radix-tree.c: use generic find_next_bit() Yury Norov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®