Skip to content

Commit dfaaf3f

Browse files
Peter Zijlstraingomolnar
authored andcommitted
locking/lockdep: Use __jhash_mix() for iterate_chain_key()
Use __jhash_mix() to mix the class_idx into the class_key. This function provides better mixing than the previously used, home grown mix function. Leave hashing to the professionals :-) Suggested-by: George Spelvin <linux@sciencehorizons.net> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent ed8ebd1 commit dfaaf3f

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

‎kernel/locking/lockdep.c‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include <linux/gfp.h>
4747
#include <linux/kmemcheck.h>
4848
#include <linux/random.h>
49+
#include <linux/jhash.h>
4950

5051
#include <asm/sections.h>
5152

@@ -309,10 +310,14 @@ static struct hlist_head chainhash_table[CHAINHASH_SIZE];
309310
* It's a 64-bit hash, because it's important for the keys to be
310311
* unique.
311312
*/
312-
#define iterate_chain_key(key1, key2) \
313-
(((key1) << MAX_LOCKDEP_KEYS_BITS) ^ \
314-
((key1) >> (64-MAX_LOCKDEP_KEYS_BITS)) ^ \
315-
(key2))
313+
static inline u64 iterate_chain_key(u64 key, u32 idx)
314+
{
315+
u32 k0 = key, k1 = key >> 32;
316+
317+
__jhash_mix(idx, k0, k1); /* Macro that modifies arguments! */
318+
319+
return k0 | (u64)k1 << 32;
320+
}
316321

317322
void lockdep_off(void)
318323
{

0 commit comments

Comments
 (0)