Re: [PATCH v2] futex: Use a keyed hash for global futex buckets

From: Thomas Gleixner

Date: Sat Dec 05 2026 - 15:35:33 EST


On Fri, Nov 06 2026 at 10:19, Kyle Zeng wrote:
> On Thu, Nov 05, 2026 at 09:04:47AM +0800, kernel test robot wrote:
>> 0fcb05b723 ("Merge tag 'libcrypto-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux")
>> c44a057178 ("[PATCH v2] futex: Use a keyed hash for global futex buckets")
>>
>> 0fcb05b72344f408 c44a057178cbedbc04c63404258
>> ---------------- ---------------------------
>> %stddev %change %stddev
>> \ | \
>> 7.026e+08 -6.0% 6.607e+08 will-it-scale.224.threads
>> 3136755 -6.0% 2949754 will-it-scale.per_thread_ops
>> 7.026e+08 -6.0% 6.607e+08 will-it-scale.workload
>
> I wonder what is the best way to run this above regression test and what

The answer is in the quoted text to which you replied to:

>> The kernel config and materials to reproduce are available at:
>> https://download.01.org/0day-ci/archive/20261105/202611050816.9e42490c-lkp@xxxxxxxxx

No?

> will be an acceptable threshold for the patch to be merged.
> I'd like to iterate on the patch, fixing the issue while avoiding the
> the performance regression.

You might try the following:

futex_init()
{
...
get_random_bytes(&futex_hash_key, sizeof(futex_hash_key));
...
}

struct futex_hash_bucket **futex_queues(void)
{
...
u32 hash_key = (*(u32 *)key) ^ futex_hash_key);

hash = jhash2(&hask_key, offsetof(typeof(*key), both.offset) / sizeof(u32),
key->both.offset);
...
)

or something like that, which would remove the compile time constant
from the hash function while at the same time preserving the
performance.

I know that's not the same in a cryptographic sense, but it might be
sufficient to remove the initial threat you are looking at.

Because your proposed solution is also prone to the collision checking
approach because it's just a matter of effort to decode the extra
inconveniance of the boot time established siphash seed value, no?

Thanks,

tglx