[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20150324155303.f5ced0c3395e315319a0c9e6@linux-foundation.org>
Date: Tue, 24 Mar 2015 15:53:03 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Yury Norov <yury.norov@...il.com>
Cc: linux@...izon.com, klimov.linux@...il.com,
linux@...musvillemoes.dk, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] lib: bitmap_[empty,full]: remove code duplication
On Mon, 16 Mar 2015 20:56:39 +0300 Yury Norov <yury.norov@...il.com> wrote:
> Function 'bitmap_empty' has it's own implementation.
> But it's clearly as simple as:
> "find_first_bit(src, nbits) == nbits"
> The same is true for 'bitmap_full'.
>
> Underscored versions of 'bitmap_[empty,full]' are not
> needed anymore and so removed too.
>
> Boot-tested on Core i7-2630QM.
>
> --- a/include/linux/bitmap.h
> +++ b/include/linux/bitmap.h
> @@ -285,18 +285,12 @@ static inline int bitmap_subset(const unsigned long *src1,
>
> static inline int bitmap_empty(const unsigned long *src, unsigned nbits)
> {
> - if (small_const_nbits(nbits))
> - return ! (*src & BITMAP_LAST_WORD_MASK(nbits));
> - else
> - return __bitmap_empty(src, nbits);
> + return find_first_bit(src, nbits) == nbits;
> }
But we lost the small_const_nbits() optimization, and that will be a
common case.
Would it be better to do
if (small_const_nbits(...))
...
else
find_first_bit(...);
?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists