[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230720094555.1397621-4-chengming.zhou@linux.dev>
Date: Thu, 20 Jul 2023 17:45:52 +0800
From: chengming.zhou@...ux.dev
To: axboe@...nel.dk, osandov@...com, ming.lei@...hat.com,
kbusch@...nel.org, krisman@...e.de
Cc: linux-kernel@...r.kernel.org, linux-block@...r.kernel.org,
zhouchengming@...edance.com
Subject: [PATCH 3/6] sbitmap: don't loop twice in find_next_zero_bit()
From: Chengming Zhou <zhouchengming@...edance.com>
__sbitmap_get_shallow() try to allocate a free bit with a limited depth,
which always wrap when finding a free bit in the word, even in the
round-robin case. So it seems we don't need strict round-robin here.
This way will loop twice in find_next_zero_bit() in the word, no point
in looping twice in find_next_zero_bit() if we don't want strict
round-robin for this case.
Signed-off-by: Chengming Zhou <zhouchengming@...edance.com>
---
lib/sbitmap.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/sbitmap.c b/lib/sbitmap.c
index ccb96d1f92ba..0f3943bd3940 100644
--- a/lib/sbitmap.c
+++ b/lib/sbitmap.c
@@ -268,7 +268,9 @@ static int __sbitmap_get_shallow(struct sbitmap *sb,
unsigned int index;
index = SB_NR_TO_INDEX(sb, alloc_hint);
- alloc_hint = SB_NR_TO_BIT(sb, alloc_hint);
+
+ /* No point in looping twice in find_next_zero_bit() for this case. */
+ alloc_hint = 0;
return sbitmap_find_bit(sb, shallow_depth, index, alloc_hint, true);
}
--
2.41.0
Powered by blists - more mailing lists