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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aEC-04zhtWh04b_F@yury>
Date: Wed, 4 Jun 2025 17:46:59 -0400
From: Yury Norov <yury.norov@...il.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org,
	Rasmus Villemoes <linux@...musvillemoes.dk>,
	John Stultz <jstultz@...gle.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Stephen Boyd <sboyd@...nel.org>
Subject: Re: [PATCH 1/3] bitmap: generalize node_random()

On Wed, Jun 04, 2025 at 02:34:42PM -0700, Andrew Morton wrote:
> On Wed,  4 Jun 2025 17:21:21 -0400 Yury Norov <yury.norov@...il.com> wrote:
> 
> > Generalize node_random and make it available to general bitmaps and
> > cpumasks users.
> 
> Seems sensible.
> 
> > --- a/lib/find_bit.c
> > +++ b/lib/find_bit.c
> >  
> > +unsigned long find_random_bit(const unsigned long *addr, unsigned long size)
> > +{
> > +	int w = bitmap_weight(addr, size);
> > +
> > +	switch (w) {
> > +	case 0:
> > +		return size;
> > +	case 1:
> > +		return find_first_bit(addr, size);
> 
> Is the `1' special case useful?  The `default' case should still work OK?

find_first_bit() is faster that find_nth_bit(), so this is a
performance optimization. See 3e061d924fe9c7b4 ("lib/nodemask: optimize
node_random for nodemask with single NUMA node").
 
> > +	default:
> > +		return find_nth_bit(addr, size, get_random_u32_below(w));
> > +	}
> > +}
> > +EXPORT_SYMBOL(find_random_bit);
> 
> Some kerneldoc, please?

Indeed, will send v2.

> Of course, the hard-coding of get_random_u32_below() might be
> unsuitable for some future potential callers but we can deal with that
> if it ever occurs.

Can you please elaborate?

Thanks,
Yury

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ