[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAH8bW-i5C==goN8GoVG70Hivobf1F53vj42VCBwWBHZ8iEcdw@mail.gmail.com>
Date: Wed, 26 Jan 2022 07:56:16 -0800
From: Yury Norov <yury.norov@...il.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Rasmus Villemoes <linux@...musvillemoes.dk>,
Andrew Morton <akpm@...ux-foundation.org>,
Michał Mirosław <mirq-linux@...e.qmqm.pl>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Peter Zijlstra <peterz@...radead.org>,
David Laight <David.Laight@...lab.com>,
Joe Perches <joe@...ches.com>, Dennis Zhou <dennis@...nel.org>,
Emil Renner Berthing <kernel@...il.dk>,
Nicholas Piggin <npiggin@...il.com>,
Matti Vaittinen <matti.vaittinen@...rohmeurope.com>,
Alexey Klimov <aklimov@...hat.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 27/54] lib/bitmap: add bitmap_weight_{cmp, eq, gt, ge, lt,
le} functions
On Mon, Jan 24, 2022 at 4:42 AM Andy Shevchenko
<andriy.shevchenko@...ux.intel.com> wrote:
>
> On Sun, Jan 23, 2022 at 10:38:58AM -0800, Yury Norov wrote:
> > Many kernel users use bitmap_weight() to compare the result against
> > some number or expression:
> >
> > if (bitmap_weight(...) > 1)
> > do_something();
> >
> > It works OK, but may be significantly improved for large bitmaps: if
> > first few words count set bits to a number greater than given, we can
> > stop counting and immediately return.
> >
> > The same idea would work in other direction: if we know that the number
> > of set bits that we counted so far is small enough, so that it would be
> > smaller than required number even if all bits of the rest of the bitmap
> > are set, we can stop counting earlier.
> >
> > This patch adds new bitmap_weight_cmp() as suggested by Michał Mirosław
> > and a family of eq, gt, ge, lt and le wrappers to allow this optimization.
>
> lt, and le
>
> > The following patches apply new functions where appropriate.
>
> What I missed in the above message is the rough statistics like some of them
> are used more often, some less, and some, perhaps, just added for the sake of
> symmetry (the latter is what would be important to see if there are APIs which
> have no users at all).
These are my grep numbers. Some lines are declarations and comments, so minus
6 or 8 for each number, but all new functions have actual users.
$ git grep weight_eq|wc -l
35
$ git grep weight_gt|wc -l
20
$ git grep weight_ge|wc -l
25
$ git grep weight_lt|wc -l
14
$ git grep weight_le|wc -l
18
Powered by blists - more mailing lists