Re: [RFC PATCH] futex: Dynamically allocate futex_queues depending on nr_node_ids
From: Sebastian Andrzej Siewior
Date: Fri Feb 27 2026 - 12:12:43 EST
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.
> if (!node_possible(node)) {
Sebastian