diff options
author | Ingo Molnar <mingo@elte.hu> | 2006-07-03 03:24:53 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-07-03 18:27:04 -0400 |
commit | 4ea2176dfa714882e88180b474e4cbcd888b70af (patch) | |
tree | 7ff3810f6b8750c226234887bb3063d91e1d71c3 /include/asm-i386/rwsem.h | |
parent | a8f24a3978c5f82419e1c90dc90460731204f46f (diff) |
[PATCH] lockdep: prove rwsem locking correctness
Use the lock validator framework to prove rwsem 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 'include/asm-i386/rwsem.h')
-rw-r--r-- | include/asm-i386/rwsem.h | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/include/asm-i386/rwsem.h b/include/asm-i386/rwsem.h index 558804e4a039..2f07601562e7 100644 --- a/include/asm-i386/rwsem.h +++ b/include/asm-i386/rwsem.h | |||
@@ -40,6 +40,7 @@ | |||
40 | 40 | ||
41 | #include <linux/list.h> | 41 | #include <linux/list.h> |
42 | #include <linux/spinlock.h> | 42 | #include <linux/spinlock.h> |
43 | #include <linux/lockdep.h> | ||
43 | 44 | ||
44 | struct rwsem_waiter; | 45 | struct rwsem_waiter; |
45 | 46 | ||
@@ -61,21 +62,34 @@ struct rw_semaphore { | |||
61 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) | 62 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) |
62 | spinlock_t wait_lock; | 63 | spinlock_t wait_lock; |
63 | struct list_head wait_list; | 64 | struct list_head wait_list; |
65 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
66 | struct lockdep_map dep_map; | ||
67 | #endif | ||
64 | }; | 68 | }; |
65 | 69 | ||
70 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
71 | # define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname } | ||
72 | #else | ||
73 | # define __RWSEM_DEP_MAP_INIT(lockname) | ||
74 | #endif | ||
75 | |||
76 | |||
66 | #define __RWSEM_INITIALIZER(name) \ | 77 | #define __RWSEM_INITIALIZER(name) \ |
67 | { RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, LIST_HEAD_INIT((name).wait_list) \ | 78 | { RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, LIST_HEAD_INIT((name).wait_list) \ |
68 | } | 79 | __RWSEM_DEP_MAP_INIT(name) } |
69 | 80 | ||
70 | #define DECLARE_RWSEM(name) \ | 81 | #define DECLARE_RWSEM(name) \ |
71 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | 82 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) |
72 | 83 | ||
73 | static inline void init_rwsem(struct rw_semaphore *sem) | 84 | extern void __init_rwsem(struct rw_semaphore *sem, const char *name, |
74 | { | 85 | struct lock_class_key *key); |
75 | sem->count = RWSEM_UNLOCKED_VALUE; | 86 | |
76 | spin_lock_init(&sem->wait_lock); | 87 | #define init_rwsem(sem) \ |
77 | INIT_LIST_HEAD(&sem->wait_list); | 88 | do { \ |
78 | } | 89 | static struct lock_class_key __key; \ |
90 | \ | ||
91 | __init_rwsem((sem), #sem, &__key); \ | ||
92 | } while (0) | ||
79 | 93 | ||
80 | /* | 94 | /* |
81 | * lock for reading | 95 | * lock for reading |
@@ -128,7 +142,7 @@ LOCK_PREFIX " cmpxchgl %2,%0\n\t" | |||
128 | /* | 142 | /* |
129 | * lock for writing | 143 | * lock for writing |
130 | */ | 144 | */ |
131 | static inline void __down_write(struct rw_semaphore *sem) | 145 | static inline void __down_write_nested(struct rw_semaphore *sem, int subclass) |
132 | { | 146 | { |
133 | int tmp; | 147 | int tmp; |
134 | 148 | ||
@@ -152,6 +166,11 @@ LOCK_PREFIX " xadd %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns the | |||
152 | : "memory", "cc"); | 166 | : "memory", "cc"); |
153 | } | 167 | } |
154 | 168 | ||
169 | static inline void __down_write(struct rw_semaphore *sem) | ||
170 | { | ||
171 | __down_write_nested(sem, 0); | ||
172 | } | ||
173 | |||
155 | /* | 174 | /* |
156 | * trylock for writing -- returns 1 if successful, 0 if contention | 175 | * trylock for writing -- returns 1 if successful, 0 if contention |
157 | */ | 176 | */ |