Skip to content

Commit 8d67743

Browse files
committed
futex: Unbreak futex hashing
The recent futex inode life time fix changed the ordering of the futex key union struct members, but forgot to adjust the hash function accordingly, As a result the hashing omits the leading 64bit and even hashes beyond the futex key causing a bad hash distribution which led to a ~100% performance regression. Hand in the futex key pointer instead of a random struct member and make the size calculation based of the struct offset. Fixes: 8019ad1 ("futex: Fix inode life-time issue") Reported-by: Rong Chen <rong.a.chen@intel.com> Decoded-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Rong Chen <rong.a.chen@intel.com> Link: https://lkml.kernel.org/r/87h7yy90ve.fsf@nanos.tec.linutronix.de
1 parent 8019ad1 commit 8d67743

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

kernel/futex.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,9 @@ static inline int hb_waiters_pending(struct futex_hash_bucket *hb)
385385
*/
386386
static struct futex_hash_bucket *hash_futex(union futex_key *key)
387387
{
388-
u32 hash = jhash2((u32*)&key->both.word,
389-
(sizeof(key->both.word)+sizeof(key->both.ptr))/4,
388+
u32 hash = jhash2((u32 *)key, offsetof(typeof(*key), both.offset) / 4,
390389
key->both.offset);
390+
391391
return &futex_queues[hash & (futex_hashsize - 1)];
392392
}
393393

0 commit comments

Comments
 (0)