All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Jaewon Kim <jaewon31.kim@samsung.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	labbott@redhat.com, Michal Nazarewicz <mina86@mina86.com>,
	m.szyprowski@samsung.com, gregory.0xf0@gmail.com,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	akinobu.mita@gmail.com, linux-mm@kvack.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	jaewon31.kim@gmail.com
Subject: Re: [PATCH] lib: bitmap: introduce bitmap_find_next_zero_area_and_size
Date: Mon, 16 Jan 2017 19:59:50 +0200	[thread overview]
Message-ID: <CAHp75VfO6POaH+AsoS9kU1y+CEKwuJ0FNSB8Bg866X3iXS9DRA@mail.gmail.com> (raw)
In-Reply-To: <1482725891-10866-1-git-send-email-jaewon31.kim@samsung.com>

On Mon, Dec 26, 2016 at 6:18 AM, Jaewon Kim <jaewon31.kim@samsung.com> wrote:
> There was no bitmap API which returns both next zero index and size of zeros
> from that index.
>
> This is helpful to look fragmentation. This is an test code to look size of zeros.
> Test result is '10+9+994=>1013 found of total: 1024'
>
> unsigned long search_idx, found_idx, nr_found_tot;
> unsigned long bitmap_max;
> unsigned int nr_found;
> unsigned long *bitmap;
>
> search_idx = nr_found_tot = 0;
> bitmap_max = 1024;
> bitmap = kzalloc(BITS_TO_LONGS(bitmap_max) * sizeof(long),
>                  GFP_KERNEL);
>
> /* test bitmap_set offset, count */
> bitmap_set(bitmap, 10, 1);
> bitmap_set(bitmap, 20, 10);
>
> for (;;) {
>         found_idx = bitmap_find_next_zero_area_and_size(bitmap,
>                                 bitmap_max, search_idx, &nr_found);
>         if (found_idx >= bitmap_max)
>                 break;
>         if (nr_found_tot == 0)
>                 printk("%u", nr_found);
>         else
>                 printk("+%u", nr_found);
>         nr_found_tot += nr_found;
>         search_idx = found_idx + nr_found;
> }
> printk("=>%lu found of total: %lu\n", nr_found_tot, bitmap_max);

Tests should be added to corresponding test module. See lib/*test*
files for details.

-- 
With Best Regards,
Andy Shevchenko

WARNING: multiple messages have this Message-ID (diff)
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Jaewon Kim <jaewon31.kim@samsung.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	labbott@redhat.com, Michal Nazarewicz <mina86@mina86.com>,
	m.szyprowski@samsung.com, gregory.0xf0@gmail.com,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	akinobu.mita@gmail.com, linux-mm@kvack.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	jaewon31.kim@gmail.com
Subject: Re: [PATCH] lib: bitmap: introduce bitmap_find_next_zero_area_and_size
Date: Mon, 16 Jan 2017 19:59:50 +0200	[thread overview]
Message-ID: <CAHp75VfO6POaH+AsoS9kU1y+CEKwuJ0FNSB8Bg866X3iXS9DRA@mail.gmail.com> (raw)
In-Reply-To: <1482725891-10866-1-git-send-email-jaewon31.kim@samsung.com>

On Mon, Dec 26, 2016 at 6:18 AM, Jaewon Kim <jaewon31.kim@samsung.com> wrote:
> There was no bitmap API which returns both next zero index and size of zeros
> from that index.
>
> This is helpful to look fragmentation. This is an test code to look size of zeros.
> Test result is '10+9+994=>1013 found of total: 1024'
>
> unsigned long search_idx, found_idx, nr_found_tot;
> unsigned long bitmap_max;
> unsigned int nr_found;
> unsigned long *bitmap;
>
> search_idx = nr_found_tot = 0;
> bitmap_max = 1024;
> bitmap = kzalloc(BITS_TO_LONGS(bitmap_max) * sizeof(long),
>                  GFP_KERNEL);
>
> /* test bitmap_set offset, count */
> bitmap_set(bitmap, 10, 1);
> bitmap_set(bitmap, 20, 10);
>
> for (;;) {
>         found_idx = bitmap_find_next_zero_area_and_size(bitmap,
>                                 bitmap_max, search_idx, &nr_found);
>         if (found_idx >= bitmap_max)
>                 break;
>         if (nr_found_tot == 0)
>                 printk("%u", nr_found);
>         else
>                 printk("+%u", nr_found);
>         nr_found_tot += nr_found;
>         search_idx = found_idx + nr_found;
> }
> printk("=>%lu found of total: %lu\n", nr_found_tot, bitmap_max);

Tests should be added to corresponding test module. See lib/*test*
files for details.

-- 
With Best Regards,
Andy Shevchenko

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2017-01-16 17:59 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20161226041809epcas5p1981244de55764c10f1a80d80346f3664@epcas5p1.samsung.com>
2016-12-26  4:18 ` [PATCH] lib: bitmap: introduce bitmap_find_next_zero_area_and_size Jaewon Kim
2016-12-26  4:18   ` Jaewon Kim
2016-12-26 21:09   ` Michal Nazarewicz
2016-12-26 21:09     ` Michal Nazarewicz
2016-12-27  4:14     ` Jaewon Kim
2016-12-27  4:14       ` Jaewon Kim
2016-12-27 10:05   ` Michal Hocko
2016-12-27 10:05     ` Michal Hocko
2016-12-28  4:41     ` Jaewon Kim
2016-12-28  4:41       ` Jaewon Kim
2016-12-28  8:32       ` Michal Hocko
2016-12-28  8:32         ` Michal Hocko
2016-12-28 14:14       ` Michal Nazarewicz
2016-12-28 14:14         ` Michal Nazarewicz
2016-12-29  2:13         ` Jaewon Kim
2016-12-29  2:13           ` Jaewon Kim
2017-01-15  7:17   ` Yury Norov
2017-01-15  7:17     ` Yury Norov
2017-01-17  3:22     ` Jaewon Kim
2017-01-17  3:22       ` Jaewon Kim
2017-01-16 17:59   ` Andy Shevchenko [this message]
2017-01-16 17:59     ` 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=CAHp75VfO6POaH+AsoS9kU1y+CEKwuJ0FNSB8Bg866X3iXS9DRA@mail.gmail.com \
    --to=andy.shevchenko@gmail.com \
    --cc=akinobu.mita@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=gregory.0xf0@gmail.com \
    --cc=jaewon31.kim@gmail.com \
    --cc=jaewon31.kim@samsung.com \
    --cc=labbott@redhat.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mina86@mina86.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.