chain_key collision check triggers
Subsystems (2)
Peter Zijlstra
maintainerQuoted 5 lines · Heiko Carstens
Hi all,
the new lockdep
chain_keycollision detection code triggers quite reliably on s390, so it looks like we need a differentiterate_chain_key()implementation?
That too, I have one queued up; but if you can realiably trigger this that's 'good' news. Most reports so far have been one offs that people could not reproduce.
Let me wake up a bit more, but in the meantime, the below is what I had queued.
---
Subject: locking,lockdep: Use __jhash_mix for iterate_chain_key
From: Peter Zijlstra <[email protected]>
Date: Mon May 30 18:31:33 CEST 2016
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 :-)
--- kernel/locking/lockdep.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
kernel/locking/lockdep.c +9 -4
@@ -46,6 +46,7 @@#include <linux/gfp.h> #include <linux/kmemcheck.h> #include <linux/random.h> +#include <linux/jhash.h> #include <asm/sections.h>
@@ -309,10 +310,14 @@ static struct hlist_head chainhash_table* 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 key,u32 idx) +{ +u32 k0 = key, k1 = key >>32 ; + +__jhash_mix (idx, k0, k1);/* Macro that modifies arguments! */ + +return k0 | (u64 )k1 <<32 ; +}void lockdep_off (void ) {
Quoted 14 lines · Peter Zijlstra
Quoted 5 lines · Heiko Carstens
Hi all,
the new lockdep
chain_keycollision detection code triggers quite reliably on s390, so it looks like we need a differentiterate_chain_key()implementation?That too, I have one queued up; but if you can realiably trigger this that's 'good' news. Most reports so far have been one offs that people could not reproduce.
Let me wake up a bit more, but in the meantime, the below is what I had queued.
Quoted 8 lines
---
Subject: locking,lockdep: Use__jhash_mixforiterate_chain_key
From: Peter Zijlstra <[email protected]>
Date: Mon May 30 18:31:33 CEST 2016Use
__jhash_mix()to mix theclass_idxinto theclass_key. This function provides better mixing than the previously used, home grown mix function.
Ok, thanks! I'll use that then. Unfortunately the new hash function generates 28 instead of 2 instructions on s390.
Peter Zijlstra
maintainerQuoted 20 lines · Heiko Carstens
Quoted 19 lines · Peter Zijlstra
Quoted 5 lines · Heiko Carstens
Hi all,
the new lockdep
chain_keycollision detection code triggers quite reliably on s390, so it looks like we need a differentiterate_chain_key()implementation?That too, I have one queued up; but if you can realiably trigger this that's 'good' news. Most reports so far have been one offs that people could not reproduce.
Let me wake up a bit more, but in the meantime, the below is what I had queued.
---
Subject: locking,lockdep: Use__jhash_mixforiterate_chain_key
From: Peter Zijlstra <[email protected]>
Date: Mon May 30 18:31:33 CEST 2016
Quoted 6 lines
Quoted 3 lines
Use
__jhash_mix()to mix theclass_idxinto theclass_key. This function provides better mixing than the previously used, home grown mix function.Ok, thanks! I'll use that then. Unfortunately the new hash function generates 28 instead of 2 instructions on s390.
Yeah, but I doubt you can actually measure the performance difference, lockdep is a pig anyway.