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,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 C26B5C43331 for ; Tue, 24 Mar 2020 13:31:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8D05B20753 for ; Tue, 24 Mar 2020 13:31:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585056685; bh=IGSlqq6hTkxv2h9XpSBomhmjn8iXo6CQHK+pMRjfako=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=XCa4mWRtrPywU4VLyz7pr3a/zkD6jiU7aGpONftiyGA8fMzVXUuwSY7CpRCeAFwnP 2uVgPXvBg0RxWCJAVKXt7cWVr2y3y3t3UOTHT1S+2g5mOorfiGZ78Ih5x1avYBXm5y V70FaRe71ICTlDVWpQuhifpgSjEmEAxYUU5Im1dQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727875AbgCXNbY (ORCPT ); Tue, 24 Mar 2020 09:31:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:41078 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728087AbgCXNUB (ORCPT ); Tue, 24 Mar 2020 09:20:01 -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 2A305208CA; Tue, 24 Mar 2020 13:20:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585056000; bh=IGSlqq6hTkxv2h9XpSBomhmjn8iXo6CQHK+pMRjfako=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GcjFVPA9+mrWty5aPhx39MKm4AXZFxG7uukC4IR6xrBB1qAZWSh8NloyEs+sKfUC6 GRpDTCs8qVoS5k53mrZ/EkCY7ebg1bOXxl+kQb+PCID9CHHoEykkPaIFwe0b2Joka8 BKWE6FFBp+HSd8kvu72oH+u0ulnK1s6onj6OOMHA= 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 5.4 095/102] futex: Unbreak futex hashing Date: Tue, 24 Mar 2020 14:11:27 +0100 Message-Id: <20200324130816.418081988@linuxfoundation.org> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200324130806.544601211@linuxfoundation.org> References: <20200324130806.544601211@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 @@ -385,9 +385,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)]; }