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
| ||
|
Date: Fri, 28 Jan 2022 06:59:14 +0000 From: "Vaittinen, Matti" <Matti.Vaittinen@...rohmeurope.com> To: Yury Norov <yury.norov@...il.com>, Andy Shevchenko <andriy.shevchenko@...ux.intel.com>, 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>, Alexey Klimov <aklimov@...hat.com>, "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org> Subject: Re: [PATCH 27/54] lib/bitmap: add bitmap_weight_{cmp, eq, gt, ge, lt, le} functions On 1/23/22 20:38, 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. > The following patches apply new functions where appropriate. > Thanks for pushing this improvement Yury. Seeing how much this has evolved from the single_bit_set() suggestion - it'd be a bit thick from me to add a suggested-by ;) I did review it though and it looks good to me! Reviewed-by: Matti Vaittinen <matti.vaittinen@...rohmeurope.com> > Suggested-by: "Michał Mirosław" <mirq-linux@...e.qmqm.pl> (for bitmap_weight_cmp) > Signed-off-by: Yury Norov <yury.norov@...il.com> > --- > include/linux/bitmap.h | 80 ++++++++++++++++++++++++++++++++++++++++++ > lib/bitmap.c | 21 +++++++++++ > 2 files changed, 101 insertions(+) -- The Linux Kernel guy at ROHM Semiconductors Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~ this year is the year of a signature writers block ~~
Powered by blists - more mailing lists