From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: linux-kernel@vger.kernel.org
Cc: "André Almeida" <andrealmeid@igalia.com>,
"Darren Hart" <dvhart@infradead.org>,
"Davidlohr Bueso" <dave@stgolabs.net>,
"Ingo Molnar" <mingo@redhat.com>,
"Juri Lelli" <juri.lelli@redhat.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Valentin Schneider" <vschneid@redhat.com>,
"Waiman Long" <longman@redhat.com>
Subject: Re: [PATCH v11 15/19] futex: Implement FUTEX2_NUMA
Date: Thu, 17 Apr 2025 17:34:51 +0200 [thread overview]
Message-ID: <20250417153451.b50sWh_Z@linutronix.de> (raw)
In-Reply-To: <20250407165224.z0FmVaXX@linutronix.de>
On 2025-04-07 18:52:25 [+0200], To linux-kernel@vger.kernel.org wrote:
> On 2025-04-07 17:57:38 [+0200], To linux-kernel@vger.kernel.org wrote:
> > --- a/kernel/futex/core.c
> > +++ b/kernel/futex/core.c
> > @@ -332,15 +337,35 @@ __futex_hash(union futex_key *key, struct futex_private_hash *fph)
> …
> > + if (node == FUTEX_NO_NODE) {
> > + /*
> > + * In case of !FLAGS_NUMA, use some unused hash bits to pick a
> > + * node -- this ensures regular futexes are interleaved across
> > + * the nodes and avoids having to allocate multiple
> > + * hash-tables.
> > + *
> > + * NOTE: this isn't perfectly uniform, but it is fast and
> > + * handles sparse node masks.
> > + */
> > + node = (hash >> futex_hashshift) % nr_node_ids;
>
> forgot to mention earlier: This % nr_node_ids turns into div and it is
> visible in perf top while looking at __futex_hash(). We could round it
> down to a power-of-two (which should be the case in my 1, 2 and 4 based
> NUMA world) and then we could use AND instead.
> ARM does not support NUMA or div so it is not a concern.
>
> Maybe a fast path for 1/2/4 would make sense since it is the most common
> one. In case you consider it I could run test to see how significant it
> is. It might be that it pops up in "perf bench futex hash" but not be
> significant in general use case. I had some hacks and those did not
> improve the numbers as much as I hoped for.
Since I'm cleaning up: I'm getting approx 1% improvement with this so I
am not considering it.
Sebastian
next prev parent reply other threads:[~2025-04-17 15:34 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-07 15:57 [PATCH v11 00/19] futex: Add support task local hash maps, FUTEX2_NUMA and FUTEX2_MPOL Sebastian Andrzej Siewior
2025-04-07 15:57 ` [PATCH v11 01/19] rcuref: Provide rcuref_is_dead() Sebastian Andrzej Siewior
2025-04-07 15:57 ` [PATCH v11 02/19] mm: Add vmalloc_huge_node() Sebastian Andrzej Siewior
2025-04-07 15:57 ` [PATCH v11 03/19] futex: Move futex_queue() into futex_wait_setup() Sebastian Andrzej Siewior
2025-04-07 15:57 ` [PATCH v11 04/19] futex: Pull futex_hash() out of futex_q_lock() Sebastian Andrzej Siewior
2025-04-07 15:57 ` [PATCH v11 05/19] futex: Create hb scopes Sebastian Andrzej Siewior
2025-04-07 15:57 ` [PATCH v11 06/19] futex: Create futex_hash() get/put class Sebastian Andrzej Siewior
2025-04-07 15:57 ` [PATCH v11 07/19] futex: Create private_hash() " Sebastian Andrzej Siewior
2025-04-07 15:57 ` [PATCH v11 08/19] futex: Acquire a hash reference in futex_wait_multiple_setup() Sebastian Andrzej Siewior
2025-04-07 15:57 ` [PATCH v11 09/19] futex: Decrease the waiter count before the unlock operation Sebastian Andrzej Siewior
2025-04-07 15:57 ` [PATCH v11 10/19] futex: Introduce futex_q_lockptr_lock() Sebastian Andrzej Siewior
2025-04-07 15:57 ` [PATCH v11 11/19] futex: Create helper function to initialize a hash slot Sebastian Andrzej Siewior
2025-04-07 15:57 ` [PATCH v11 12/19] futex: Add basic infrastructure for local task local hash Sebastian Andrzej Siewior
2025-04-07 15:57 ` [PATCH v11 13/19] futex: Allow automatic allocation of process wide futex hash Sebastian Andrzej Siewior
2025-04-07 15:57 ` [PATCH v11 14/19] futex: Allow to resize the private local hash Sebastian Andrzej Siewior
2025-04-07 15:57 ` [PATCH v11 15/19] futex: Implement FUTEX2_NUMA Sebastian Andrzej Siewior
2025-04-07 16:52 ` Sebastian Andrzej Siewior
2025-04-17 15:34 ` Sebastian Andrzej Siewior [this message]
2025-04-07 15:57 ` [PATCH v11 16/19] futex: Implement FUTEX2_MPOL Sebastian Andrzej Siewior
2025-04-07 15:57 ` [PATCH v11 17/19] tools headers: Synchronize prctl.h ABI header Sebastian Andrzej Siewior
2025-04-07 15:57 ` [PATCH v11 18/19] tools/perf: Allow to select the number of hash buckets Sebastian Andrzej Siewior
2025-04-07 15:57 ` [PATCH v11 19/19] futex: Allow to make the private hash immutable Sebastian Andrzej Siewior
2025-04-10 10:56 ` Sebastian Andrzej Siewior
2025-04-10 14:52 ` Shrikanth Hegde
2025-04-10 15:28 ` Sebastian Andrzej Siewior
2025-04-10 15:48 ` Shrikanth Hegde
2025-04-07 16:00 ` [PATCH v11 00/19] futex: Add support task local hash maps, FUTEX2_NUMA and FUTEX2_MPOL Sebastian Andrzej Siewior
2025-04-08 13:51 ` André Almeida
2025-04-08 16:13 ` Sebastian Andrzej Siewior
2025-04-10 17:51 ` Shrikanth Hegde
2025-04-15 9:03 ` Sebastian Andrzej Siewior
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=20250417153451.b50sWh_Z@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=andrealmeid@igalia.com \
--cc=dave@stgolabs.net \
--cc=dvhart@infradead.org \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=vschneid@redhat.com \
/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