From: Yury Norov <yury.norov@gmail.com>
To: linux-kernel@vger.kernel.org,
"Alexander Lobakin" <alexandr.lobakin@intel.com>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Arnd Bergmann" <arnd@arndb.de>,
"David Gow" <davidgow@google.com>,
"Eric Dumazet" <edumazet@google.com>,
"Isabella Basso" <isabbasso@riseup.net>,
"Kees Cook" <keescook@chromium.org>,
"Keith Busch" <kbusch@kernel.org>,
"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
"Marco Elver" <elver@google.com>,
"Mark Rutland" <mark.rutland@arm.com>,
"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Toke Høiland-Jørgensen" <toke@redhat.com>,
"Valentin Schneider" <vschneid@redhat.com>
Cc: Yury Norov <yury.norov@gmail.com>
Subject: [PATCH v3 0/5] lib/find: add find_nth_bit()
Date: Sat, 17 Sep 2022 20:07:10 -0700 [thread overview]
Message-ID: <20220918030716.1252285-1-yury.norov@gmail.com> (raw)
Kernel lacks for a function that searches for Nth bit in a bitmap.
Usually people do it like this:
for_each_set_bit(bit, mask, size)
if (n-- == 0)
return bit;
Which is not so elegant and very slow.
This series adds fast routines for this task, and applies them where
appropriate.
v1: https://lore.kernel.org/lkml/20220706182300.70862-4-yury.norov@gmail.com/T/
v2: https://lore.kernel.org/lkml/CAAH8bW_RYG_Tbpip=BkSFAymDm2y3jJBqTi0PJWA=H-a-L_3tg@mail.gmail.com/T/
v3:
- add bitmap_weight_and() and use it in cpumask_local_spread();
- rework find_nth_bit() family: similarly to [1], introduce
FIND_NTH_BIT(), and optimize the function to return earlier when
it's known that the rest of bitmap can't meet the requirement.
- patch "lib/nodemask: inline next_node_in() and node_random()" has
been merged, so drop it from this series.
On top of:
[1] https://lore.kernel.org/lkml/20220915020730.852234-1-yury.norov@gmail.com/T/
Yury Norov (6):
lib/bitmap: don't call __bitmap_weight() in kernel code
lib/bitmap: add bitmap_weight_and()
lib: add find_nth(,and,andnot)_bit()
lib/bitmap: add tests for find_nth_bit()
lib/bitmap: remove bitmap_ord_to_pos
cpumask: add cpumask_nth_{,and,andnot}
fs/ntfs3/bitmap.c | 4 +-
include/linux/bitmap.h | 13 +++++-
include/linux/bitops.h | 19 +++++++++
include/linux/cpumask.h | 55 +++++++++++++++++++++++++
include/linux/find.h | 86 ++++++++++++++++++++++++++++++++++++++++
include/linux/nodemask.h | 3 +-
lib/bitmap.c | 68 ++++++++++++-------------------
lib/cpumask.c | 28 ++++++-------
lib/find_bit.c | 44 ++++++++++++++++++++
lib/find_bit_benchmark.c | 18 +++++++++
lib/test_bitmap.c | 47 +++++++++++++++++++++-
11 files changed, 320 insertions(+), 65 deletions(-)
--
2.34.1
next reply other threads:[~2022-09-18 3:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-18 3:07 Yury Norov [this message]
2022-09-18 3:07 ` [PATCH v3 1/6] lib/bitmap: don't call __bitmap_weight() in kernel code Yury Norov
2022-09-18 3:07 ` [PATCH v3 2/6] lib/bitmap: add bitmap_weight_and() Yury Norov
2022-09-18 3:07 ` [PATCH v3 3/6] lib: add find_nth{,_and,_andnot}_bit() Yury Norov
2022-09-18 3:07 ` [PATCH v3 4/6] lib/bitmap: add tests for find_nth_bit() Yury Norov
2022-09-18 3:07 ` [PATCH v3 5/6] lib/bitmap: remove bitmap_ord_to_pos Yury Norov
2022-09-18 3:07 ` [PATCH v3 6/6] cpumask: add cpumask_nth_{,and,andnot} Yury Norov
2022-09-23 16:18 ` [PATCH v3 0/5] lib/find: add find_nth_bit() Yury Norov
2022-09-26 19:17 ` Yury Norov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220918030716.1252285-1-yury.norov@gmail.com \
--to=yury.norov@gmail.com \
--cc=alexandr.lobakin@intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@arndb.de \
--cc=davidgow@google.com \
--cc=edumazet@google.com \
--cc=elver@google.com \
--cc=isabbasso@riseup.net \
--cc=kbusch@kernel.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mark.rutland@arm.com \
--cc=memxor@gmail.com \
--cc=rostedt@goodmis.org \
--cc=toke@redhat.com \
--cc=vschneid@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).