Skip to content

Commit 4b32d0a

Browse files
Peter ZijlstraLinus Torvalds
authored andcommitted
lockdep: various fixes
- 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 [akpm@linux-foundation.org: cleanups] Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Acked-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 4fe8774 commit 4b32d0a

3 files changed

Lines changed: 19 additions & 11 deletions

File tree

‎include/linux/lockdep.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/*
22
* Runtime locking correctness validator
33
*
4-
* Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
4+
* Copyright (C) 2006,2007 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
5+
* Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com>
56
*
67
* see Documentation/lockdep-design.txt for more details.
78
*/

‎kernel/lockdep.c‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
*
66
* Started by Ingo Molnar:
77
*
8-
* Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
8+
* Copyright (C) 2006,2007 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
9+
* Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com>
910
*
1011
* this code maps all the lock dependencies as they occur in a live kernel
1112
* and will warn about the following classes of locking bugs:
@@ -37,6 +38,7 @@
3738
#include <linux/debug_locks.h>
3839
#include <linux/irqflags.h>
3940
#include <linux/utsname.h>
41+
#include <linux/hash.h>
4042

4143
#include <asm/sections.h>
4244

@@ -238,8 +240,7 @@ LIST_HEAD(all_lock_classes);
238240
*/
239241
#define CLASSHASH_BITS (MAX_LOCKDEP_KEYS_BITS - 1)
240242
#define CLASSHASH_SIZE (1UL << CLASSHASH_BITS)
241-
#define CLASSHASH_MASK (CLASSHASH_SIZE - 1)
242-
#define __classhashfn(key) ((((unsigned long)key >> CLASSHASH_BITS) + (unsigned long)key) & CLASSHASH_MASK)
243+
#define __classhashfn(key) hash_long((unsigned long)key, CLASSHASH_BITS)
243244
#define classhashentry(key) (classhash_table + __classhashfn((key)))
244245

245246
static struct list_head classhash_table[CLASSHASH_SIZE];
@@ -250,9 +251,7 @@ static struct list_head classhash_table[CLASSHASH_SIZE];
250251
*/
251252
#define CHAINHASH_BITS (MAX_LOCKDEP_CHAINS_BITS-1)
252253
#define CHAINHASH_SIZE (1UL << CHAINHASH_BITS)
253-
#define CHAINHASH_MASK (CHAINHASH_SIZE - 1)
254-
#define __chainhashfn(chain) \
255-
(((chain >> CHAINHASH_BITS) + chain) & CHAINHASH_MASK)
254+
#define __chainhashfn(chain) hash_long(chain, CHAINHASH_BITS)
256255
#define chainhashentry(chain) (chainhash_table + __chainhashfn((chain)))
257256

258257
static struct list_head chainhash_table[CHAINHASH_SIZE];
@@ -676,7 +675,8 @@ look_up_lock_class(struct lockdep_map *lock, unsigned int subclass)
676675
* (or spin_lock_init()) call - which acts as the key. For static
677676
* locks we use the lock object itself as the key.
678677
*/
679-
BUILD_BUG_ON(sizeof(struct lock_class_key) > sizeof(struct lock_class));
678+
BUILD_BUG_ON(sizeof(struct lock_class_key) >
679+
sizeof(struct lockdep_map));
680680

681681
key = lock->key->subkeys + subclass;
682682

@@ -686,9 +686,12 @@ look_up_lock_class(struct lockdep_map *lock, unsigned int subclass)
686686
* We can walk the hash lockfree, because the hash only
687687
* grows, and we are careful when adding entries to the end:
688688
*/
689-
list_for_each_entry(class, hash_head, hash_entry)
690-
if (class->key == key)
689+
list_for_each_entry(class, hash_head, hash_entry) {
690+
if (class->key == key) {
691+
WARN_ON_ONCE(class->name != lock->name);
691692
return class;
693+
}
694+
}
692695

693696
return NULL;
694697
}

‎kernel/lockdep_proc.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
*
66
* Started by Ingo Molnar:
77
*
8-
* Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
8+
* Copyright (C) 2006,2007 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
9+
* Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com>
910
*
1011
* Code for /proc/lockdep and /proc/lockdep_stats:
1112
*
@@ -498,6 +499,9 @@ static void *ls_start(struct seq_file *m, loff_t *pos)
498499
if (data->iter == data->stats)
499500
seq_header(m);
500501

502+
if (data->iter == data->iter_end)
503+
data->iter = NULL;
504+
501505
return data->iter;
502506
}
503507

0 commit comments

Comments
 (0)