From edfca254378e729035073af6ac0d9156565afebe Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 12 Jul 2018 08:33:14 -0600 Subject: [PATCH] axmap: optimize ulog64 usage in axmap_handler() We can do this incrementally, no need to compute from scratch for every iteration. Signed-off-by: Jens Axboe --- lib/axmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/axmap.c b/lib/axmap.c index 4047f236..454af0b9 100644 --- a/lib/axmap.c +++ b/lib/axmap.c @@ -156,10 +156,10 @@ static bool axmap_handler(struct axmap *axmap, uint64_t bit_nr, void *), void *data) { struct axmap_level *al; + uint64_t index = bit_nr; int i; for (i = 0; i < axmap->nr_levels; i++) { - unsigned long index = ulog64(bit_nr, i); unsigned long offset = index >> UNIT_SHIFT; unsigned int bit = index & BLOCKS_PER_UNIT_MASK; @@ -167,6 +167,9 @@ static bool axmap_handler(struct axmap *axmap, uint64_t bit_nr, if (func(al, offset, bit, data)) return true; + + if (index) + index >>= UNIT_SHIFT; } return false; -- 2.25.1