Re: [PATCH v10 20/21] futex: Implement FUTEX2_NUMA
From: Sebastian Andrzej Siewior
Date: Wed Mar 26 2025 - 04:03:39 EST
On 2025-03-26 01:22:19 [+0530], Shrikanth Hegde wrote:
> > diff --git a/kernel/futex/core.c b/kernel/futex/core.c
> > index bc7451287b2ce..b9da7dc6a900a 100644
> > --- a/kernel/futex/core.c
> > +++ b/kernel/futex/core.c
> > @@ -1597,24 +1646,41 @@ int futex_hash_prctl(unsigned long arg2, unsigned long arg3)
> > static int __init futex_init(void)
> > {
> > unsigned long hashsize, i;
> > - unsigned int futex_shift;
> > + unsigned int order, n;
> > + unsigned long size;
> > #ifdef CONFIG_BASE_SMALL
> > hashsize = 16;
> > #else
> > - hashsize = roundup_pow_of_two(256 * num_possible_cpus());
> > + hashsize = 256 * num_possible_cpus();
> > + hashsize /= num_possible_nodes();
>
> Wouldn't it be better to use num_online_nodes? each node may get a bigger
> hash bucket which means less collision no?
Ideally at this point you should have online_nodes == possible_nodes.
Due to hotplug you could have more possible than online nodes. However
in this case you would have more smaller buckets which are used even if
the node is offline. Assuming the hash function is perfect, you should
utilize just the same amount of buckets.
Sebastian