Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp763530ybz; Fri, 24 Apr 2020 08:54:10 -0700 (PDT) X-Google-Smtp-Source: APiQypLphIl8ujG4KiR3mfyXFnxQEjI7KMMr3VFnAjWvca1z7x9Hgtzyul3eG2PObK7FkgqtcI88 X-Received: by 2002:a17:906:49c7:: with SMTP id w7mr7881497ejv.29.1587743650255; Fri, 24 Apr 2020 08:54:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587743650; cv=none; d=google.com; s=arc-20160816; b=grYg+VYk4hnSdqUj0A016VzEyWh61aIx6eE8Tvi00wScthkREHllHNdJW9heyJiNFj 3OUYWjB2VIckb1/Ux6gGP+t8mHBklx4usUprmkBjuTOfclsHpWOemehwTxn4sinRMD2K abm5yY9I3NgzbqdRAyWzfdLvkMzepPu2tb2yBq8aM2rqyVPPPLWGhayLbE7lCdYU+ff5 6L3G9NfJ0LDkTUIkRK7c1ZIUYWFWO5Lz/6ePgY8lNky5OkcOhbTNoWUo/f0cAyZzWqu8 9wINzo5nzLI4D5q4tfqjrjYK0OtBROib7qFrZFsjIzxeUnixIf7Cp9FhHCLIqe+snrJn Ti+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=t6oHHj1R0Upn7vhp0/rGBsoEdbcnrc0Dz7MCSV60CTs=; b=CltHvWU/vmlku0mDbRehtuiEr9S6XWHI3XQQxxmJU0ZQoWr0vqysqi1BbzziXcHVnf j2Z7ZJFk5vnTB3ypxLt4Co0NGPutqHR4dYagphjwdee1x3N+BKZuoP0qqXZ3Bt40d7j5 1xXVq7OXnCjKBSsnW65Y0QELKtfWqL48AG0RErTj6XP0RRUXD05pra7cp0SM2D7M/cyU b5GzYJfR9oFvOUKwVGasf9VKofMd4mZWHcGIsX73K0ZaIz4T0mfpNW3oQf1nTtQ+CgRA DRxw7YtxOyWdkvPbjXpDSrsyV5Eq9xlQSwklbMO3JfIp2NMcdpB3tCSzDNlMlrDUiX5h 62NA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c11si3423792ejs.396.2020.04.24.08.53.46; Fri, 24 Apr 2020 08:54:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728541AbgDXPtm (ORCPT + 99 others); Fri, 24 Apr 2020 11:49:42 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:56256 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728110AbgDXPtj (ORCPT ); Fri, 24 Apr 2020 11:49:39 -0400 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1jS0a8-0001hQ-NZ; Fri, 24 Apr 2020 16:49:36 +0100 Received: from ben by deadeye with local (Exim 4.93) (envelope-from ) id 1jS0a8-00FNGT-3o; Fri, 24 Apr 2020 16:49:36 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Thomas Gleixner" , "Rong Chen" , "Jann Horn" Date: Fri, 24 Apr 2020 16:51:32 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 247/247] futex: Unbreak futex hashing In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.83-rc2 review patch. If anyone has any objections, please let me know. ------------------ 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: Ben Hutchings Cc: Jann Horn --- kernel/futex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/kernel/futex.c +++ b/kernel/futex.c @@ -309,9 +309,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)]; }