public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch 0/4] lockstat updates
@ 2007-06-12 12:13 Peter Zijlstra
  2007-06-12 12:13 ` [patch 1/4] lockdep: variuos fixes Peter Zijlstra
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Peter Zijlstra @ 2007-06-12 12:13 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel
  Cc: Bill Huey, Jason Baron, Steven Rostedt, Christoph Hellwig,
	Peter Zijlstra

Biggest among these updates is the posibility to measure lock bouncing.

-- 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [patch 1/4] lockdep: variuos fixes
  2007-06-12 12:13 [patch 0/4] lockstat updates Peter Zijlstra
@ 2007-06-12 12:13 ` Peter Zijlstra
  2007-06-12 13:47   ` debian developer
  2007-06-12 12:13 ` [patch 2/4] lockdep: fixup sk_callback_lock annotation Peter Zijlstra
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Peter Zijlstra @ 2007-06-12 12:13 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel
  Cc: Bill Huey, Jason Baron, Steven Rostedt, Christoph Hellwig,
	Peter Zijlstra, Ingo Molnar

[-- Attachment #1: lockdep_fixups.patch --]
[-- Type: text/plain, Size: 4323 bytes --]

 - update the copyright notices
 - use the default hash function
 - fix a thinko in a BUILD_BUG_ON
 - add a WARN_ON to spot inconsitent naming
 - fix a termination issue in /proc/lock_stat

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Ingo Molnar <mingo@elte.hu>
---
 include/linux/lockdep.h |    3 ++-
 kernel/lockdep.c        |   20 +++++++++++---------
 kernel/lockdep_proc.c   |    6 +++++-
 3 files changed, 18 insertions(+), 11 deletions(-)

Index: linux-2.6/kernel/lockdep.c
===================================================================
--- linux-2.6.orig/kernel/lockdep.c
+++ linux-2.6/kernel/lockdep.c
@@ -5,7 +5,8 @@
  *
  * Started by Ingo Molnar:
  *
- *  Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
+ *  Copyright (C) 2006,2007 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
+ *  Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com>
  *
  * this code maps all the lock dependencies as they occur in a live kernel
  * and will warn about the following classes of locking bugs:
@@ -37,6 +38,7 @@
 #include <linux/debug_locks.h>
 #include <linux/irqflags.h>
 #include <linux/utsname.h>
+#include <linux/hash.h>
 
 #include <asm/sections.h>
 
@@ -238,8 +240,7 @@ LIST_HEAD(all_lock_classes);
  */
 #define CLASSHASH_BITS		(MAX_LOCKDEP_KEYS_BITS - 1)
 #define CLASSHASH_SIZE		(1UL << CLASSHASH_BITS)
-#define CLASSHASH_MASK		(CLASSHASH_SIZE - 1)
-#define __classhashfn(key)	((((unsigned long)key >> CLASSHASH_BITS) + (unsigned long)key) & CLASSHASH_MASK)
+#define __classhashfn(key)	hash_long((unsigned long)key, CLASSHASH_BITS)
 #define classhashentry(key)	(classhash_table + __classhashfn((key)))
 
 static struct list_head classhash_table[CLASSHASH_SIZE];
@@ -250,9 +251,7 @@ static struct list_head classhash_table[
  */
 #define CHAINHASH_BITS		(MAX_LOCKDEP_CHAINS_BITS-1)
 #define CHAINHASH_SIZE		(1UL << CHAINHASH_BITS)
-#define CHAINHASH_MASK		(CHAINHASH_SIZE - 1)
-#define __chainhashfn(chain) \
-		(((chain >> CHAINHASH_BITS) + chain) & CHAINHASH_MASK)
+#define __chainhashfn(chain)	hash_long(chain, CHAINHASH_BITS)
 #define chainhashentry(chain)	(chainhash_table + __chainhashfn((chain)))
 
 static struct list_head chainhash_table[CHAINHASH_SIZE];
@@ -680,7 +679,7 @@ look_up_lock_class(struct lockdep_map *l
 	 * (or spin_lock_init()) call - which acts as the key. For static
 	 * locks we use the lock object itself as the key.
 	 */
-	BUILD_BUG_ON(sizeof(struct lock_class_key) > sizeof(struct lock_class));
+	BUILD_BUG_ON(sizeof(struct lock_class_key) > sizeof(struct lockdep_map));
 
 	key = lock->key->subkeys + subclass;
 
@@ -690,9 +689,12 @@ look_up_lock_class(struct lockdep_map *l
 	 * We can walk the hash lockfree, because the hash only
 	 * grows, and we are careful when adding entries to the end:
 	 */
-	list_for_each_entry(class, hash_head, hash_entry)
-		if (class->key == key)
+	list_for_each_entry(class, hash_head, hash_entry) {
+		if (class->key == key) {
+			WARN_ON_ONCE(class->name != lock->name);
 			return class;
+		}
+	}
 
 	return NULL;
 }
Index: linux-2.6/include/linux/lockdep.h
===================================================================
--- linux-2.6.orig/include/linux/lockdep.h
+++ linux-2.6/include/linux/lockdep.h
@@ -1,7 +1,8 @@
 /*
  * Runtime locking correctness validator
  *
- *  Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
+ *  Copyright (C) 2006,2007 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
+ *  Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com>
  *
  * see Documentation/lockdep-design.txt for more details.
  */
Index: linux-2.6/kernel/lockdep_proc.c
===================================================================
--- linux-2.6.orig/kernel/lockdep_proc.c
+++ linux-2.6/kernel/lockdep_proc.c
@@ -5,7 +5,8 @@
  *
  * Started by Ingo Molnar:
  *
- *  Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
+ *  Copyright (C) 2006,2007 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
+ *  Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com>
  *
  * Code for /proc/lockdep and /proc/lockdep_stats:
  *
@@ -498,6 +499,9 @@ static void *ls_start(struct seq_file *m
 	if (data->iter == data->stats)
 		seq_header(m);
 
+	if (data->iter == data->iter_end)
+		data->iter = NULL;
+
 	return data->iter;
 }
 

-- 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [patch 2/4] lockdep: fixup sk_callback_lock annotation
  2007-06-12 12:13 [patch 0/4] lockstat updates Peter Zijlstra
  2007-06-12 12:13 ` [patch 1/4] lockdep: variuos fixes Peter Zijlstra
@ 2007-06-12 12:13 ` Peter Zijlstra
  2007-06-12 12:13 ` [patch 3/4] lockstat: measure lock bouncing Peter Zijlstra
  2007-06-12 12:13 ` [patch 4/4] lockstat: better class name representation Peter Zijlstra
  3 siblings, 0 replies; 7+ messages in thread
From: Peter Zijlstra @ 2007-06-12 12:13 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel
  Cc: Bill Huey, Jason Baron, Steven Rostedt, Christoph Hellwig,
	Peter Zijlstra, Ingo Molnar, netdev

[-- Attachment #1: lockdep_fixup_annotate.patch --]
[-- Type: text/plain, Size: 2327 bytes --]

the two init sites resulted in inconsistend names for the lock class.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Ingo Molnar <mingo@elte.hu>
Cc: netdev@vger.kernel.org
---
 net/core/sock.c |   23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

Index: linux-2.6/net/core/sock.c
===================================================================
--- linux-2.6.orig/net/core/sock.c
+++ linux-2.6/net/core/sock.c
@@ -171,6 +171,19 @@ static const char *af_family_slock_key_s
   "slock-AF_TIPC"  , "slock-AF_BLUETOOTH", "slock-AF_IUCV"     ,
   "slock-AF_RXRPC" , "slock-AF_MAX"
 };
+static const char *af_family_clock_key_strings[AF_MAX+1] = {
+  "clock-AF_UNSPEC", "clock-AF_UNIX"     , "clock-AF_INET"     ,
+  "clock-AF_AX25"  , "clock-AF_IPX"      , "clock-AF_APPLETALK",
+  "clock-AF_NETROM", "clock-AF_BRIDGE"   , "clock-AF_ATMPVC"   ,
+  "clock-AF_X25"   , "clock-AF_INET6"    , "clock-AF_ROSE"     ,
+  "clock-AF_DECnet", "clock-AF_NETBEUI"  , "clock-AF_SECURITY" ,
+  "clock-AF_KEY"   , "clock-AF_NETLINK"  , "clock-AF_PACKET"   ,
+  "clock-AF_ASH"   , "clock-AF_ECONET"   , "clock-AF_ATMSVC"   ,
+  "clock-21"       , "clock-AF_SNA"      , "clock-AF_IRDA"     ,
+  "clock-AF_PPPOX" , "clock-AF_WANPIPE"  , "clock-AF_LLC"      ,
+  "clock-27"       , "clock-28"          , "clock-29"          ,
+  "clock-AF_TIPC"  , "clock-AF_BLUETOOTH", "clock-AF_MAX"
+};
 #endif
 
 /*
@@ -941,8 +954,9 @@ struct sock *sk_clone(const struct sock 
 
 		rwlock_init(&newsk->sk_dst_lock);
 		rwlock_init(&newsk->sk_callback_lock);
-		lockdep_set_class(&newsk->sk_callback_lock,
-				   af_callback_keys + newsk->sk_family);
+		lockdep_set_class_and_name(&newsk->sk_callback_lock,
+				af_callback_keys + newsk->sk_family,
+				af_family_clock_key_strings[newsk->sk_family]);
 
 		newsk->sk_dst_cache	= NULL;
 		newsk->sk_wmem_queued	= 0;
@@ -1530,8 +1544,9 @@ void sock_init_data(struct socket *sock,
 
 	rwlock_init(&sk->sk_dst_lock);
 	rwlock_init(&sk->sk_callback_lock);
-	lockdep_set_class(&sk->sk_callback_lock,
-			   af_callback_keys + sk->sk_family);
+	lockdep_set_class_and_name(&sk->sk_callback_lock,
+			af_callback_keys + sk->sk_family,
+			af_family_clock_key_strings[sk->sk_family]);
 
 	sk->sk_state_change	=	sock_def_wakeup;
 	sk->sk_data_ready	=	sock_def_readable;

-- 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [patch 3/4] lockstat: measure lock bouncing
  2007-06-12 12:13 [patch 0/4] lockstat updates Peter Zijlstra
  2007-06-12 12:13 ` [patch 1/4] lockdep: variuos fixes Peter Zijlstra
  2007-06-12 12:13 ` [patch 2/4] lockdep: fixup sk_callback_lock annotation Peter Zijlstra
@ 2007-06-12 12:13 ` Peter Zijlstra
  2007-06-12 12:13 ` [patch 4/4] lockstat: better class name representation Peter Zijlstra
  3 siblings, 0 replies; 7+ messages in thread
From: Peter Zijlstra @ 2007-06-12 12:13 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel
  Cc: Bill Huey, Jason Baron, Steven Rostedt, Christoph Hellwig,
	Peter Zijlstra, Ingo Molnar

[-- Attachment #1: lockstat_bounce.patch --]
[-- Type: text/plain, Size: 6829 bytes --]


    __acquire
        |
       lock _____
        |        \
        |    __contended
        |         |
        |        wait
        | _______/
        |/
        |
   __acquired
        |
   __release
        |
     unlock


We measure acquisition and contention bouncing. 

This is done by recording a cpu stamp in each lock instance.

Contention bouncing requires the cpu stamp to be set on acquisition. Hence we
move __acquired into the generic path. 

__acquired is then used to measure acquisition bouncing by comparing the
current cpu with the old stamp before replacing it.

__contended is used to measure contention bouncing (only useful for preemptable
locks) 

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Ingo Molnar <mingo@elte.hu>
---
 include/linux/lockdep.h |   17 ++++++++++++++++-
 kernel/lockdep.c        |   38 ++++++++++++++++++++++++++------------
 kernel/lockdep_proc.c   |   18 +++++++++++-------
 kernel/mutex.c          |    2 +-
 4 files changed, 54 insertions(+), 21 deletions(-)

Index: linux-2.6/include/linux/lockdep.h
===================================================================
--- linux-2.6.orig/include/linux/lockdep.h
+++ linux-2.6/include/linux/lockdep.h
@@ -130,12 +130,24 @@ struct lock_time {
 	unsigned long			nr;
 };
 
+enum bounce_type {
+	bounce_acquired_write,
+	bounce_acquired_read,
+	bounce_contended_write,
+	bounce_contended_read,
+	nr_bounce_types,
+
+	bounce_acquired = bounce_acquired_write,
+	bounce_contended = bounce_contended_write,
+};
+
 struct lock_class_stats {
 	unsigned long			contention_point[4];
 	struct lock_time		read_waittime;
 	struct lock_time		write_waittime;
 	struct lock_time		read_holdtime;
 	struct lock_time		write_holdtime;
+	unsigned long			bounces[nr_bounce_types];
 };
 
 struct lock_class_stats lock_stats(struct lock_class *class);
@@ -150,6 +162,9 @@ struct lockdep_map {
 	struct lock_class_key		*key;
 	struct lock_class		*class_cache;
 	const char			*name;
+#ifdef CONFIG_LOCK_STAT
+	int				cpu;
+#endif
 };
 
 /*
@@ -321,8 +336,8 @@ do {								\
 	if (!try(_lock)) {					\
 		lock_contended(&(_lock)->dep_map, _RET_IP_);	\
 		lock(_lock);					\
-		lock_acquired(&(_lock)->dep_map);		\
 	}							\
+	lock_acquired(&(_lock)->dep_map);			\
 } while (0)
 
 #else /* CONFIG_LOCK_STAT */
Index: linux-2.6/kernel/lockdep.c
===================================================================
--- linux-2.6.orig/kernel/lockdep.c
+++ linux-2.6/kernel/lockdep.c
@@ -177,6 +177,9 @@ struct lock_class_stats lock_stats(struc
 
 		lock_time_add(&pcs->read_holdtime, &stats.read_holdtime);
 		lock_time_add(&pcs->write_holdtime, &stats.write_holdtime);
+
+		for (i = 0; i < ARRAY_SIZE(stats.bounces); i++)
+			stats.bounces[i] += pcs->bounces[i];
 	}
 
 	return stats;
@@ -2328,6 +2331,9 @@ void lockdep_init_map(struct lockdep_map
 	lock->name = name;
 	lock->key = key;
 	lock->class_cache = NULL;
+#ifdef CONFIG_LOCK_STAT
+	lock->cpu = raw_smp_processor_id();
+#endif
 	if (subclass)
 		register_lock_class(lock, subclass, 1);
 }
@@ -2778,6 +2784,8 @@ found_it:
 	stats = get_lock_stats(hlock->class);
 	if (point < ARRAY_SIZE(stats->contention_point))
 		stats->contention_point[i]++;
+	if (lock->cpu != smp_processor_id())
+		stats->bounces[bounce_contended + !!hlock->read]++;
 	put_lock_stats(stats);
 }
 
@@ -2789,8 +2797,8 @@ __lock_acquired(struct lockdep_map *lock
 	struct lock_class_stats *stats;
 	unsigned int depth;
 	u64 now;
-	s64 waittime;
-	int i;
+	s64 waittime = 0;
+	int i, cpu;
 
 	depth = curr->lockdep_depth;
 	if (DEBUG_LOCKS_WARN_ON(!depth))
@@ -2812,19 +2820,25 @@ __lock_acquired(struct lockdep_map *lock
 	return;
 
 found_it:
-	if (!hlock->waittime_stamp)
-		return;
-
-	now = sched_clock();
-	waittime = now - hlock->waittime_stamp;
-	hlock->holdtime_stamp = now;
+	cpu = smp_processor_id();
+	if (hlock->waittime_stamp) {
+		now = sched_clock();
+		waittime = now - hlock->waittime_stamp;
+		hlock->holdtime_stamp = now;
+	}
 
 	stats = get_lock_stats(hlock->class);
-	if (hlock->read)
-		lock_time_inc(&stats->read_waittime, waittime);
-	else
-		lock_time_inc(&stats->write_waittime, waittime);
+	if (waittime) {
+		if (hlock->read)
+			lock_time_inc(&stats->read_waittime, waittime);
+		else
+			lock_time_inc(&stats->write_waittime, waittime);
+	}
+	if (lock->cpu != cpu)
+		stats->bounces[bounce_acquired + !!hlock->read]++;
 	put_lock_stats(stats);
+
+	lock->cpu = cpu;
 }
 
 void lock_contended(struct lockdep_map *lock, unsigned long ip)
Index: linux-2.6/kernel/lockdep_proc.c
===================================================================
--- linux-2.6.orig/kernel/lockdep_proc.c
+++ linux-2.6/kernel/lockdep_proc.c
@@ -430,16 +430,18 @@ static void seq_stats(struct seq_file *m
 		else
 			seq_printf(m, "%40s:", name);
 
+		seq_printf(m, "%14lu ", stats->bounces[bounce_contended_write]);
 		seq_lock_time(m, &stats->write_waittime);
-		seq_puts(m, " ");
+		seq_printf(m, " %14lu ", stats->bounces[bounce_acquired_write]);
 		seq_lock_time(m, &stats->write_holdtime);
 		seq_puts(m, "\n");
 	}
 
 	if (stats->read_holdtime.nr) {
 		seq_printf(m, "%38s-R:", name);
+		seq_printf(m, "%14lu ", stats->bounces[bounce_contended_read]);
 		seq_lock_time(m, &stats->read_waittime);
-		seq_puts(m, " ");
+		seq_printf(m, " %14lu ", stats->bounces[bounce_acquired_read]);
 		seq_lock_time(m, &stats->read_holdtime);
 		seq_puts(m, "\n");
 	}
@@ -469,26 +471,28 @@ static void seq_stats(struct seq_file *m
 	}
 	if (i) {
 		seq_puts(m, "\n");
-		seq_line(m, '.', 0, 40 + 1 + 8 * (14 + 1));
+		seq_line(m, '.', 0, 40 + 1 + 10 * (14 + 1));
 		seq_puts(m, "\n");
 	}
 }
 
 static void seq_header(struct seq_file *m)
 {
-	seq_printf(m, "lock_stat version 0.1\n");
-	seq_line(m, '-', 0, 40 + 1 + 8 * (14 + 1));
-	seq_printf(m, "%40s %14s %14s %14s %14s %14s %14s %14s %14s\n",
+	seq_printf(m, "lock_stat version 0.2\n");
+	seq_line(m, '-', 0, 40 + 1 + 10 * (14 + 1));
+	seq_printf(m, "%40s %14s %14s %14s %14s %14s %14s %14s %14s %14s %14s\n",
 			"class name",
+			"con-bounces",
 			"contentions",
 			"waittime-min",
 			"waittime-max",
 			"waittime-total",
+			"acq-bounces",
 			"acquisitions",
 			"holdtime-min",
 			"holdtime-max",
 			"holdtime-total");
-	seq_line(m, '-', 0, 40 + 1 + 8 * (14 + 1));
+	seq_line(m, '-', 0, 40 + 1 + 10 * (14 + 1));
 	seq_printf(m, "\n");
 }
 
Index: linux-2.6/kernel/mutex.c
===================================================================
--- linux-2.6.orig/kernel/mutex.c
+++ linux-2.6/kernel/mutex.c
@@ -180,8 +180,8 @@ __mutex_lock_common(struct mutex *lock, 
 		spin_lock_mutex(&lock->wait_lock, flags);
 	}
 
-	lock_acquired(&lock->dep_map);
 done:
+	lock_acquired(&lock->dep_map);
 	/* got the lock - rejoice! */
 	mutex_remove_waiter(lock, &waiter, task_thread_info(task));
 	debug_mutex_set_owner(lock, task_thread_info(task));

-- 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [patch 4/4] lockstat: better class name representation
  2007-06-12 12:13 [patch 0/4] lockstat updates Peter Zijlstra
                   ` (2 preceding siblings ...)
  2007-06-12 12:13 ` [patch 3/4] lockstat: measure lock bouncing Peter Zijlstra
@ 2007-06-12 12:13 ` Peter Zijlstra
  3 siblings, 0 replies; 7+ messages in thread
From: Peter Zijlstra @ 2007-06-12 12:13 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel
  Cc: Bill Huey, Jason Baron, Steven Rostedt, Christoph Hellwig,
	Peter Zijlstra

[-- Attachment #1: lockstat_class_name.patch --]
[-- Type: text/plain, Size: 1255 bytes --]

optionally add class->name_version and class->subclass to the class name

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 kernel/lockdep_proc.c |   24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

Index: linux-2.6/kernel/lockdep_proc.c
===================================================================
--- linux-2.6.orig/kernel/lockdep_proc.c
+++ linux-2.6/kernel/lockdep_proc.c
@@ -421,8 +421,30 @@ static void seq_stats(struct seq_file *m
 	class = data->class;
 	stats = &data->stats;
 
-	snprintf(name, 38, "%s", class->name);
+	namelen = 38;
+	if (class->name_version > 1)
+		namelen -= 2; /* XXX truncates versions > 9 */
+	if (class->subclass)
+		namelen -= 2;
+
+	if (!class->name) {
+		char str[KSYM_NAME_LEN];
+		const char *key_name;
+
+		key_name = __get_key_name(class->key, str);
+		snprintf(name, namelen, "%s", key_name);
+	} else {
+		snprintf(name, namelen, "%s", class->name);
+	}
 	namelen = strlen(name);
+	if (class->name_version > 1) {
+		snprintf(name+namelen, 3, "#%d", class->name_version);
+		namelen += 2;
+	}
+	if (class->subclass) {
+		snprintf(name+namelen, 3, "/%d", class->subclass);
+		namelen += 2;
+	}
 
 	if (stats->write_holdtime.nr) {
 		if (stats->read_holdtime.nr)

-- 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [patch 1/4] lockdep: variuos fixes
  2007-06-12 12:13 ` [patch 1/4] lockdep: variuos fixes Peter Zijlstra
@ 2007-06-12 13:47   ` debian developer
  2007-06-12 14:08     ` Peter Zijlstra
  0 siblings, 1 reply; 7+ messages in thread
From: debian developer @ 2007-06-12 13:47 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: linux-kernel

What exactly is being copyright'ed here?

On 6/12/07, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
>  - update the copyright notices
>  - use the default hash function
>  - fix a thinko in a BUILD_BUG_ON
>  - add a WARN_ON to spot inconsitent naming
>  - fix a termination issue in /proc/lock_stat
>
> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Acked-by: Ingo Molnar <mingo@elte.hu>
> ---
>  include/linux/lockdep.h |    3 ++-
>  kernel/lockdep.c        |   20 +++++++++++---------
>  kernel/lockdep_proc.c   |    6 +++++-
>  3 files changed, 18 insertions(+), 11 deletions(-)
>
> Index: linux-2.6/kernel/lockdep.c
> ===================================================================
> --- linux-2.6.orig/kernel/lockdep.c
> +++ linux-2.6/kernel/lockdep.c
> @@ -5,7 +5,8 @@
>   *
>   * Started by Ingo Molnar:
>   *
> - *  Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
> + *  Copyright (C) 2006,2007 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
> + *  Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com>
>   *
>   * this code maps all the lock dependencies as they occur in a live kernel
>   * and will warn about the following classes of locking bugs:
> @@ -37,6 +38,7 @@
>  #include <linux/debug_locks.h>
>  #include <linux/irqflags.h>
>  #include <linux/utsname.h>
> +#include <linux/hash.h>
>
>  #include <asm/sections.h>
>
> @@ -238,8 +240,7 @@ LIST_HEAD(all_lock_classes);
>   */
>  #define CLASSHASH_BITS         (MAX_LOCKDEP_KEYS_BITS - 1)
>  #define CLASSHASH_SIZE         (1UL << CLASSHASH_BITS)
> -#define CLASSHASH_MASK         (CLASSHASH_SIZE - 1)
> -#define __classhashfn(key)     ((((unsigned long)key >> CLASSHASH_BITS) + (unsigned long)key) & CLASSHASH_MASK)
> +#define __classhashfn(key)     hash_long((unsigned long)key, CLASSHASH_BITS)
>  #define classhashentry(key)    (classhash_table + __classhashfn((key)))
>
>  static struct list_head classhash_table[CLASSHASH_SIZE];
> @@ -250,9 +251,7 @@ static struct list_head classhash_table[
>   */
>  #define CHAINHASH_BITS         (MAX_LOCKDEP_CHAINS_BITS-1)
>  #define CHAINHASH_SIZE         (1UL << CHAINHASH_BITS)
> -#define CHAINHASH_MASK         (CHAINHASH_SIZE - 1)
> -#define __chainhashfn(chain) \
> -               (((chain >> CHAINHASH_BITS) + chain) & CHAINHASH_MASK)
> +#define __chainhashfn(chain)   hash_long(chain, CHAINHASH_BITS)
>  #define chainhashentry(chain)  (chainhash_table + __chainhashfn((chain)))
>
>  static struct list_head chainhash_table[CHAINHASH_SIZE];
> @@ -680,7 +679,7 @@ look_up_lock_class(struct lockdep_map *l
>          * (or spin_lock_init()) call - which acts as the key. For static
>          * locks we use the lock object itself as the key.
>          */
> -       BUILD_BUG_ON(sizeof(struct lock_class_key) > sizeof(struct lock_class));
> +       BUILD_BUG_ON(sizeof(struct lock_class_key) > sizeof(struct lockdep_map));
>
>         key = lock->key->subkeys + subclass;
>
> @@ -690,9 +689,12 @@ look_up_lock_class(struct lockdep_map *l
>          * We can walk the hash lockfree, because the hash only
>          * grows, and we are careful when adding entries to the end:
>          */
> -       list_for_each_entry(class, hash_head, hash_entry)
> -               if (class->key == key)
> +       list_for_each_entry(class, hash_head, hash_entry) {
> +               if (class->key == key) {
> +                       WARN_ON_ONCE(class->name != lock->name);
>                         return class;
> +               }
> +       }
>
>         return NULL;
>  }
> Index: linux-2.6/include/linux/lockdep.h
> ===================================================================
> --- linux-2.6.orig/include/linux/lockdep.h
> +++ linux-2.6/include/linux/lockdep.h
> @@ -1,7 +1,8 @@
>  /*
>   * Runtime locking correctness validator
>   *
> - *  Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
> + *  Copyright (C) 2006,2007 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
> + *  Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com>
>   *
>   * see Documentation/lockdep-design.txt for more details.
>   */
> Index: linux-2.6/kernel/lockdep_proc.c
> ===================================================================
> --- linux-2.6.orig/kernel/lockdep_proc.c
> +++ linux-2.6/kernel/lockdep_proc.c
> @@ -5,7 +5,8 @@
>   *
>   * Started by Ingo Molnar:
>   *
> - *  Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
> + *  Copyright (C) 2006,2007 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
> + *  Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com>
>   *
>   * Code for /proc/lockdep and /proc/lockdep_stats:
>   *
> @@ -498,6 +499,9 @@ static void *ls_start(struct seq_file *m
>         if (data->iter == data->stats)
>                 seq_header(m);
>
> +       if (data->iter == data->iter_end)
> +               data->iter = NULL;
> +
>         return data->iter;
>  }
>
>
> --
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [patch 1/4] lockdep: variuos fixes
  2007-06-12 13:47   ` debian developer
@ 2007-06-12 14:08     ` Peter Zijlstra
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Zijlstra @ 2007-06-12 14:08 UTC (permalink / raw)
  To: debian developer; +Cc: linux-kernel, Ingo Molnar

On Tue, 2007-06-12 at 19:17 +0530, debian developer wrote:

> On 6/12/07, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:

> > Index: linux-2.6/kernel/lockdep.c
> > ===================================================================
> > --- linux-2.6.orig/kernel/lockdep.c
> > +++ linux-2.6/kernel/lockdep.c
> > @@ -5,7 +5,8 @@
> >   *
> >   * Started by Ingo Molnar:
> >   *
> > - *  Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
> > + *  Copyright (C) 2006,2007 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
> > + *  Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com>
> >   *
> >   * this code maps all the lock dependencies as they occur in a live kernel
> >   * and will warn about the following classes of locking bugs:

> What exactly is being copyright'ed here?

Thanks for being triply impolite! You score: anonymous, top-posting and
dropping CC-lists.

The code in these files, as in most other files in the Linux kernel, is
copyrighted. The code is Licensed under GPLv2, but copyright belongs to
Red Hat and it's authors are Ingo and myself.

That is, say you want to use this code in a non GPLv2 project (say this
GPLv3 thing) then you would need to contact the copyright owner of this
code.




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-06-12 14:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-12 12:13 [patch 0/4] lockstat updates Peter Zijlstra
2007-06-12 12:13 ` [patch 1/4] lockdep: variuos fixes Peter Zijlstra
2007-06-12 13:47   ` debian developer
2007-06-12 14:08     ` Peter Zijlstra
2007-06-12 12:13 ` [patch 2/4] lockdep: fixup sk_callback_lock annotation Peter Zijlstra
2007-06-12 12:13 ` [patch 3/4] lockstat: measure lock bouncing Peter Zijlstra
2007-06-12 12:13 ` [patch 4/4] lockstat: better class name representation Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox