diff options
| author | Ingo Molnar <mingo@elte.hu> | 2006-07-03 03:24:54 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-07-03 18:27:04 -0400 |
| commit | 8a25d5debff2daee280e83e09d8c25d67c26a972 (patch) | |
| tree | 3bccfef9acb66fc62863bfd6c16493c5e8c8e394 /lib | |
| parent | 4ea2176dfa714882e88180b474e4cbcd888b70af (diff) | |
[PATCH] lockdep: prove spinlock rwlock locking correctness
Use the lock validator framework to prove spinlock and rwlock locking
correctness.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/kernel_lock.c | 7 | ||||
| -rw-r--r-- | lib/spinlock_debug.c | 36 |
2 files changed, 42 insertions, 1 deletions
diff --git a/lib/kernel_lock.c b/lib/kernel_lock.c index e713e86811ae..e0fdfddb406e 100644 --- a/lib/kernel_lock.c +++ b/lib/kernel_lock.c | |||
| @@ -177,7 +177,12 @@ static inline void __lock_kernel(void) | |||
| 177 | 177 | ||
| 178 | static inline void __unlock_kernel(void) | 178 | static inline void __unlock_kernel(void) |
| 179 | { | 179 | { |
| 180 | spin_unlock(&kernel_flag); | 180 | /* |
| 181 | * the BKL is not covered by lockdep, so we open-code the | ||
| 182 | * unlocking sequence (and thus avoid the dep-chain ops): | ||
| 183 | */ | ||
| 184 | _raw_spin_unlock(&kernel_flag); | ||
| 185 | preempt_enable(); | ||
| 181 | } | 186 | } |
| 182 | 187 | ||
| 183 | /* | 188 | /* |
diff --git a/lib/spinlock_debug.c b/lib/spinlock_debug.c index 3de2ccf48ac6..3d9c4dc965ed 100644 --- a/lib/spinlock_debug.c +++ b/lib/spinlock_debug.c | |||
| @@ -12,6 +12,42 @@ | |||
| 12 | #include <linux/delay.h> | 12 | #include <linux/delay.h> |
| 13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
| 14 | 14 | ||
| 15 | void __spin_lock_init(spinlock_t *lock, const char *name, | ||
| 16 | struct lock_class_key *key) | ||
| 17 | { | ||
| 18 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
| 19 | /* | ||
| 20 | * Make sure we are not reinitializing a held lock: | ||
| 21 | */ | ||
| 22 | debug_check_no_locks_freed((void *)lock, sizeof(*lock)); | ||
| 23 | lockdep_init_map(&lock->dep_map, name, key); | ||
| 24 | #endif | ||
| 25 | lock->raw_lock = (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED; | ||
| 26 | lock->magic = SPINLOCK_MAGIC; | ||
| 27 | lock->owner = SPINLOCK_OWNER_INIT; | ||
| 28 | lock->owner_cpu = -1; | ||
| 29 | } | ||
| 30 | |||
| 31 | EXPORT_SYMBOL(__spin_lock_init); | ||
| 32 | |||
| 33 | void __rwlock_init(rwlock_t *lock, const char *name, | ||
| 34 | struct lock_class_key *key) | ||
| 35 | { | ||
| 36 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
| 37 | /* | ||
| 38 | * Make sure we are not reinitializing a held lock: | ||
| 39 | */ | ||
| 40 | debug_check_no_locks_freed((void *)lock, sizeof(*lock)); | ||
| 41 | lockdep_init_map(&lock->dep_map, name, key); | ||
| 42 | #endif | ||
| 43 | lock->raw_lock = (raw_rwlock_t) __RAW_RW_LOCK_UNLOCKED; | ||
| 44 | lock->magic = RWLOCK_MAGIC; | ||
| 45 | lock->owner = SPINLOCK_OWNER_INIT; | ||
| 46 | lock->owner_cpu = -1; | ||
| 47 | } | ||
| 48 | |||
| 49 | EXPORT_SYMBOL(__rwlock_init); | ||
| 50 | |||
| 15 | static void spin_bug(spinlock_t *lock, const char *msg) | 51 | static void spin_bug(spinlock_t *lock, const char *msg) |
| 16 | { | 52 | { |
| 17 | struct task_struct *owner = NULL; | 53 | struct task_struct *owner = NULL; |
