[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwiHFiWGbMv5G0u81rj77Y-HpFLYacx-NE2SR-29BMFGq3tqg@mail.gmail.com>
Date: Wed, 24 May 2017 14:38:15 +0200
From: Rasmus Villemoes <linux@...musvillemoes.dk>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
LKML <linux-kernel@...r.kernel.org>,
Martin Schwidefsky <schwidefsky@...ibm.com>
Subject: Re: bitmap API consistency
On 24 May 2017 at 14:11, Andy Shevchenko
<andriy.shevchenko@...ux.intel.com> wrote:
> Hi!
>
> Surprisingly discovered today that bitmap API is not consistent in some
> cases (at least one I found recently).
>
> bitmap_fill() sets area of bits in a bitmap.
> bitmap_zero() clears them.
>
> However, if _fill() does something sane, _zero() clears _all_ bits up to
> word size (long).
>
> I think it should be fixed to be consistent with _fill() variant.
What do you want it to do? It always acts on whole words, so the last
word must be set to something. One might as well say that _zero and
_fill are consistent in that they both set the bits beyond nbits in
the last word to 0.
If anything, I'd change bitmap_fill to do a memset(0xff) of the entire
region. There used to be bugs where some of the bitmap_* functions
didn't actually ignore the trailing bits, making it somewhat important
that they were always 0, but I think they're fixed now.
Note that if one wants a guarantee that the trailing bits are not
touched at all, the APIs to use are bitmap_{set, clear}(dst, 0,
count). bitmap_{zero,fill} assumes that nbits is the total size of the
bitmap (i.e. that the user will never care about bits beyond nbits).
Maybe a few comments could be added somewhere.
Rasmus
Powered by blists - more mailing lists