Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1559957 > unrolled thread

Re: [PATCH] lib: bitmap: introduce bitmap_find_next_zero_area_and_size

Started byAndy Shevchenko <andy.shevchenko@gmail.com>
First post2017-01-16 19:10 +0100
Last post2017-01-16 19:10 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] lib: bitmap: introduce bitmap_find_next_zero_area_and_size Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-01-16 19:10 +0100

#1559957 — Re: [PATCH] lib: bitmap: introduce bitmap_find_next_zero_area_and_size

FromAndy Shevchenko <andy.shevchenko@gmail.com>
Date2017-01-16 19:10 +0100
SubjectRe: [PATCH] lib: bitmap: introduce bitmap_find_next_zero_area_and_size
Message-ID<t0jTb-42i-3@gated-at.bofh.it>
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

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web