lkml.org 
[lkml]   [2016]   [May]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [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)
{
\
 
 \ /
  Last update: 2016-05-30 18:01    [W:1.918 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site