Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3642528imm; Mon, 18 Jun 2018 01:24:39 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLwz6fCrt4F8/J+jP0fUkAaOdc9yeH8lnt92scC0SEfXvL1a41Nk7PXM3EcnKSIqoUAp5CO X-Received: by 2002:a65:4c4d:: with SMTP id l13-v6mr10394977pgr.211.1529310279535; Mon, 18 Jun 2018 01:24:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529310279; cv=none; d=google.com; s=arc-20160816; b=rwKq9PUGrh6r5OyXK3fJUiM4FI9Xvml38W4ZVO+uaFw+oLymWuF0WVWxGsJ749BP7M mPiT0FXSDkV+1ROXgaopk2/w2+A/BxdaB3xCj2DeyPPYsOtHTOziFDbGH/uoXa8VcJxk nPAbi67G7dejdDsjCJGjoeYZirsXxIGCmuVq5fagDt+ZEKSCorU3qlFzGKMuUOMNpw0e +8lmb4TPNtcp+cUcqL5QG9FDO/YkMFyAymxDR+TSkyoGXWWiCJHXoiOVt+xqUS9wPF41 ozA7zMoy4HEolcj+yjsePdTGz1rdJtHV5zZXfn1CFPUVxoXIEaOnYMSTKxKr1phDsV+a EbKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=kZcvzZLgaxlvp+1ue2iOBuDrSc2xQ2BNZkj10lOAm60=; b=VDJ9TpIPAJBR1L2reGOooB23klJA+SCaS+DRjTqswEKXxMlakyqoLKwOWZtdLViwHw /JsOKfI0MpdPl+mwB3aAhnY3hwUe78HeGp4vcKlPcerx044A6jJ5Ip5tqgdyiTRoZ4s8 HdEAvXhWFrKibASFiIYP2F+/eNqaQkg25AUlwHb6fGGbHERNqftt55I4QPwKCG6QLgHF N9bF91NQJo/CaUe1QY9HIW5MCMhgosexiN94o0Yhem1cC1wiwr1P9pyfiDzADlDtYH9j nZ5y0nny1nEb5xrtMbGWbSfWi3qAciKO7RjCr7739878i2G2bmKpQF3w3wahMSQNhQCN Czow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v22-v6si13941491ply.328.2018.06.18.01.24.26; Mon, 18 Jun 2018 01:24:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965759AbeFRIXP (ORCPT + 99 others); Mon, 18 Jun 2018 04:23:15 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55742 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965687AbeFRIXN (ORCPT ); Mon, 18 Jun 2018 04:23:13 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A9691BAD; Mon, 18 Jun 2018 08:23:12 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Amir Goldstein , Linus Torvalds , Sasha Levin Subject: [PATCH 4.16 137/279] : fix end_name_hash() for 64bit long Date: Mon, 18 Jun 2018 10:12:02 +0200 Message-Id: <20180618080614.500944826@linuxfoundation.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618080608.851973560@linuxfoundation.org> References: <20180618080608.851973560@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Amir Goldstein [ Upstream commit 19b9ad67310ed2f685062a00aec602bec33835f0 ] The comment claims that this helper will try not to loose bits, but for 64bit long it looses the high bits before hashing 64bit long into 32bit int. Use the helper hash_long() to do the right thing for 64bit long. For 32bit long, there is no change. All the callers of end_name_hash() either assign the result to qstr->hash, which is u32 or return the result as an int value (e.g. full_name_hash()). Change the helper return type to int to conform to its users. [ It took me a while to apply this, because my initial reaction to it was - incorrectly - that it could make for slower code. After having looked more at it, I take back all my complaints about the patch, Amir was right and I was mis-reading things or just being stupid. I also don't worry too much about the possible performance impact of this on 64-bit, since most architectures that actually care about performance end up not using this very much (the dcache code is the most performance-critical, but the word-at-a-time case uses its own hashing anyway). So this ends up being mostly used for filesystems that do their own degraded hashing (usually because they want a case-insensitive comparison function). A _tiny_ worry remains, in that not everybody uses DCACHE_WORD_ACCESS, and then this potentially makes things more expensive on 64-bit architectures with slow or lacking multipliers even for the normal case. That said, realistically the only such architecture I can think of is PA-RISC. Nobody really cares about performance on that, it's more of a "look ma, I've got warts^W an odd machine" platform. So the patch is fine, and all my initial worries were just misplaced from not looking at this properly. - Linus ] Signed-off-by: Amir Goldstein Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- include/linux/stringhash.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/include/linux/stringhash.h +++ b/include/linux/stringhash.h @@ -50,9 +50,9 @@ partial_name_hash(unsigned long c, unsig * losing bits). This also has the property (wanted by the dcache) * that the msbits make a good hash table index. */ -static inline unsigned long end_name_hash(unsigned long hash) +static inline unsigned int end_name_hash(unsigned long hash) { - return __hash_32((unsigned int)hash); + return hash_long(hash, 32); } /*