Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1412933 > unrolled thread

Re: [lockdep] chain_key collision check triggers

Started byPeter Zijlstra <peterz@infradead.org>
First post2016-06-03 10:50 +0200
Last post2016-06-03 13:40 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [lockdep] chain_key collision check triggers Peter Zijlstra <peterz@infradead.org> - 2016-06-03 10:50 +0200
    Re: [lockdep] chain_key collision check triggers Heiko Carstens <heiko.carstens@de.ibm.com> - 2016-06-03 13:20 +0200
      Re: [lockdep] chain_key collision check triggers Peter Zijlstra <peterz@infradead.org> - 2016-06-03 13:40 +0200

#1412933 — Re: [lockdep] chain_key collision check triggers

FromPeter Zijlstra <peterz@infradead.org>
Date2016-06-03 10:50 +0200
SubjectRe: [lockdep] chain_key collision check triggers
Message-ID<rFSXL-T2-11@gated-at.bofh.it>
On Fri, Jun 03, 2016 at 09:15:44AM +0200, Heiko Carstens wrote:
> Hi all,
> 
> the new lockdep chain_key collision detection code triggers quite reliably
> on s390, so it looks like we need a different iterate_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 <peterz@infradead.org>
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 :-)

Cc: torvalds@linux-foundation.org
Suggested-by: George Spelvin <linux@sciencehorizons.net>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 kernel/locking/lockdep.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -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)
 {

[toc] | [next] | [standalone]


#1413129

FromHeiko Carstens <heiko.carstens@de.ibm.com>
Date2016-06-03 13:20 +0200
Message-ID<rFViW-2rq-21@gated-at.bofh.it>
In reply to#1412933
On Fri, Jun 03, 2016 at 10:48:01AM +0200, Peter Zijlstra wrote:
> On Fri, Jun 03, 2016 at 09:15:44AM +0200, Heiko Carstens wrote:
> > Hi all,
> > 
> > the new lockdep chain_key collision detection code triggers quite reliably
> > on s390, so it looks like we need a different iterate_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 <peterz@infradead.org>
> 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.

Ok, thanks! I'll use that then. Unfortunately the new hash function
generates 28 instead of 2 instructions on s390.

[toc] | [prev] | [next] | [standalone]


#1413143

FromPeter Zijlstra <peterz@infradead.org>
Date2016-06-03 13:40 +0200
Message-ID<rFVCh-2xA-3@gated-at.bofh.it>
In reply to#1413129
On Fri, Jun 03, 2016 at 01:12:50PM +0200, Heiko Carstens wrote:
> On Fri, Jun 03, 2016 at 10:48:01AM +0200, Peter Zijlstra wrote:
> > On Fri, Jun 03, 2016 at 09:15:44AM +0200, Heiko Carstens wrote:
> > > Hi all,
> > > 
> > > the new lockdep chain_key collision detection code triggers quite reliably
> > > on s390, so it looks like we need a different iterate_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 <peterz@infradead.org>
> > 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.
> 
> 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.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web