Re: [PATCH 2/9] lib/bitmap: implement bitmap_{empty,full} with bitmap_weight_eq()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: Yury Norov <yury.norov@xxxxxxxxx>
- Subject: Re: [PATCH 2/9] lib/bitmap: implement bitmap_{empty,full} with bitmap_weight_eq()
- From: Michał Mirosław <mirq-linux@xxxxxxxxxxxx>
- Date: Sun, 28 Nov 2021 19:10:20 +0100
- Cc: linux-kernel@xxxxxxxxxxxxxxx, "James E.J. Bottomley" <jejb@xxxxxxxxxxxxx>, "Martin K. Petersen" <martin.petersen@xxxxxxxxxx>, "Paul E. McKenney" <paulmck@xxxxxxxxxx>, "Rafael J. Wysocki" <rafael@xxxxxxxxxx>, Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>, Alexey Klimov <aklimov@xxxxxxxxxx>, Amitkumar Karwar <amitkarwar@xxxxxxxxx>, Andi Kleen <ak@xxxxxxxxxxxxxxx>, Andrew Lunn <andrew@xxxxxxx>, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, Andy Gross <agross@xxxxxxxxxx>, Andy Lutomirski <luto@xxxxxxxxxx>, Andy Shevchenko <andy@xxxxxxxxxxxxx>, Anup Patel <anup.patel@xxxxxxx>, Ard Biesheuvel <ardb@xxxxxxxxxx>, Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>, Arnd Bergmann <arnd@xxxxxxxx>, Borislav Petkov <bp@xxxxxxxxx>, Catalin Marinas <catalin.marinas@xxxxxxx>, Christoph Hellwig <hch@xxxxxx>, Christoph Lameter <cl@xxxxxxxxx>, Daniel Vetter <daniel@xxxxxxxx>, Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>, David Airlie <airlied@xxxxxxxx>, David Laight <David.Laight@xxxxxxxxxx>, Dennis Zhou <dennis@xxxxxxxxxx>, Dinh Nguyen <dinguyen@xxxxxxxxxx>, Geetha sowjanya <gakula@xxxxxxxxxxx>, Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>, Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>, Guo Ren <guoren@xxxxxxxxxx>, Hans de Goede <hdegoede@xxxxxxxxxx>, Heiko Carstens <hca@xxxxxxxxxxxxx>, Ian Rogers <irogers@xxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Jakub Kicinski <kuba@xxxxxxxxxx>, Jason Wessel <jason.wessel@xxxxxxxxxxxxx>, Jens Axboe <axboe@xxxxxx>, Jiri Olsa <jolsa@xxxxxxxxxx>, Jonathan Cameron <jic23@xxxxxxxxxx>, Juri Lelli <juri.lelli@xxxxxxxxxx>, Kalle Valo <kvalo@xxxxxxxxxxxxxx>, Kees Cook <keescook@xxxxxxxxxxxx>, Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxxxxx>, Lee Jones <lee.jones@xxxxxxxxxx>, Marc Zyngier <maz@xxxxxxxxxx>, Marcin Wojtas <mw@xxxxxxxxxxxx>, Mark Gross <markgross@xxxxxxxxxx>, Mark Rutland <mark.rutland@xxxxxxx>, Matti Vaittinen <mazziesaccount@xxxxxxxxx>, Mauro Carvalho Chehab <mchehab@xxxxxxxxxx>, Mel Gorman <mgorman@xxxxxxx>, Michael Ellerman <mpe@xxxxxxxxxxxxxx>, Mike Marciniszyn <mike.marciniszyn@xxxxxxxxxxxxxxxxxxxx>, Nicholas Piggin <npiggin@xxxxxxxxx>, Palmer Dabbelt <palmer@xxxxxxxxxxx>, Peter Zijlstra <peterz@xxxxxxxxxxxxx>, Petr Mladek <pmladek@xxxxxxxx>, Randy Dunlap <rdunlap@xxxxxxxxxxxxx>, Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>, Roy Pledge <Roy.Pledge@xxxxxxx>, Russell King <linux@xxxxxxxxxxxxxxx>, Saeed Mahameed <saeedm@xxxxxxxxxx>, Sagi Grimberg <sagi@xxxxxxxxxxx>, Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx>, Solomon Peachy <pizza@xxxxxxxxxxxx>, Stephen Boyd <sboyd@xxxxxxxxxx>, Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx>, Steven Rostedt <rostedt@xxxxxxxxxxx>, Subbaraya Sundeep <sbhatta@xxxxxxxxxxx>, Sudeep Holla <sudeep.holla@xxxxxxx>, Sunil Goutham <sgoutham@xxxxxxxxxxx>, Tariq Toukan <tariqt@xxxxxxxxxx>, Tejun Heo <tj@xxxxxxxxxx>, Thomas Bogendoerfer <tsbogend@xxxxxxxxxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Ulf Hansson <ulf.hansson@xxxxxxxxxx>, Vincent Guittot <vincent.guittot@xxxxxxxxxx>, Vineet Gupta <vgupta@xxxxxxxxxx>, Viresh Kumar <viresh.kumar@xxxxxxxxxx>, Vivien Didelot <vivien.didelot@xxxxxxxxx>, Vlastimil Babka <vbabka@xxxxxxx>, Will Deacon <will@xxxxxxxxxx>, bcm-kernel-feedback-list@xxxxxxxxxxxx, kvm@xxxxxxxxxxxxxxx, linux-alpha@xxxxxxxxxxxxxxx, linux-arm-kernel@xxxxxxxxxxxxxxxxxxx, linux-crypto@xxxxxxxxxxxxxxx, linux-csky@xxxxxxxxxxxxxxx, linux-ia64@xxxxxxxxxxxxxxx, linux-mips@xxxxxxxxxxxxxxx, linux-mm@xxxxxxxxx, linux-perf-users@xxxxxxxxxxxxxxx, linux-riscv@xxxxxxxxxxxxxxxxxxx, linux-s390@xxxxxxxxxxxxxxx, linux-snps-arc@xxxxxxxxxxxxxxxxxxx, linuxppc-dev@xxxxxxxxxxxxxxxx
- In-reply-to: <20211128035704.270739-3-yury.norov@gmail.com>
- References: <20211128035704.270739-1-yury.norov@gmail.com> <20211128035704.270739-3-yury.norov@gmail.com>
On Sat, Nov 27, 2021 at 07:56:57PM -0800, Yury Norov wrote:
> Now as we have bitmap_weight_eq(), switch bitmap_full() and
> bitmap_empty() to using it.
>
> Signed-off-by: Yury Norov <yury.norov@xxxxxxxxx>
> ---
> include/linux/bitmap.h | 26 ++++++++++----------------
> 1 file changed, 10 insertions(+), 16 deletions(-)
>
> diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
> index 996041f771c8..2d951e4dc814 100644
> --- a/include/linux/bitmap.h
> +++ b/include/linux/bitmap.h
> @@ -386,22 +386,6 @@ static inline int bitmap_subset(const unsigned long *src1,
> return __bitmap_subset(src1, src2, nbits);
> }
>
> -static inline bool bitmap_empty(const unsigned long *src, unsigned nbits)
> -{
> - if (small_const_nbits(nbits))
> - return ! (*src & BITMAP_LAST_WORD_MASK(nbits));
> -
> - return find_first_bit(src, nbits) == nbits;
> -}
Since this is supposed to be an optimization, I would go all the way and
replace this with the trivial implementation instead:
bool bitmap_empty(long *bits, size_t nbits)
{
for (; nbits >= BITS_PER_LONG; ++bits, nbits -= BITS_PER_LONG)
if (*bits)
return false;
if (nbits && *bits & BITMAP_LAST_WORD_MASK(nbits))
return false;
return true;
}
Best Regards
Michał Mirosław
[Index of Archives]
[Linux Kernel]
[Sparc Linux]
[DCCP]
[Linux ARM]
[Yosemite News]
[Linux SCSI]
[Linux x86_64]
[Linux for Ham Radio]