From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755158AbcE3PLg (ORCPT ); Mon, 30 May 2016 11:11:36 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:49059 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753551AbcE3PLe (ORCPT ); Mon, 30 May 2016 11:11:34 -0400 Date: Mon, 30 May 2016 17:11:29 +0200 From: Peter Zijlstra To: George Spelvin Cc: Linus Torvalds , lkml , "J . Bruce Fields" Subject: Re: [PATCH v3 06/10] fs/namei.c: Improve dcache hash function Message-ID: <20160530151129.GO3206@twins.programming.kicks-ass.net> References: <1464465443-25305-1-git-send-email-linux@sciencehorizons.net> <1464465443-25305-7-git-send-email-linux@sciencehorizons.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1464465443-25305-7-git-send-email-linux@sciencehorizons.net> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 28, 2016 at 03:57:19PM -0400, George Spelvin wrote: > +static inline unsigned int fold_hash(unsigned long x, unsigned long y) > { > + y ^= x * GOLDEN_RATIO_64; > + y *= GOLDEN_RATIO_64; > + return y >> 32; > } So does it make sense to use that pattern here too? This code doesn't much care about performance, but wants a decent hash from the stack of class keys. --- kernel/locking/lockdep.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 81f1a7107c0e..c8498efcd5d9 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -309,10 +309,12 @@ static struct hlist_head chainhash_table[CHAINHASH_SIZE]; * It's a 64-bit hash, because it's important for the keys to be * unique. */ -#define iterate_chain_key(key1, key2) \ - (((key1) << MAX_LOCKDEP_KEYS_BITS) ^ \ - ((key1) >> (64-MAX_LOCKDEP_KEYS_BITS)) ^ \ - (key2)) +static inline u64 iterate_chain_key(u64 x, u64 y) +{ + y ^= x * GOLDEN_RATIO_64; + y *= GOLDEN_RATIO_64; + return y; +} void lockdep_off(void) {