lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220918030716.1252285-1-yury.norov@gmail.com>
Date:   Sat, 17 Sep 2022 20:07:10 -0700
From:   Yury Norov <yury.norov@...il.com>
To:     linux-kernel@...r.kernel.org,
        Alexander Lobakin <alexandr.lobakin@...el.com>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Arnd Bergmann <arnd@...db.de>, David Gow <davidgow@...gle.com>,
        Eric Dumazet <edumazet@...gle.com>,
        Isabella Basso <isabbasso@...eup.net>,
        Kees Cook <keescook@...omium.org>,
        Keith Busch <kbusch@...nel.org>,
        Kumar Kartikeya Dwivedi <memxor@...il.com>,
        Marco Elver <elver@...gle.com>,
        Mark Rutland <mark.rutland@....com>,
        Rasmus Villemoes <linux@...musvillemoes.dk>,
        Steven Rostedt <rostedt@...dmis.org>,
        Toke Høiland-Jørgensen <toke@...hat.com>,
        Valentin Schneider <vschneid@...hat.com>
Cc:     Yury Norov <yury.norov@...il.com>
Subject: [PATCH v3 0/5] lib/find: add find_nth_bit()

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ