[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230828184353.5145-9-yury.norov@gmail.com>
Date: Mon, 28 Aug 2023 11:43:48 -0700
From: Yury Norov <yury.norov@...il.com>
To: linux-kernel@...r.kernel.org
Cc: Yury Norov <yury.norov@...il.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>
Subject: [PATCH 08/12] bitmap: optiimze bitmap_bitremap()
When 'new' map is empty, we can skip remapping entirely and return
the old bit.
Signed-off-by: Yury Norov <yury.norov@...il.com>
---
lib/bitmap.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 9ecdc74cb6b4..2e8deeb8bf99 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -1017,12 +1017,17 @@ EXPORT_SYMBOL(__bitmap_remap);
int __bitmap_bitremap(int oldbit, const unsigned long *old,
const unsigned long *new, int bits)
{
- int w = bitmap_weight(new, bits);
- int n = bitmap_pos_to_ord(old, oldbit, bits);
- if (n < 0 || w == 0)
+ int w, n;
+
+ w = bitmap_weight(new, bits);
+ if (w == 0)
+ return oldbit;
+
+ n = bitmap_pos_to_ord(old, oldbit, bits);
+ if (n < 0)
return oldbit;
- else
- return find_nth_bit(new, bits, n % w);
+
+ return find_nth_bit(new, bits, n % w);
}
EXPORT_SYMBOL(__bitmap_bitremap);
--
2.39.2
Powered by blists - more mailing lists