From: Yury Norov <yury.norov@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Yury Norov <yury.norov@gmail.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>
Subject: [PATCH 04/12] bitmap: add test for bitmap_bitremap()
Date: Mon, 28 Aug 2023 11:43:44 -0700 [thread overview]
Message-ID: <20230828184353.5145-5-yury.norov@gmail.com> (raw)
In-Reply-To: <20230828184353.5145-1-yury.norov@gmail.com>
Similarly to bitmap_remap, test bitmap_bitremap().
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
lib/test_bitmap.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c
index e1c22d399f24..e9211f9a0e67 100644
--- a/lib/test_bitmap.c
+++ b/lib/test_bitmap.c
@@ -378,6 +378,19 @@ static void __init test_weight(void)
}
}
+static __always_inline void __init __test_bitremap(unsigned long *dst, unsigned long *src,
+ unsigned long *old, unsigned long *new, unsigned long nbits)
+{
+ unsigned long oldbit, newbit;
+
+ bitmap_zero(dst, nbits);
+
+ for_each_set_bit(oldbit, src, nbits) {
+ newbit = bitmap_bitremap(oldbit, old, new, nbits);
+ __set_bit(newbit, dst);
+ }
+}
+
static void __init test_remap(void)
{
DECLARE_BITMAP(dst, 8);
@@ -402,6 +415,9 @@ static void __init test_remap(void)
bitmap_remap(dst, src, old, new, 8);
expect_eq_bitmap(exp0, dst, 8);
+ __test_bitremap(dst, src, old, new, 8);
+ expect_eq_bitmap(exp0, dst, 8);
+
/*
* When old mapping is the same as new, source bits are copied to dst.
* Real code must use bitmap_copy() if it's known in advance.
@@ -409,6 +425,9 @@ static void __init test_remap(void)
bitmap_remap(dst, src, old, old, 8);
expect_eq_bitmap(src, dst, 8);
+ __test_bitremap(dst, src, old, old, 8);
+ expect_eq_bitmap(src, dst, 8);
+
bitmap_remap(dst, src, new, new, 8);
expect_eq_bitmap(src, dst, 8);
@@ -419,23 +438,38 @@ static void __init test_remap(void)
bitmap_remap(dst, src, empty, new, 8);
expect_eq_bitmap(src, dst, 8);
+ __test_bitremap(dst, src, empty, new, 8);
+ expect_eq_bitmap(src, dst, 8);
+
bitmap_remap(dst, src, old, empty, 8);
expect_eq_bitmap(src, dst, 8);
+ __test_bitremap(dst, src, old, empty, 8);
+ expect_eq_bitmap(src, dst, 8);
+
bitmap_remap(dst, src, empty, empty, 8);
expect_eq_bitmap(src, dst, 8);
+ __test_bitremap(dst, src, empty, empty, 8);
+ expect_eq_bitmap(src, dst, 8);
+
/* Set extra bit in old map to test carry logic */
set_bit(5, old);
bitmap_remap(dst, src, old, new, 8);
expect_eq_bitmap(exp1, dst, 8);
+ __test_bitremap(dst, src, old, new, 8);
+ expect_eq_bitmap(exp1, dst, 8);
+
/* Map old bits to #7 */
bitmap_zero(new, 8);
set_bit(7, new);
bitmap_remap(dst, src, old, new, 8);
expect_eq_bitmap(exp2, dst, 8);
+ __test_bitremap(dst, src, old, new, 8);
+ expect_eq_bitmap(exp2, dst, 8);
+
bitmap_fill(perf_src, 1000);
bitmap_set(perf_old, 0, 500);
bitmap_clear(perf_old, 500, 500);
--
2.39.2
next prev parent reply other threads:[~2023-08-28 18:44 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-28 18:43 [PATCH 00/12] bitmap: rework bitmap_{bit,}remap() Yury Norov
2023-08-28 18:43 ` [PATCH 01/12] bitmap: add find_nth_bit_from() Yury Norov
2023-08-28 18:43 ` [PATCH 02/12] bitmap: add bitmap_weight_from() Yury Norov
2023-08-29 7:22 ` Rasmus Villemoes
2023-08-28 18:43 ` [PATCH 03/12] bitmap: add test for bitmap_remap() Yury Norov
2023-08-28 18:43 ` Yury Norov [this message]
2023-08-28 18:43 ` [PATCH 05/12] bitmap: update comment for bitmap_{bit,}remap() Yury Norov
2023-08-28 18:43 ` [PATCH 06/12] bitmap: add small_cont_nbits() optimization for bitmap_remap() Yury Norov
2023-08-28 18:43 ` [PATCH 07/12] bitmap: add small_const_nbits() optimization for bitmap_bitremap() Yury Norov
2023-08-28 18:43 ` [PATCH 08/12] bitmap: optiimze bitmap_bitremap() Yury Norov
2023-08-28 18:43 ` [PATCH 09/12] bitmap: optimize bitmap_remap() when 'new' is empty map Yury Norov
2023-08-28 18:43 ` [PATCH 10/12] bitmap: separate handling of identity and remapping parts in bitmap_remap() Yury Norov
2023-08-28 18:43 ` [PATCH 11/12] bitmap: defer calculating weight of 'new' " Yury Norov
2023-08-28 18:43 ` [PATCH 12/12] bitmap: don't count bits from the beginning " Yury Norov
2023-08-29 7:33 ` [PATCH 00/12] bitmap: rework bitmap_{bit,}remap() Rasmus Villemoes
2023-08-29 13:38 ` Andy Shevchenko
2023-08-29 13:50 ` Yury Norov
2023-08-29 14:56 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230828184353.5145-5-yury.norov@gmail.com \
--to=yury.norov@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®