mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: "K Prateek Nayak" <kprateek.nayak@amd.com>,
	"Thomas Gleixner" <tglx@kernel.org>,
	"Ingo Molnar" <mingo@redhat.com>,
	linux-kernel@vger.kernel.org,
	"Darren Hart" <dvhart@infradead.org>,
	"Davidlohr Bueso" <dave@stgolabs.net>,
	"André Almeida" <andrealmeid@igalia.com>
Subject: Re: [RFC PATCH] futex: Dynamically allocate futex_queues depending on nr_node_ids
Date: Fri, 27 Feb 2026 18:18:00 +0100	[thread overview]
Message-ID: <20260227171800.GK606826@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20260227171230.b4w4sE25@linutronix.de>

On Fri, Feb 27, 2026 at 06:12:30PM +0100, Sebastian Andrzej Siewior wrote:
> On 2026-02-27 17:18:41 [+0100], Peter Zijlstra wrote:
> > Ooh, I just remebered, I've always wanted to apply Linus' runtime-const
> > stuff to the futex thing.
> 
> I wasn't aware we have this, I did want to do/ have something like this.
> 
> Need to look at this in detail but…
> 
> > --- a/kernel/futex/core.c
> > +++ b/kernel/futex/core.c
> > @@ -439,14 +442,14 @@ __futex_hash(union futex_key *key, struct futex_private_hash *fph)
> >  		 * NOTE: this isn't perfectly uniform, but it is fast and
> >  		 * handles sparse node masks.
> >  		 */
> > -		node = (hash >> futex_hashshift) % nr_node_ids;
> > +		node = runtime_const_shift_right_32(hash, __futex_shift) % nr_node_ids;
> 
> getting rid of that div here would be the next step. If we could round
> it up to the next pow2 then we could avoid it. But I remember it did not
> show up in bench as much as I was thinking it would.

Right, modern x86 seems really rather good at division (unlike a few
years ago).

But yes, it would be nice to do better there.

  reply	other threads:[~2026-02-27 17:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-28 10:13 K Prateek Nayak
2026-02-24 11:13 ` Sebastian Andrzej Siewior
2026-02-25  3:36   ` K Prateek Nayak
2026-02-25  7:39     ` Sebastian Andrzej Siewior
2026-02-25  8:51       ` K Prateek Nayak
2026-02-25  9:22         ` Sebastian Andrzej Siewior
2026-02-27  8:47           ` K Prateek Nayak
2026-02-27 15:15             ` Sebastian Andrzej Siewior
2026-02-27 16:04               ` K Prateek Nayak
2026-02-27 14:42 ` Peter Zijlstra
2026-02-27 14:59   ` K Prateek Nayak
2026-02-27 16:18     ` Peter Zijlstra
2026-02-27 17:12       ` Sebastian Andrzej Siewior
2026-02-27 17:18         ` Peter Zijlstra [this message]
2026-03-02  4:59       ` K Prateek Nayak

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=20260227171800.GK606826@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=andrealmeid@igalia.com \
    --cc=bigeasy@linutronix.de \
    --cc=dave@stgolabs.net \
    --cc=dvhart@infradead.org \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@kernel.org \
    /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

Powered by JetHome