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=unavailable 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 5BAA0C2D0F3 for ; Wed, 1 Apr 2020 16:30:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EAC4C21655 for ; Wed, 1 Apr 2020 16:30:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585758640; bh=kkiZxSWSvTmep1CrIhlSNygi64GZbcmWRh4jqTD3b3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=vKgMbYWbjArfnhA+U3zP15ec5SB4nDY2dEnqqyMVENivX6115MMrAHGIywJ+hm7QA /p/CuXJaiUCcw2tdy4mjbeRDUhQHIq4wkJU+gaawNvJRfE9DKd7XJ2BdSwDM3LdJ7n WXIeylHbgQ6pdcGe7geVgpSUJ7TLKjw47sBFQggY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387566AbgDAQai (ORCPT ); Wed, 1 Apr 2020 12:30:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:56580 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387517AbgDAQag (ORCPT ); Wed, 1 Apr 2020 12:30:36 -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 51DDB21D79; Wed, 1 Apr 2020 16:30:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585758634; bh=kkiZxSWSvTmep1CrIhlSNygi64GZbcmWRh4jqTD3b3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ecvlQEl3nJvuKJ6CNJyizKmRyWSl5uuePBHjBMG29iSvvO4taIrDh0nb5wqNpOnhH c9z0cNlOihTSFSUZvpM4fvMtZvuG7Y6fqRzVApMS42dhbRSZvx9UwABdx9IAX1tK31 AUsNbc1DlTN2c9vBT0zYvGqWVoPTHls9cyzUQS2U= 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.4 30/91] futex: Unbreak futex hashing Date: Wed, 1 Apr 2020 18:17:26 +0200 Message-Id: <20200401161523.559502813@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200401161512.917494101@linuxfoundation.org> References: <20200401161512.917494101@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 @@ -378,9 +378,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)]; }