linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Syed Nayyar Waris <syednwaris@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	William Breathitt Gray <vilhelm.gray@gmail.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v6 2/4] lib/test_bitmap.c: Add for_each_set_clump test cases
Date: Thu, 21 May 2020 03:10:18 +0530	[thread overview]
Message-ID: <CACG_h5o5=DXFtNzHn+NzY0rRjbZXhjrs58ka042hoOsVFFHnkA@mail.gmail.com> (raw)
In-Reply-To: <20200515113202.GO185537@smile.fi.intel.com>

On Fri, May 15, 2020 at 5:02 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Fri, May 15, 2020 at 04:48:46AM +0530, Syed Nayyar Waris wrote:
> > The introduction of the generic for_each_set_clump macro need test
> > cases to verify the implementation. This patch adds test cases for
> > scenarios in which clump sizes are 8 bits, 24 bits, 30 bits and 6 bits.
> > The cases contain situations where clump is getting split at the word
> > boundary and also when zeroes are present in the start and middle of
> > bitmap.
>
> Thanks for an update. Looks pretty much okay to me, though one nit below.
> After addressing,
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> > Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
> > Cc: Linus Walleij <linus.walleij@linaro.org>
> > Signed-off-by: Syed Nayyar Waris <syednwaris@gmail.com>
> > Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
> > ---
> > Changes in v6:
> >  - Make 'for loop' inside 'test_for_each_set_clump' more succinct.
> >
> > Changes in v5:
> >  - No change.
> >
> > Changes in v4:
> >  - Use 'for' loop in test function of 'for_each_set_clump'.
> >
> > Changes in v3:
> >  - No Change.
> >
> > Changes in v2:
> >  - Unify different tests for 'for_each_set_clump'. Pass test data as
> >    function parameters.
> >  - Remove unnecessary bitmap_zero calls.
> >
> >  lib/test_bitmap.c | 142 ++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 142 insertions(+)
> >
> > diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c
> > index 6b13150667f5..673c512a5bbd 100644
> > --- a/lib/test_bitmap.c
> > +++ b/lib/test_bitmap.c
> > @@ -155,6 +155,38 @@ static bool __init __check_eq_clump8(const char *srcfile, unsigned int line,
> >       return true;
> >  }
> >
> > +static bool __init __check_eq_clump(const char *srcfile, unsigned int line,
> > +                                 const unsigned int offset,
> > +                                 const unsigned int size,
> > +                                 const unsigned long *const clump_exp,
> > +                                 const unsigned long *const clump,
> > +                                 const unsigned long clump_size)
> > +{
> > +     unsigned long exp;
> > +
> > +     if (offset >= size) {
> > +             pr_warn("[%s:%u] bit offset for clump out-of-bounds: expected less than %u, got %u\n",
> > +                     srcfile, line, size, offset);
> > +             return false;
> > +     }
> > +
> > +     exp = clump_exp[offset / clump_size];
> > +     if (!exp) {
> > +             pr_warn("[%s:%u] bit offset for zero clump: expected nonzero clump, got bit offset %u with clump value 0",
> > +                     srcfile, line, offset);
> > +             return false;
> > +     }
> > +
> > +     if (*clump != exp) {
> > +             pr_warn("[%s:%u] expected clump value of 0x%lX, got clump value of 0x%lX",
> > +                     srcfile, line, exp, *clump);
> > +             return false;
> > +     }
> > +
> > +     return true;
> > +}
> > +
> > +
> >  #define __expect_eq(suffix, ...)                                     \
> >       ({                                                              \
> >               int result = 0;                                         \
> > @@ -172,6 +204,7 @@ static bool __init __check_eq_clump8(const char *srcfile, unsigned int line,
> >  #define expect_eq_pbl(...)           __expect_eq(pbl, ##__VA_ARGS__)
> >  #define expect_eq_u32_array(...)     __expect_eq(u32_array, ##__VA_ARGS__)
> >  #define expect_eq_clump8(...)                __expect_eq(clump8, ##__VA_ARGS__)
> > +#define expect_eq_clump(...)         __expect_eq(clump, ##__VA_ARGS__)
> >
> >  static void __init test_zero_clear(void)
> >  {
> > @@ -577,6 +610,28 @@ static void noinline __init test_mem_optimisations(void)
> >       }
> >  }
> >
> > +static const unsigned long clump_bitmap_data[] __initconst = {
> > +     0x38000201,
> > +     0x05ff0f38,
> > +     0xeffedcba,
> > +     0xbbbbabcd,
> > +     0x000000aa,
> > +     0x000000aa,
> > +     0x00ff0000,
> > +     0xaaaaaa00,
> > +     0xff000000,
> > +     0x00aa0000,
> > +     0x00000000,
> > +     0x00000000,
> > +     0x00000000,
> > +     0x0f000000,
> > +     0x00ff0000,
> > +     0xaaaaaa00,
> > +     0xff000000,
> > +     0x00aa0000,
> > +     0x00000ac0,
> > +};
> > +
> >  static const unsigned char clump_exp[] __initconst = {
> >       0x01,   /* 1 bit set */
> >       0x02,   /* non-edge 1 bit set */
> > @@ -588,6 +643,92 @@ static const unsigned char clump_exp[] __initconst = {
> >       0x05,   /* non-adjacent 2 bits set */
> >  };
> >
> > +static const unsigned long clump_exp1[] __initconst = {
> > +     0x01,   /* 1 bit set */
> > +     0x02,   /* non-edge 1 bit set */
> > +     0x00,   /* zero bits set */
> > +     0x38,   /* 3 bits set across 4-bit boundary */
> > +     0x38,   /* Repeated clump */
> > +     0x0F,   /* 4 bits set */
> > +     0xFF,   /* all bits set */
> > +     0x05,   /* non-adjacent 2 bits set */
> > +};
> > +
> > +static const unsigned long clump_exp2[] __initconst = {
> > +     0xfedcba,       /* 24 bits */
> > +     0xabcdef,
> > +     0xaabbbb,       /* Clump split between 2 words */
> > +     0x000000,       /* zeroes in between */
> > +     0x0000aa,
> > +     0x000000,
> > +     0x0000ff,
> > +     0xaaaaaa,
> > +     0x000000,
> > +     0x0000ff,
> > +};
> > +
> > +static const unsigned long clump_exp3[] __initconst = {
> > +     0x00000000,     /* starting with 0s*/
> > +     0x00000000,     /* All 0s */
> > +     0x00000000,
> > +     0x00000000,
> > +     0x3f00000f,     /* Non zero set */
> > +     0x2aa80003,
> > +     0x00000aaa,
> > +     0x00003fc0,
> > +};
> > +
> > +static const unsigned long clump_exp4[] __initconst = {
> > +     0x00,
> > +     0x2b,
> > +};
> > +
> > +struct clump_test_data {
>
> > +     unsigned long data[256];
>
> DECLARE_BITMAP() ?
>
> > +     unsigned long count;
> > +     unsigned long offset;
> > +     unsigned long limit;
> > +     unsigned long clump_size;
> > +     unsigned long const *exp;
>
> > +} clump_test_data[] = { {{0}, 2, 0, 64, 8, clump_exp1},
> > +                     {{0}, 8, 2, 240, 24, clump_exp2},
> > +                     {{0}, 8, 10, 240, 30, clump_exp3},
> > +                     {{0}, 1, 18, 18, 6, clump_exp4} };
>
> Please, split structure definition and test data.
>
> > +

I have incorporated your above 2 review comments.

I will be sharing the new (v7) patchset in some time with your
'Reviewed-by' tag included in this patch. I believe I have understood
correctly.

Regards
Syed Nayyar Waris

  reply	other threads:[~2020-05-20 21:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-14 23:16 [PATCH v6 0/4] Introduce the for_each_set_clump macro Syed Nayyar Waris
2020-05-14 23:17 ` [PATCH v6 1/4] bitops: Introduce the " Syed Nayyar Waris
2020-05-15 11:29   ` Andy Shevchenko
2020-05-14 23:18 ` [PATCH v6 2/4] lib/test_bitmap.c: Add for_each_set_clump test cases Syed Nayyar Waris
2020-05-15 11:32   ` Andy Shevchenko
2020-05-20 21:40     ` Syed Nayyar Waris [this message]
2020-05-21 10:11       ` Andy Shevchenko
2020-05-14 23:19 ` [PATCH v6 3/4] gpio: thunderx: Utilize for_each_set_clump macro Syed Nayyar Waris
2020-05-14 23:21 ` [PATCH v6 4/4] gpio: xilinx: " Syed Nayyar Waris
2020-05-15 11:32 ` [PATCH v6 0/4] Introduce the " 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='CACG_h5o5=DXFtNzHn+NzY0rRjbZXhjrs58ka042hoOsVFFHnkA@mail.gmail.com' \
    --to=syednwaris@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vilhelm.gray@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).