Thread (33 messages) 33 messages, 9 authors, 2021-12-15

Re: [PATCH 2/9] lib/bitmap: implement bitmap_{empty,full} with bitmap_weight_eq()

From: Yury Norov <yury.norov@gmail.com>
Date: 2021-11-28 06:29:37
Also in: kvm, linux-alpha, linux-crypto, linux-mips, linux-mm, linux-riscv, linux-s390, linuxppc-dev, lkml

On Sun, Nov 28, 2021 at 05:37:19AM +0100, Michał Mirosław wrote:
On Sat, Nov 27, 2021 at 07:56:57PM -0800, Yury Norov wrote:
quoted
Now as we have bitmap_weight_eq(), switch bitmap_full() and
bitmap_empty() to using it.
[...]
quoted
-static inline bool bitmap_empty(const unsigned long *src, unsigned nbits)
-{
-	if (small_const_nbits(nbits))
-		return ! (*src & BITMAP_LAST_WORD_MASK(nbits));
-
-	return find_first_bit(src, nbits) == nbits;
-}
[...]
quoted
+static __always_inline bool bitmap_empty(const unsigned long *src, unsigned int nbits)
+{
+	return bitmap_weight_eq(src, nbits, 0);
+}
[..]

What's the speed difference? Have you benchmarked this?
bitmap_weight_eq() should be faster than find_first_bit(), but the
difference is few cycles, so I didn't bother measuring it.

New version looks just better.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help