Message ID | 20230717113709.328671-3-glider@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1058925vqt; Mon, 17 Jul 2023 04:54:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlGTd99OcYT2pNijnc4/r+xXQLBr/3EG8x71QEIKuJYCIfxMvLUGDGlaxdz7CyTPdhL2nVbF X-Received: by 2002:a05:6830:1d75:b0:6b9:5810:84d2 with SMTP id l21-20020a0568301d7500b006b9581084d2mr10628815oti.6.1689594855731; Mon, 17 Jul 2023 04:54:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689594855; cv=none; d=google.com; s=arc-20160816; b=DLGekixtOJa4zwl8f3UHbLZWmLdVyGlHHgaMZdWIVROrLK/E6KbTDz2CsYwTtqeSl7 1BEve2IO64Z00MFq5BC9tjNAimPgsQkndWCaoWYRmqVnQSTQZ70T6eJl/SO3iQ3+4tEx OKCD+zjEaD7/IZCqvQxrS4L0rczn48QaQjr1GbRjwNEIYn1OJmZGA9spKsjWRqNddRdr 3Wo3hJe/SNdUopA4TwdXnaU47YbQAnvtEBTaBZMXYQ8Fz7qyD2MYxz+OvyzEMIQnvOzF Vw4SzeCY05snHD2cjRp9aQio0LsmlWtLe15k3B1A47P/P75CIXDRRZ/EbalsEmsBkWjv No4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=S4GzxuyU3vJn9v8U3mWqzLaFXfnE9ofQM/5FOa6/PYw=; fh=O56S7FQoQXDYw0ENjMcjZy7yKrdXtC51zI+f09bWPts=; b=WVyc5SJXEHosmq7pefC2nXLoimrWvefR2D/sX03aJH5Zx7nip/45bPmRdFcVF1pic+ 3VJV6LPuyOovwOYDHfQmWnHNnQpyaUpyOp5X1AKvAh6ogxeMYxjGf4DeFH/a8AfovPKn gBSIUxSJIvHm7LIIHQAEHLgNLsQCUD58fBk1S+J8YOGH4CKmRIHMyIyVEzwLLOLjkGOK FahBOWbta/uD5U8bRueRj0642lAjspkj/neGrdr9+x+IQmznoeCPzWdaZ9BK2S0bXdgQ RW6mg9R3poseDEsg+dArRlyZ1gWAwDKAeHjcgDtvb4A8pIwUdo79rOej592fSmSsmjWf Lrdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=TRhADAln; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c5-20020a6566c5000000b0055c0477e26dsi10988198pgw.475.2023.07.17.04.54.02; Mon, 17 Jul 2023 04:54:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=TRhADAln; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230272AbjGQLh0 (ORCPT <rfc822;hadasmailinglist@gmail.com> + 99 others); Mon, 17 Jul 2023 07:37:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230260AbjGQLhX (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 17 Jul 2023 07:37:23 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A789C10CF for <linux-kernel@vger.kernel.org>; Mon, 17 Jul 2023 04:37:20 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-57745160c1dso41998677b3.2 for <linux-kernel@vger.kernel.org>; Mon, 17 Jul 2023 04:37:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689593840; x=1692185840; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=S4GzxuyU3vJn9v8U3mWqzLaFXfnE9ofQM/5FOa6/PYw=; b=TRhADAlnuCLbiGu1Z8fSaZaO8ThyU1u4h/oqBA8WWnXEPQrIlWo4fAT5TGnCam3mI4 PScfWARXctzZJoglFnaeX4/4mXUgNbsR5JyhvUQAug+Vv3KpeCt3WCj5Fm1poyP+huJ7 Fou4az0geM/C601sPT5rGVu2sYmfvq3oHsY2eBMXkhwYVp1cfyiGhxorRMM7lmrH9X0d OgW1NntxVRPZwEGrFfjEWlXZZ4fzEJSH/PWgVvRG+IPW4A3SRs9WTQqab6DqdxHhiaHu InkzhF7rowEHA7zC8IpLrEcQVL23wiD5U+B+UWJbhxSkiEDPR3kNDORikeMRKxcUZUL0 d9hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689593840; x=1692185840; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=S4GzxuyU3vJn9v8U3mWqzLaFXfnE9ofQM/5FOa6/PYw=; b=GICJEvwxB7dZz0Pipj65haK9JOQl5ZuM9IAnV07xZdc7grZ09sPW+6dlbS4PpKyE8H oAd7shX1xeYlGx/OQVcjas171Vq3vq/Nfv/K39XhnM4nhdX5KzvYzoz1k0duTztgIHNj 5MQl5C9VFCQZMk2v9FBMjEjGbE1mcxSMlCs3FVDqmz5It9O1S7MJrt+JWIT3qPlVDtHq mB+n8Cx3N0bcJEeQtMURL42FZxuV91DOcXq7F1xouRyrDOp5Pcxf3wJNF1Qnroih2Qs/ oRv9bSt1ifi2ZFormxNqU3/rKqqfleQK39GvqcADtHxE/iVOpDYrKNcObPtAys4dhKKu CWbQ== X-Gm-Message-State: ABy/qLYW6JBEOtOKSGsHCa1j32T/3QCIx1rWx1S4ulWXsMD2S/8BexdV 3lWkoxNmJp++c5R/cx74Bg9yV/UzzCg= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:3b6e:8102:6db8:d83f]) (user=glider job=sendgmr) by 2002:a81:ad5d:0:b0:573:285a:c2a3 with SMTP id l29-20020a81ad5d000000b00573285ac2a3mr126417ywk.1.1689593839923; Mon, 17 Jul 2023 04:37:19 -0700 (PDT) Date: Mon, 17 Jul 2023 13:37:05 +0200 In-Reply-To: <20230717113709.328671-1-glider@google.com> Mime-Version: 1.0 References: <20230717113709.328671-1-glider@google.com> X-Mailer: git-send-email 2.41.0.255.g8b1d071c50-goog Message-ID: <20230717113709.328671-3-glider@google.com> Subject: [PATCH v3 2/5] lib/test_bitmap: add tests for bitmap_{set,get}_value() From: Alexander Potapenko <glider@google.com> To: glider@google.com, catalin.marinas@arm.com, will@kernel.org, pcc@google.com, andreyknvl@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, yury.norov@gmail.com Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, eugenis@google.com, syednwaris@gmail.com, william.gray@linaro.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771668615132000043 X-GMAIL-MSGID: 1771668615132000043 |
Series |
Implement MTE tag compression for swapped pages
|
|
Commit Message
Alexander Potapenko
July 17, 2023, 11:37 a.m. UTC
Add basic tests ensuring that values can be added at arbitrary positions
of the bitmap, including those spanning into the adjacent unsigned
longs.
Signed-off-by: Alexander Potapenko <glider@google.com>
---
This patch was previously called
"lib/test_bitmap: add tests for bitmap_{set,get}_value_unaligned"
v3:
- switch to using bitmap_{set,get}_value()
- change the expected bit pattern in test_set_get_value(),
as the test was incorrectly assuming 0 is the LSB.
---
lib/test_bitmap.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
Comments
On Mon, Jul 17, 2023 at 01:37:05PM +0200, Alexander Potapenko wrote: > Add basic tests ensuring that values can be added at arbitrary positions > of the bitmap, including those spanning into the adjacent unsigned > longs. I always in favour of a new test case! Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > Signed-off-by: Alexander Potapenko <glider@google.com> > > --- > This patch was previously called > "lib/test_bitmap: add tests for bitmap_{set,get}_value_unaligned" Hint, you may always just link to lore mail archive for easier access and handling. Also with `b4` at hand the lore link can be used to resurrect a discussion (in case it's needed). > v3: > - switch to using bitmap_{set,get}_value() > - change the expected bit pattern in test_set_get_value(), > as the test was incorrectly assuming 0 is the LSB. > --- > lib/test_bitmap.c | 33 +++++++++++++++++++++++++++++++++ > 1 file changed, 33 insertions(+) > > diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c > index 187f5b2db4cf1..c2ab54040c249 100644 > --- a/lib/test_bitmap.c > +++ b/lib/test_bitmap.c > @@ -71,6 +71,17 @@ __check_eq_uint(const char *srcfile, unsigned int line, > return true; > } > > +static bool __init > +__check_eq_ulong(const char *srcfile, unsigned int line, > + const unsigned long exp_ulong, unsigned long x) > +{ > + if (exp_ulong != x) { > + pr_err("[%s:%u] expected %lu, got %lu\n", > + srcfile, line, exp_ulong, x); > + return false; > + } > + return true; > +} > > static bool __init > __check_eq_bitmap(const char *srcfile, unsigned int line, > @@ -186,6 +197,7 @@ __check_eq_str(const char *srcfile, unsigned int line, > }) > > #define expect_eq_uint(...) __expect_eq(uint, ##__VA_ARGS__) > +#define expect_eq_ulong(...) __expect_eq(ulong, ##__VA_ARGS__) > #define expect_eq_bitmap(...) __expect_eq(bitmap, ##__VA_ARGS__) > #define expect_eq_pbl(...) __expect_eq(pbl, ##__VA_ARGS__) > #define expect_eq_u32_array(...) __expect_eq(u32_array, ##__VA_ARGS__) > @@ -1222,6 +1234,25 @@ static void __init test_bitmap_const_eval(void) > BUILD_BUG_ON(~var != ~BIT(25)); > } > > +static void __init test_set_get_value(void) > +{ > + DECLARE_BITMAP(bitmap, BITS_PER_LONG * 2); > + unsigned long val; > + int i; > + > + for (i = 0; i < BITS_PER_LONG * 2 - 7; i++) { > + bitmap_zero(bitmap, BITS_PER_LONG * 2); > + bitmap_set_value(bitmap, 0b10101UL, i, 5); > + val = bitmap_get_value(bitmap, i, 5); > + expect_eq_ulong(0b10101UL, val); > + bitmap_set_value(bitmap, 0b101UL, i + 5, 3); > + val = bitmap_get_value(bitmap, i + 5, 3); > + expect_eq_ulong(0b101UL, val); > + val = bitmap_get_value(bitmap, i, 8); > + expect_eq_ulong(0b10110101UL, val); > + } > +} > + > static void __init selftest(void) > { > test_zero_clear(); > @@ -1249,6 +1280,8 @@ static void __init selftest(void) > test_for_each_clear_bitrange_from(); > test_for_each_set_clump8(); > test_for_each_set_bit_wrap(); > + > + test_set_get_value(); > } > > KSTM_MODULE_LOADERS(test_bitmap); > -- > 2.41.0.255.g8b1d071c50-goog >
On Mon, Jul 17, 2023 at 01:37:05PM +0200, Alexander Potapenko wrote: > Add basic tests ensuring that values can be added at arbitrary positions > of the bitmap, including those spanning into the adjacent unsigned > longs. > > Signed-off-by: Alexander Potapenko <glider@google.com> Thanks for the test! > --- > This patch was previously called > "lib/test_bitmap: add tests for bitmap_{set,get}_value_unaligned" > > v3: > - switch to using bitmap_{set,get}_value() > - change the expected bit pattern in test_set_get_value(), > as the test was incorrectly assuming 0 is the LSB. > --- > lib/test_bitmap.c | 33 +++++++++++++++++++++++++++++++++ > 1 file changed, 33 insertions(+) > > diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c > index 187f5b2db4cf1..c2ab54040c249 100644 > --- a/lib/test_bitmap.c > +++ b/lib/test_bitmap.c > @@ -71,6 +71,17 @@ __check_eq_uint(const char *srcfile, unsigned int line, > return true; > } > > +static bool __init > +__check_eq_ulong(const char *srcfile, unsigned int line, > + const unsigned long exp_ulong, unsigned long x) > +{ > + if (exp_ulong != x) { > + pr_err("[%s:%u] expected %lu, got %lu\n", > + srcfile, line, exp_ulong, x); > + return false; > + } > + return true; > +} > > static bool __init > __check_eq_bitmap(const char *srcfile, unsigned int line, > @@ -186,6 +197,7 @@ __check_eq_str(const char *srcfile, unsigned int line, > }) > > #define expect_eq_uint(...) __expect_eq(uint, ##__VA_ARGS__) > +#define expect_eq_ulong(...) __expect_eq(ulong, ##__VA_ARGS__) > #define expect_eq_bitmap(...) __expect_eq(bitmap, ##__VA_ARGS__) > #define expect_eq_pbl(...) __expect_eq(pbl, ##__VA_ARGS__) > #define expect_eq_u32_array(...) __expect_eq(u32_array, ##__VA_ARGS__) > @@ -1222,6 +1234,25 @@ static void __init test_bitmap_const_eval(void) > BUILD_BUG_ON(~var != ~BIT(25)); > } > > +static void __init test_set_get_value(void) > +{ > + DECLARE_BITMAP(bitmap, BITS_PER_LONG * 2); It's too short. Can you make it long enough to ensure it works as expected when start is not in the 1st word, and start+nbits is in the following word. > + unsigned long val; > + int i; > + > + for (i = 0; i < BITS_PER_LONG * 2 - 7; i++) { > + bitmap_zero(bitmap, BITS_PER_LONG * 2); > + bitmap_set_value(bitmap, 0b10101UL, i, 5); > + val = bitmap_get_value(bitmap, i, 5); > + expect_eq_ulong(0b10101UL, val); Can you also check that the rest of bitmap is untouched? Something like: DECLARE_BITMAP(bitmap, ...); DECLARE_BITMAP(orig, ...); memset(orig, 0x5a, ...); memset(bitmap, 0x5a, ...); for (j = start; j < start + nbits; j++) if (val & BIT(j - start)) __set_bit(j, orig); else __clear_bit(j, orig); bitmap_set_value(bitmap, val, start, nbits); expect_eq_bitmap(orig, bitmap, ...); I like this kind of testing because it gives people a better understanding of what happens behind all that optimization tricks. Thanks, Yury
On Mon, Jul 17, 2023 at 09:11:50AM -0700, Yury Norov wrote: > On Mon, Jul 17, 2023 at 01:37:05PM +0200, Alexander Potapenko wrote: ... > if (val & BIT(j - start)) > __set_bit(j, orig); > else > __clear_bit(j, orig); JFYI: __asign_bit() can be used here.
On Mon, Jul 17, 2023 at 6:11 PM Yury Norov <yury.norov@gmail.com> wrote: > > On Mon, Jul 17, 2023 at 01:37:05PM +0200, Alexander Potapenko wrote: > > Add basic tests ensuring that values can be added at arbitrary positions > > of the bitmap, including those spanning into the adjacent unsigned > > longs. > > > > Signed-off-by: Alexander Potapenko <glider@google.com> > > Thanks for the test! > > > --- > > This patch was previously called > > "lib/test_bitmap: add tests for bitmap_{set,get}_value_unaligned" > > > > v3: > > - switch to using bitmap_{set,get}_value() > > - change the expected bit pattern in test_set_get_value(), > > as the test was incorrectly assuming 0 is the LSB. > > --- > > lib/test_bitmap.c | 33 +++++++++++++++++++++++++++++++++ > > 1 file changed, 33 insertions(+) > > > > diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c > > index 187f5b2db4cf1..c2ab54040c249 100644 > > --- a/lib/test_bitmap.c > > +++ b/lib/test_bitmap.c > > @@ -71,6 +71,17 @@ __check_eq_uint(const char *srcfile, unsigned int line, > > return true; > > } > > > > +static bool __init > > +__check_eq_ulong(const char *srcfile, unsigned int line, > > + const unsigned long exp_ulong, unsigned long x) > > +{ > > + if (exp_ulong != x) { > > + pr_err("[%s:%u] expected %lu, got %lu\n", > > + srcfile, line, exp_ulong, x); > > + return false; > > + } > > + return true; > > +} > > > > static bool __init > > __check_eq_bitmap(const char *srcfile, unsigned int line, > > @@ -186,6 +197,7 @@ __check_eq_str(const char *srcfile, unsigned int line, > > }) > > > > #define expect_eq_uint(...) __expect_eq(uint, ##__VA_ARGS__) > > +#define expect_eq_ulong(...) __expect_eq(ulong, ##__VA_ARGS__) > > #define expect_eq_bitmap(...) __expect_eq(bitmap, ##__VA_ARGS__) > > #define expect_eq_pbl(...) __expect_eq(pbl, ##__VA_ARGS__) > > #define expect_eq_u32_array(...) __expect_eq(u32_array, ##__VA_ARGS__) > > @@ -1222,6 +1234,25 @@ static void __init test_bitmap_const_eval(void) > > BUILD_BUG_ON(~var != ~BIT(25)); > > } > > > > +static void __init test_set_get_value(void) > > +{ > > + DECLARE_BITMAP(bitmap, BITS_PER_LONG * 2); > > It's too short. Can you make it long enough to ensure it works as > expected when start is not in the 1st word, and start+nbits is in > the following word. > > > + unsigned long val; > > + int i; > > + > > + for (i = 0; i < BITS_PER_LONG * 2 - 7; i++) { > > + bitmap_zero(bitmap, BITS_PER_LONG * 2); > > + bitmap_set_value(bitmap, 0b10101UL, i, 5); > > + val = bitmap_get_value(bitmap, i, 5); > > + expect_eq_ulong(0b10101UL, val); > > Can you also check that the rest of bitmap is untouched? > Something like: > > DECLARE_BITMAP(bitmap, ...); > DECLARE_BITMAP(orig, ...); > > memset(orig, 0x5a, ...); > memset(bitmap, 0x5a, ...); > > for (j = start; j < start + nbits; j++) > if (val & BIT(j - start)) > __set_bit(j, orig); > else > __clear_bit(j, orig); > > bitmap_set_value(bitmap, val, start, nbits); > expect_eq_bitmap(orig, bitmap, ...); > > I like this kind of testing because it gives people a better > understanding of what happens behind all that optimization tricks. Will do. In fact the difference between GENMASK(n, 0) and GENMASK(n-1, 0) discussed in the other patch requires exactly this kind of testing.
On Mon, Jul 17, 2023 at 3:04 PM Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote: > > On Mon, Jul 17, 2023 at 01:37:05PM +0200, Alexander Potapenko wrote: > > Add basic tests ensuring that values can be added at arbitrary positions > > of the bitmap, including those spanning into the adjacent unsigned > > longs. > > I always in favour of a new test case! > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > > Signed-off-by: Alexander Potapenko <glider@google.com> > > > > --- > > This patch was previously called > > "lib/test_bitmap: add tests for bitmap_{set,get}_value_unaligned" > > Hint, you may always just link to lore mail archive for easier access and > handling. Also with `b4` at hand the lore link can be used to resurrect > a discussion (in case it's needed). Will add the link in v4 (guess you didn't want it in the final patch description, correct?)
diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c index 187f5b2db4cf1..c2ab54040c249 100644 --- a/lib/test_bitmap.c +++ b/lib/test_bitmap.c @@ -71,6 +71,17 @@ __check_eq_uint(const char *srcfile, unsigned int line, return true; } +static bool __init +__check_eq_ulong(const char *srcfile, unsigned int line, + const unsigned long exp_ulong, unsigned long x) +{ + if (exp_ulong != x) { + pr_err("[%s:%u] expected %lu, got %lu\n", + srcfile, line, exp_ulong, x); + return false; + } + return true; +} static bool __init __check_eq_bitmap(const char *srcfile, unsigned int line, @@ -186,6 +197,7 @@ __check_eq_str(const char *srcfile, unsigned int line, }) #define expect_eq_uint(...) __expect_eq(uint, ##__VA_ARGS__) +#define expect_eq_ulong(...) __expect_eq(ulong, ##__VA_ARGS__) #define expect_eq_bitmap(...) __expect_eq(bitmap, ##__VA_ARGS__) #define expect_eq_pbl(...) __expect_eq(pbl, ##__VA_ARGS__) #define expect_eq_u32_array(...) __expect_eq(u32_array, ##__VA_ARGS__) @@ -1222,6 +1234,25 @@ static void __init test_bitmap_const_eval(void) BUILD_BUG_ON(~var != ~BIT(25)); } +static void __init test_set_get_value(void) +{ + DECLARE_BITMAP(bitmap, BITS_PER_LONG * 2); + unsigned long val; + int i; + + for (i = 0; i < BITS_PER_LONG * 2 - 7; i++) { + bitmap_zero(bitmap, BITS_PER_LONG * 2); + bitmap_set_value(bitmap, 0b10101UL, i, 5); + val = bitmap_get_value(bitmap, i, 5); + expect_eq_ulong(0b10101UL, val); + bitmap_set_value(bitmap, 0b101UL, i + 5, 3); + val = bitmap_get_value(bitmap, i + 5, 3); + expect_eq_ulong(0b101UL, val); + val = bitmap_get_value(bitmap, i, 8); + expect_eq_ulong(0b10110101UL, val); + } +} + static void __init selftest(void) { test_zero_clear(); @@ -1249,6 +1280,8 @@ static void __init selftest(void) test_for_each_clear_bitrange_from(); test_for_each_set_clump8(); test_for_each_set_bit_wrap(); + + test_set_get_value(); } KSTM_MODULE_LOADERS(test_bitmap);