lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 30 May 2016 17:11:29 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	George Spelvin <linux@...encehorizons.net>
Cc:	Linus Torvalds <torvalds@...ux-foundation.org>,
	lkml <linux-kernel@...r.kernel.org>,
	"J . Bruce Fields" <bfields@...hat.com>
Subject: Re: [PATCH v3 06/10] fs/namei.c: Improve dcache hash function

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)
 {

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ