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: <20250205080531.9cCHabrf@linutronix.de>
Date: Wed, 5 Feb 2025 09:05:31 +0100
From: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
To: Peter Zijlstra <peterz@...radead.org>
Cc: linux-kernel@...r.kernel.org,
	André Almeida <andrealmeid@...lia.com>,
	Darren Hart <dvhart@...radead.org>,
	Davidlohr Bueso <dave@...olabs.net>, Ingo Molnar <mingo@...hat.com>,
	Juri Lelli <juri.lelli@...hat.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Valentin Schneider <vschneid@...hat.com>,
	Waiman Long <longman@...hat.com>
Subject: Re: [PATCH v8 13/15] futex: Resize local futex hash table based on
 number of threads.

On 2025-02-04 11:21:46 [+0100], Peter Zijlstra wrote:
> On Mon, Feb 03, 2025 at 02:59:33PM +0100, Sebastian Andrzej Siewior wrote:
> > Automatically size the local hash based on the number of threads. The
> > logic tries to allocate between 16 and futex_hashsize (the default for
> > the system wide hash bucket) and uses 4 * number-of-threads.
> > On CONFIG_BASE_SMALL configs the suggested size is always 2.
> 
> > +	scoped_guard(rcu) {
> > +		threads = get_nr_threads(current);
> 
> How about something like:
> 
> 		threads = min(get_nr_threads(), num_online_cpus())
> 
> ?
makes sense.

> > +		hb_p = rcu_dereference(current->mm->futex_phash);
> > +		if (hb_p)
> > +			current_buckets = hb_p->hash_mask + 1;
> > +	}
> > +
> > +	if (IS_ENABLED(CONFIG_BASE_SMALL)) {
> > +		buckets = 2;
> > +
> 
> Or... you just disable the local thing entirely for BASE_SMALL and have
> it fall back to the global hash.

Okay, why not.

> > +	} else {
> > +		/*
> > +		 * The default allocation will remain within
> > +		 *   16 <= threads * 4 <= global hash size
> > +		 */
> > +		buckets = roundup_pow_of_two(4 * threads);
> > +		buckets = max(buckets, 16);
> > +		buckets = min(buckets, futex_hashsize);
> > +	}
> > +	if (current_buckets >= buckets)
> > +		return 0;
> > +
> > +	return futex_hash_allocate(buckets);
> >  }
> >  
> >  static int futex_hash_get_slots(void)

Sebastian

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ