Re: [PATCH RFC] futex: avoid false sharing between hb->chain and the bucket lock
From: Thomas Gleixner
Date: Tue Jun 09 2026 - 16:32:47 EST
On Tue, Jun 09 2026 at 22:25, Peter Zijlstra wrote:
> On Tue, Jun 09, 2026 at 10:16:31PM +0200, Thomas Gleixner wrote:
>> @@ -301,13 +304,12 @@ struct futex_private_hash *futex_private
>>
>> struct futex_hash_bucket *futex_hash(union futex_key *key)
>> {
>> - struct futex_private_hash *fph;
>> + struct futex_private_hash *fph = NULL;
>> struct futex_hash_bucket *hb;
>>
>> again:
>> scoped_guard(rcu) {
>> - hb = __futex_hash(key, NULL);
>> - fph = hb->priv;
>> + hb = __futex_hash(key, &fph);
>>
>> if (!fph || futex_private_hash_get(fph))
>> return hb;
>
> Also, same bug I had in my first patch, you need to re-set fph to NULL
> on the goto again :-)
Figured that out by now :)