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