mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "孙毅 (Yi Sun)" <Yi.Sun@unisoc.com>
To: Yury Norov <yury.norov@gmail.com>
Cc: "mina86@mina86.com" <mina86@mina86.com>,
	"279644543@qq.com" <279644543@qq.com>,
	"mnazarewicz@gmail.com" <mnazarewicz@gmail.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"akinobu.mita@gmail.com" <akinobu.mita@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"tjmercier@google.com" <tjmercier@google.com>,
	"qiang.zhao@freescale.com" <qiang.zhao@freescale.com>,
	"scottwood@freescale.com" <scottwood@freescale.com>,
	"fvdl@google.com" <fvdl@google.com>,
	"tglx@kernel.org" <tglx@kernel.org>,
	"song@kernel.org" <song@kernel.org>, "hch@lst.de" <hch@lst.de>,
	"minchan@kernel.org" <minchan@kernel.org>,
	"王科 (Ke Wang)" <Ke.Wang@unisoc.com>,
	"John Stultz" <jstultz@google.com>
Subject: 答复: [PATCH v5 1/2] lib: bitmap: add tests for bitmap_find_next_zero_area_off()
Date: Thu, 18 Jun 2026 12:44:19 +0000	[thread overview]
Message-ID: <cf3b9ed0197040aa8d224715a1707a8c@BJMBX02.spreadtrum.com> (raw)
In-Reply-To: <ajOGiVtCmnU9OjJP@yury>



> -----邮件原件-----
> 发件人: 孙毅 (Yi Sun)
> 发送时间: 2026年6月18日 17:43
> 收件人: 'Yury Norov' <yury.norov@gmail.com>
> 抄送: 'mina86@mina86.com' <mina86@mina86.com>; '279644543@qq.com'
> <279644543@qq.com>; 'mnazarewicz@gmail.com' <mnazarewicz@gmail.com>;
> 'akpm@linux-foundation.org' <akpm@linux-foundation.org>;
> 'akinobu.mita@gmail.com' <akinobu.mita@gmail.com>; 'linux-
> kernel@vger.kernel.org' <linux-kernel@vger.kernel.org>; 'tjmercier@google.com'
> <tjmercier@google.com>; 'qiang.zhao@freescale.com'
> <qiang.zhao@freescale.com>; 'scottwood@freescale.com'
> <scottwood@freescale.com>; 'fvdl@google.com' <fvdl@google.com>;
> 'tglx@kernel.org' <tglx@kernel.org>; 'song@kernel.org' <song@kernel.org>;
> 'hch@lst.de' <hch@lst.de>; 'minchan@kernel.org' <minchan@kernel.org>; 王科
> (Ke Wang) <Ke.Wang@unisoc.com>; 'John Stultz' <jstultz@google.com>
> 主题: 答复: [PATCH v5 1/2] lib: bitmap: add tests for
> bitmap_find_next_zero_area_off()
> 
> 
> 
> > -----邮件原件-----
> > 发件人: Yury Norov <yury.norov@gmail.com>
> > 发送时间: 2026年6月18日 13:48
> > 收件人: 孙毅 (Yi Sun) <Yi.Sun@unisoc.com>
> > 抄送: yury.norov@gmail.com; mina86@mina86.com; 279644543@qq.com;
> > mnazarewicz@gmail.com; akpm@linux-foundation.org;
> > akinobu.mita@gmail.com; linux-kernel@vger.kernel.org; john.stultz@linaro.org;
> > tjmercier@google.com; qiang.zhao@freescale.com; scottwood@freescale.com;
> > benjamin.gaignard@linaro.org; fvdl@google.com; tglx@kernel.org;
> > andreas.herrmann@calxeda.com; song@kernel.org; hch@lst.de;
> > sasha.levin@oracle.com; minchan@kernel.org
> > 主题: Re: [PATCH v5 1/2] lib: bitmap: add tests for
> > bitmap_find_next_zero_area_off()
> >
> >
> > 注意: 这封邮件来自于外部。除非你确定邮件内容安全,否则不要点击任何
> 链
> > 接和附件。
> > CAUTION: This email originated from outside of the organization. Do not click
> links
> > or open attachments unless you recognize the sender and know the content is
> > safe.
> >
> >
> >
> > On Thu, Jun 18, 2026 at 09:52:51AM +0800, Yi Sun wrote:
> > > Add functional and performance tests
> > > for bitmap_find_next_zero_area_off().
> > >
> > > To maintain consistent output format,
> > > use "find_next_0_area" instead of
> > > "bitmap_find_next_zero_area_off".
> > >
> > > performance tests partial output:
> > > Start testing find_bit() with random-filled bitmap
> > > [    0.191166] find_next_0_area:              1521308 ns,   1326 iterations
> > > [    0.192552] find_next_bit:                 1382385 ns, 163724 iterations
> > > Start testing find_bit() with sparse bitmap
> > > [    0.196835] find_next_0_area:              4250307 ns, 322497 iterations
> > > [    0.196853] find_next_bit:                   15077 ns,    656 iterations
> > >
> > > Signed-off-by: Yi Sun <yi.sun@unisoc.com>
> > > ---
> > >  lib/find_bit_benchmark.c | 17 +++++++++++++++++
> > >  lib/test_bitmap.c        | 38 ++++++++++++++++++++++++++++++++++++++
> > >  2 files changed, 55 insertions(+)
> > >
> > > diff --git a/lib/find_bit_benchmark.c b/lib/find_bit_benchmark.c
> > > index 00d9dc61cd46..062a69930d83 100644
> > > --- a/lib/find_bit_benchmark.c
> > > +++ b/lib/find_bit_benchmark.c
> > > @@ -149,6 +149,21 @@ static int __init test_find_next_and_bit(const void
> > *bitmap,
> > >       return 0;
> > >  }
> > >
> > > +static int __init
> > > +test_bitmap_find_next_zero_area_off(unsigned long *bitmap, unsigned long
> > len)
> > > +{
> > > +     unsigned long i, cnt;
> > > +     ktime_t time;
> > > +
> > > +     time = ktime_get();
> > > +     for (cnt = i = 0; i < BITMAP_LEN; cnt++)
> > > +             i = bitmap_find_next_zero_area_off(bitmap, BITMAP_LEN, i, 8, 0, 0) +
> 1;
> > > +     time = ktime_get() - time;
> > > +     pr_err("find_next_0_area:   %18llu ns, %6ld iterations\n", time, cnt);
> >
> > Change %18llu to %14llu (or whatever), and keep the name as it should.
> 
> ok,  I will make changes in v6.
> 
> >
> > > +
> > > +     return 0;
> > > +}
> > > +
> > >  static int __init find_bit_test(void)
> > >  {
> > >       unsigned long nbits = BITMAP_LEN / SPARSE;
> > > @@ -158,6 +173,7 @@ static int __init find_bit_test(void)
> > >       get_random_bytes(bitmap, sizeof(bitmap));
> > >       get_random_bytes(bitmap2, sizeof(bitmap2));
> > >
> > > +     test_bitmap_find_next_zero_area_off(bitmap, BITMAP_LEN);
> > >       test_find_next_bit(bitmap, BITMAP_LEN);
> > >       test_find_next_zero_bit(bitmap, BITMAP_LEN);
> > >       test_find_last_bit(bitmap, BITMAP_LEN);
> > > @@ -181,6 +197,7 @@ static int __init find_bit_test(void)
> > >               __set_bit(get_random_u32_below(BITMAP_LEN), bitmap2);
> > >       }
> > >
> > > +     test_bitmap_find_next_zero_area_off(bitmap, BITMAP_LEN);
> > >       test_find_next_bit(bitmap, BITMAP_LEN);
> > >       test_find_next_zero_bit(bitmap, BITMAP_LEN);
> > >       test_find_last_bit(bitmap, BITMAP_LEN);
> > > diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c
> > > index 69813c10e6c0..12aa2ca37fe1 100644
> > > --- a/lib/test_bitmap.c
> > > +++ b/lib/test_bitmap.c
> > > @@ -234,6 +234,43 @@ static void __init test_find_nth_bit(void)
> > >       }
> > >  }
> > >
> > > +static void __init
> > > +test_bitmap_find_next_zero_area_off(void)
> > > +{
> > > +     DECLARE_BITMAP(bmap, 192);
> > > +
> > > +     bitmap_set(bmap, 0, 192);
> > > +
> > > +     bitmap_clear(bmap, 0, 8);
> > > +     __clear_bit(50, bmap);
> > > +     bitmap_clear(bmap, 60, 18);
> > > +     __set_bit(69, bmap);
> > > +     __clear_bit(80, bmap);
> > > +     bitmap_clear(bmap, 100, 10);
> > > +     __clear_bit(120, bmap);
> > > +     bitmap_clear(bmap, 145, 8);
> > > +     bitmap_clear(bmap, 160, 32);
> > > +
> > > +     expect_eq_uint(0,
> > > +             bitmap_find_next_zero_area_off(bmap, 192, 0, 8, 0, 0));
> > > +     expect_eq_uint(0,
> > > +             bitmap_find_next_zero_area_off(bmap, 192, 0, 8, 3, 0));
> > > +     expect_eq_uint(163,
> > > +             bitmap_find_next_zero_area_off(bmap, 192, 0, 8, 3, 1));
> > > +     expect_eq_uint(60,
> > > +             bitmap_find_next_zero_area_off(bmap, 192, 1, 8, 0, 0));
> > > +     expect_eq_uint(160,
> > > +             bitmap_find_next_zero_area_off(bmap, 192, 1, 8, 7, 0));
> > > +     expect_eq_uint(60,
> > > +             bitmap_find_next_zero_area_off(bmap, 192, 1, 8, 7, 4));
> > > +     expect_eq_uint(100,
> > > +             bitmap_find_next_zero_area_off(bmap, 192, 0, 10, 0, 0));
> > > +     expect_eq_uint(160,
> > > +             bitmap_find_next_zero_area_off(bmap, 192, 0, 32, 0, 0));
> > > +     expect_eq_uint(1,
> > > +             !!(bitmap_find_next_zero_area_off(bmap, 192, 0, 33, 0, 0) > 192));
> >
> > It should be >= here.
> 
> There would be a problem if the return value equals 192.
> size = 192;
> if (end > size)
> 	return end;
> So the return value must be greater than 192.

I agree with the patch you suggested that returns the size, so it needs to be changed to >= here.

> 
> >
> > > +}
> > > +
> > >  static void __init test_fill_set(void)
> > >  {
> > >       DECLARE_BITMAP(bmap, 1024);
> > > @@ -1559,6 +1596,7 @@ static void __init selftest(void)
> > >       test_for_each_clear_bitrange_from();
> > >       test_for_each_set_clump8();
> > >       test_for_each_set_bit_wrap();
> > > +     test_bitmap_find_next_zero_area_off();
> > >  }
> > >
> > >  KSTM_MODULE_LOADERS(test_bitmap);
> > > --
> > > 2.34.1

  parent reply	other threads:[~2026-06-18 12:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-18  1:52 [PATCH v5 0/2] Improve the performance of bitmap_find_next_zero_area_off() Yi Sun
2026-06-18  1:52 ` [PATCH v5 1/2] lib: bitmap: add tests for bitmap_find_next_zero_area_off() Yi Sun
2026-06-18  5:48   ` Yury Norov
2026-06-18  9:43     ` 答复: " 孙毅 (Yi Sun)
2026-06-18 12:44     ` 孙毅 (Yi Sun) [this message]
2026-06-19 14:01       ` Yury Norov
2026-06-18  1:52 ` [PATCH v5 2/2] lib: bitmap: optimize bitmap_find_next_zero_area_off() Yi Sun
2026-06-18  6:14   ` Yury Norov
2026-06-18  9:29     ` 答复: " 孙毅 (Yi Sun)

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=cf3b9ed0197040aa8d224715a1707a8c@BJMBX02.spreadtrum.com \
    --to=yi.sun@unisoc.com \
    --cc=279644543@qq.com \
    --cc=Ke.Wang@unisoc.com \
    --cc=akinobu.mita@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=fvdl@google.com \
    --cc=hch@lst.de \
    --cc=jstultz@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mina86@mina86.com \
    --cc=minchan@kernel.org \
    --cc=mnazarewicz@gmail.com \
    --cc=qiang.zhao@freescale.com \
    --cc=scottwood@freescale.com \
    --cc=song@kernel.org \
    --cc=tglx@kernel.org \
    --cc=tjmercier@google.com \
    --cc=yury.norov@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

all inboxes | Powered by JetHome®