From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BB2FC2BA12 for ; Wed, 1 Apr 2020 16:42:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1D8E72063A for ; Wed, 1 Apr 2020 16:42:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585759327; bh=NGlbUHeGAsmj8DvLjo4wsyyd7AsWiHPZuZbnLUQ9UIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=B+aoMg67dm2Hgi4xWboOHa3A2RWUkyTrkoEt6awfVpPsQb+GeP2ckHkVl8Ctz4qCm UksX9A7L/Ke4Pi3074Rwiv3wL56gJBOepsDxfBn0wvObVgbAL6nUas+LihFTGfiP6f AcvUYaMrsnp3HC+KjVvZKSej/xK3BqyBLPSTzdno= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389179AbgDAQmG (ORCPT ); Wed, 1 Apr 2020 12:42:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:42602 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389486AbgDAQmD (ORCPT ); Wed, 1 Apr 2020 12:42:03 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BC20820857; Wed, 1 Apr 2020 16:42:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585759323; bh=NGlbUHeGAsmj8DvLjo4wsyyd7AsWiHPZuZbnLUQ9UIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hPHEMwmN/By4t6PVFu3Ua/aRYUyGZWclR9b36IitoKdfnYXT0LwyQ88zkM3uEOw+W nTFMrnj1hXdpB/o1NsBbVJlmY9lWU/AzxgNV0s9wlnXg77iD9rj+BJVqNV/MyQZyGn sxzpfCXlH6nAezLVOe/28umZIGVTn/nYjLXEfjnw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rong Chen , Thomas Gleixner , Linus Torvalds Subject: [PATCH 4.14 046/148] futex: Unbreak futex hashing Date: Wed, 1 Apr 2020 18:17:18 +0200 Message-Id: <20200401161557.348239612@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200401161552.245876366@linuxfoundation.org> References: <20200401161552.245876366@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Thomas Gleixner commit 8d67743653dce5a0e7aa500fcccb237cde7ad88e upstream. 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: 8019ad13ef7f ("futex: Fix inode life-time issue") Reported-by: Rong Chen Decoded-by: Linus Torvalds Signed-off-by: Thomas Gleixner Tested-by: Rong Chen Link: https://lkml.kernel.org/r/87h7yy90ve.fsf@nanos.tec.linutronix.de Signed-off-by: Greg Kroah-Hartman --- kernel/futex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/kernel/futex.c +++ b/kernel/futex.c @@ -401,9 +401,9 @@ static inline int hb_waiters_pending(str */ static struct futex_hash_bucket *hash_futex(union futex_key *key) { - u32 hash = jhash2((u32*)&key->both.word, - (sizeof(key->both.word)+sizeof(key->both.ptr))/4, + u32 hash = jhash2((u32 *)key, offsetof(typeof(*key), both.offset) / 4, key->both.offset); + return &futex_queues[hash & (futex_hashsize - 1)]; }