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 14F40C2D0F0 for ; Wed, 1 Apr 2020 16:36:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C10A1206F8 for ; Wed, 1 Apr 2020 16:36:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585758974; bh=kwfdmyOyKsHxsGInYzGNknrEDmNZxretW2FYu9TVLxo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=t2Qb2PORJSx7fggM5u2IDYVE4Gtf155G/bc+jPBnfXUL5e805IscMeU91V84j1Fvd 4rWnsrRMofk9iyXYrNdts9GHLbZbho4En5AGKC199ZVONU43Q7APanIWChAk/puVYm JFKNFOUwn8rGzj4ku0IvLiSn2xU9Jv4bZnHrR5fk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388821AbgDAQgL (ORCPT ); Wed, 1 Apr 2020 12:36:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:34934 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388803AbgDAQgF (ORCPT ); Wed, 1 Apr 2020 12:36:05 -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 CFD57206F8; Wed, 1 Apr 2020 16:36:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585758965; bh=kwfdmyOyKsHxsGInYzGNknrEDmNZxretW2FYu9TVLxo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qfj8G/RJuTfTJMltI1ZzmxO746xBQ6OgLSEqBfOk6AahcTl2NfqDUupfmEg0xeHoE uXeFyj9yrB82wXbyibRV8ThFtHF9qw4C45C0tA17mrpMNoa3PBnz/07lOEQ7mjFKzq QJ8an1dCTQOccgyWllLj+G2yUCQ9CVQmUjEQz2TU= 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.9 032/102] futex: Unbreak futex hashing Date: Wed, 1 Apr 2020 18:17:35 +0200 Message-Id: <20200401161539.048152724@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200401161530.451355388@linuxfoundation.org> References: <20200401161530.451355388@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 @@ -390,9 +390,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)]; }