Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2005, Red Hat, Inc., Ingo Molnar |
| 3 | * Released under the General Public License (GPL). |
| 4 | * |
| 5 | * This file contains the spinlock/rwlock implementations for |
| 6 | * DEBUG_SPINLOCK. |
| 7 | */ |
| 8 | |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 9 | #include <linux/spinlock.h> |
Andrew Morton | bb81a09 | 2006-12-07 02:14:01 +0100 | [diff] [blame] | 10 | #include <linux/nmi.h> |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 11 | #include <linux/interrupt.h> |
Ingo Molnar | 9a11b49a | 2006-07-03 00:24:33 -0700 | [diff] [blame] | 12 | #include <linux/debug_locks.h> |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 13 | #include <linux/delay.h> |
Paul Gortmaker | 8bc3bcc | 2011-11-16 21:29:17 -0500 | [diff] [blame] | 14 | #include <linux/export.h> |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 15 | |
Thomas Gleixner | c2f21ce | 2009-12-02 20:02:59 +0100 | [diff] [blame] | 16 | void __raw_spin_lock_init(raw_spinlock_t *lock, const char *name, |
| 17 | struct lock_class_key *key) |
Ingo Molnar | 8a25d5d | 2006-07-03 00:24:54 -0700 | [diff] [blame] | 18 | { |
| 19 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
| 20 | /* |
| 21 | * Make sure we are not reinitializing a held lock: |
| 22 | */ |
| 23 | debug_check_no_locks_freed((void *)lock, sizeof(*lock)); |
Peter Zijlstra | 4dfbb9d | 2006-10-11 01:45:14 -0400 | [diff] [blame] | 24 | lockdep_init_map(&lock->dep_map, name, key, 0); |
Ingo Molnar | 8a25d5d | 2006-07-03 00:24:54 -0700 | [diff] [blame] | 25 | #endif |
Thomas Gleixner | edc35bd | 2009-12-03 12:38:57 +0100 | [diff] [blame] | 26 | lock->raw_lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED; |
Ingo Molnar | 8a25d5d | 2006-07-03 00:24:54 -0700 | [diff] [blame] | 27 | lock->magic = SPINLOCK_MAGIC; |
| 28 | lock->owner = SPINLOCK_OWNER_INIT; |
| 29 | lock->owner_cpu = -1; |
| 30 | } |
| 31 | |
Thomas Gleixner | c2f21ce | 2009-12-02 20:02:59 +0100 | [diff] [blame] | 32 | EXPORT_SYMBOL(__raw_spin_lock_init); |
Ingo Molnar | 8a25d5d | 2006-07-03 00:24:54 -0700 | [diff] [blame] | 33 | |
| 34 | void __rwlock_init(rwlock_t *lock, const char *name, |
| 35 | struct lock_class_key *key) |
| 36 | { |
| 37 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
| 38 | /* |
| 39 | * Make sure we are not reinitializing a held lock: |
| 40 | */ |
| 41 | debug_check_no_locks_freed((void *)lock, sizeof(*lock)); |
Peter Zijlstra | 4dfbb9d | 2006-10-11 01:45:14 -0400 | [diff] [blame] | 42 | lockdep_init_map(&lock->dep_map, name, key, 0); |
Ingo Molnar | 8a25d5d | 2006-07-03 00:24:54 -0700 | [diff] [blame] | 43 | #endif |
Thomas Gleixner | fb3a6bb | 2009-12-03 20:01:19 +0100 | [diff] [blame] | 44 | lock->raw_lock = (arch_rwlock_t) __ARCH_RW_LOCK_UNLOCKED; |
Ingo Molnar | 8a25d5d | 2006-07-03 00:24:54 -0700 | [diff] [blame] | 45 | lock->magic = RWLOCK_MAGIC; |
| 46 | lock->owner = SPINLOCK_OWNER_INIT; |
| 47 | lock->owner_cpu = -1; |
| 48 | } |
| 49 | |
| 50 | EXPORT_SYMBOL(__rwlock_init); |
| 51 | |
Akinobu Mita | 4e101b0 | 2011-10-31 17:12:29 -0700 | [diff] [blame] | 52 | static void spin_dump(raw_spinlock_t *lock, const char *msg) |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 53 | { |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 54 | struct task_struct *owner = NULL; |
| 55 | |
Ingo Molnar | 9a11b49a | 2006-07-03 00:24:33 -0700 | [diff] [blame] | 56 | if (lock->owner && lock->owner != SPINLOCK_OWNER_INIT) |
| 57 | owner = lock->owner; |
| 58 | printk(KERN_EMERG "BUG: spinlock %s on CPU#%d, %s/%d\n", |
| 59 | msg, raw_smp_processor_id(), |
Pavel Emelyanov | ba25f9d | 2007-10-18 23:40:40 -0700 | [diff] [blame] | 60 | current->comm, task_pid_nr(current)); |
Stephen Boyd | 62878d3 | 2012-04-19 12:19:11 -0700 | [diff] [blame] | 61 | printk(KERN_EMERG " lock: %ps, .magic: %08x, .owner: %s/%d, " |
Ingo Molnar | 9a11b49a | 2006-07-03 00:24:33 -0700 | [diff] [blame] | 62 | ".owner_cpu: %d\n", |
| 63 | lock, lock->magic, |
| 64 | owner ? owner->comm : "<none>", |
Pavel Emelyanov | ba25f9d | 2007-10-18 23:40:40 -0700 | [diff] [blame] | 65 | owner ? task_pid_nr(owner) : -1, |
Ingo Molnar | 9a11b49a | 2006-07-03 00:24:33 -0700 | [diff] [blame] | 66 | lock->owner_cpu); |
| 67 | dump_stack(); |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 68 | } |
| 69 | |
Akinobu Mita | 4e101b0 | 2011-10-31 17:12:29 -0700 | [diff] [blame] | 70 | static void spin_bug(raw_spinlock_t *lock, const char *msg) |
| 71 | { |
| 72 | if (!debug_locks_off()) |
| 73 | return; |
| 74 | |
| 75 | spin_dump(lock, msg); |
| 76 | } |
| 77 | |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 78 | #define SPIN_BUG_ON(cond, lock, msg) if (unlikely(cond)) spin_bug(lock, msg) |
| 79 | |
Ingo Molnar | 9a11b49a | 2006-07-03 00:24:33 -0700 | [diff] [blame] | 80 | static inline void |
Thomas Gleixner | c2f21ce | 2009-12-02 20:02:59 +0100 | [diff] [blame] | 81 | debug_spin_lock_before(raw_spinlock_t *lock) |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 82 | { |
| 83 | SPIN_BUG_ON(lock->magic != SPINLOCK_MAGIC, lock, "bad magic"); |
| 84 | SPIN_BUG_ON(lock->owner == current, lock, "recursion"); |
| 85 | SPIN_BUG_ON(lock->owner_cpu == raw_smp_processor_id(), |
| 86 | lock, "cpu recursion"); |
| 87 | } |
| 88 | |
Thomas Gleixner | c2f21ce | 2009-12-02 20:02:59 +0100 | [diff] [blame] | 89 | static inline void debug_spin_lock_after(raw_spinlock_t *lock) |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 90 | { |
| 91 | lock->owner_cpu = raw_smp_processor_id(); |
| 92 | lock->owner = current; |
| 93 | } |
| 94 | |
Thomas Gleixner | c2f21ce | 2009-12-02 20:02:59 +0100 | [diff] [blame] | 95 | static inline void debug_spin_unlock(raw_spinlock_t *lock) |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 96 | { |
| 97 | SPIN_BUG_ON(lock->magic != SPINLOCK_MAGIC, lock, "bad magic"); |
Thomas Gleixner | c2f21ce | 2009-12-02 20:02:59 +0100 | [diff] [blame] | 98 | SPIN_BUG_ON(!raw_spin_is_locked(lock), lock, "already unlocked"); |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 99 | SPIN_BUG_ON(lock->owner != current, lock, "wrong owner"); |
| 100 | SPIN_BUG_ON(lock->owner_cpu != raw_smp_processor_id(), |
| 101 | lock, "wrong CPU"); |
| 102 | lock->owner = SPINLOCK_OWNER_INIT; |
| 103 | lock->owner_cpu = -1; |
| 104 | } |
| 105 | |
Thomas Gleixner | c2f21ce | 2009-12-02 20:02:59 +0100 | [diff] [blame] | 106 | static void __spin_lock_debug(raw_spinlock_t *lock) |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 107 | { |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 108 | u64 i; |
Chuck Ebbert | c22f008 | 2006-09-29 01:59:14 -0700 | [diff] [blame] | 109 | u64 loops = loops_per_jiffy * HZ; |
| 110 | int print_once = 1; |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 111 | |
| 112 | for (;;) { |
Chuck Ebbert | c22f008 | 2006-09-29 01:59:14 -0700 | [diff] [blame] | 113 | for (i = 0; i < loops; i++) { |
Thomas Gleixner | 0199c4e | 2009-12-02 20:01:25 +0100 | [diff] [blame] | 114 | if (arch_spin_trylock(&lock->raw_lock)) |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 115 | return; |
Ingo Molnar | e0a6029 | 2006-02-07 12:58:54 -0800 | [diff] [blame] | 116 | __delay(1); |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 117 | } |
| 118 | /* lockup suspected: */ |
| 119 | if (print_once) { |
| 120 | print_once = 0; |
Dave Jones | 51989b9 | 2006-01-09 20:51:32 -0800 | [diff] [blame] | 121 | printk(KERN_EMERG "BUG: spinlock lockup on CPU#%d, " |
Stephen Boyd | 62878d3 | 2012-04-19 12:19:11 -0700 | [diff] [blame] | 122 | "%s/%d, %ps\n", |
Ingo Molnar | bb44f11 | 2005-12-20 11:54:17 +0100 | [diff] [blame] | 123 | raw_smp_processor_id(), current->comm, |
Pavel Emelyanov | ba25f9d | 2007-10-18 23:40:40 -0700 | [diff] [blame] | 124 | task_pid_nr(current), lock); |
Akinobu Mita | 4e101b0 | 2011-10-31 17:12:29 -0700 | [diff] [blame] | 125 | spin_dump(lock, "lockup"); |
Andrew Morton | bb81a09 | 2006-12-07 02:14:01 +0100 | [diff] [blame] | 126 | #ifdef CONFIG_SMP |
| 127 | trigger_all_cpu_backtrace(); |
| 128 | #endif |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 129 | } |
| 130 | } |
| 131 | } |
| 132 | |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 133 | void do_raw_spin_lock(raw_spinlock_t *lock) |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 134 | { |
| 135 | debug_spin_lock_before(lock); |
Thomas Gleixner | 0199c4e | 2009-12-02 20:01:25 +0100 | [diff] [blame] | 136 | if (unlikely(!arch_spin_trylock(&lock->raw_lock))) |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 137 | __spin_lock_debug(lock); |
| 138 | debug_spin_lock_after(lock); |
| 139 | } |
| 140 | |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 141 | int do_raw_spin_trylock(raw_spinlock_t *lock) |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 142 | { |
Thomas Gleixner | 0199c4e | 2009-12-02 20:01:25 +0100 | [diff] [blame] | 143 | int ret = arch_spin_trylock(&lock->raw_lock); |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 144 | |
| 145 | if (ret) |
| 146 | debug_spin_lock_after(lock); |
| 147 | #ifndef CONFIG_SMP |
| 148 | /* |
| 149 | * Must not happen on UP: |
| 150 | */ |
| 151 | SPIN_BUG_ON(!ret, lock, "trylock failure on UP"); |
| 152 | #endif |
| 153 | return ret; |
| 154 | } |
| 155 | |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 156 | void do_raw_spin_unlock(raw_spinlock_t *lock) |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 157 | { |
| 158 | debug_spin_unlock(lock); |
Thomas Gleixner | 0199c4e | 2009-12-02 20:01:25 +0100 | [diff] [blame] | 159 | arch_spin_unlock(&lock->raw_lock); |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | static void rwlock_bug(rwlock_t *lock, const char *msg) |
| 163 | { |
Ingo Molnar | 9a11b49a | 2006-07-03 00:24:33 -0700 | [diff] [blame] | 164 | if (!debug_locks_off()) |
| 165 | return; |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 166 | |
Ingo Molnar | 9a11b49a | 2006-07-03 00:24:33 -0700 | [diff] [blame] | 167 | printk(KERN_EMERG "BUG: rwlock %s on CPU#%d, %s/%d, %p\n", |
| 168 | msg, raw_smp_processor_id(), current->comm, |
Pavel Emelyanov | ba25f9d | 2007-10-18 23:40:40 -0700 | [diff] [blame] | 169 | task_pid_nr(current), lock); |
Ingo Molnar | 9a11b49a | 2006-07-03 00:24:33 -0700 | [diff] [blame] | 170 | dump_stack(); |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | #define RWLOCK_BUG_ON(cond, lock, msg) if (unlikely(cond)) rwlock_bug(lock, msg) |
| 174 | |
Andrew Morton | 72f0b4e | 2006-08-05 12:13:47 -0700 | [diff] [blame] | 175 | #if 0 /* __write_lock_debug() can lock up - maybe this can too? */ |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 176 | static void __read_lock_debug(rwlock_t *lock) |
| 177 | { |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 178 | u64 i; |
Chuck Ebbert | c22f008 | 2006-09-29 01:59:14 -0700 | [diff] [blame] | 179 | u64 loops = loops_per_jiffy * HZ; |
| 180 | int print_once = 1; |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 181 | |
| 182 | for (;;) { |
Chuck Ebbert | c22f008 | 2006-09-29 01:59:14 -0700 | [diff] [blame] | 183 | for (i = 0; i < loops; i++) { |
Thomas Gleixner | e593194 | 2009-12-03 20:08:46 +0100 | [diff] [blame] | 184 | if (arch_read_trylock(&lock->raw_lock)) |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 185 | return; |
Ingo Molnar | e0a6029 | 2006-02-07 12:58:54 -0800 | [diff] [blame] | 186 | __delay(1); |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 187 | } |
| 188 | /* lockup suspected: */ |
| 189 | if (print_once) { |
| 190 | print_once = 0; |
Dave Jones | 51989b9 | 2006-01-09 20:51:32 -0800 | [diff] [blame] | 191 | printk(KERN_EMERG "BUG: read-lock lockup on CPU#%d, " |
| 192 | "%s/%d, %p\n", |
Ingo Molnar | bb44f11 | 2005-12-20 11:54:17 +0100 | [diff] [blame] | 193 | raw_smp_processor_id(), current->comm, |
| 194 | current->pid, lock); |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 195 | dump_stack(); |
| 196 | } |
| 197 | } |
| 198 | } |
Andrew Morton | 72f0b4e | 2006-08-05 12:13:47 -0700 | [diff] [blame] | 199 | #endif |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 200 | |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 201 | void do_raw_read_lock(rwlock_t *lock) |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 202 | { |
| 203 | RWLOCK_BUG_ON(lock->magic != RWLOCK_MAGIC, lock, "bad magic"); |
Thomas Gleixner | e593194 | 2009-12-03 20:08:46 +0100 | [diff] [blame] | 204 | arch_read_lock(&lock->raw_lock); |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 205 | } |
| 206 | |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 207 | int do_raw_read_trylock(rwlock_t *lock) |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 208 | { |
Thomas Gleixner | e593194 | 2009-12-03 20:08:46 +0100 | [diff] [blame] | 209 | int ret = arch_read_trylock(&lock->raw_lock); |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 210 | |
| 211 | #ifndef CONFIG_SMP |
| 212 | /* |
| 213 | * Must not happen on UP: |
| 214 | */ |
| 215 | RWLOCK_BUG_ON(!ret, lock, "trylock failure on UP"); |
| 216 | #endif |
| 217 | return ret; |
| 218 | } |
| 219 | |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 220 | void do_raw_read_unlock(rwlock_t *lock) |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 221 | { |
| 222 | RWLOCK_BUG_ON(lock->magic != RWLOCK_MAGIC, lock, "bad magic"); |
Thomas Gleixner | e593194 | 2009-12-03 20:08:46 +0100 | [diff] [blame] | 223 | arch_read_unlock(&lock->raw_lock); |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | static inline void debug_write_lock_before(rwlock_t *lock) |
| 227 | { |
| 228 | RWLOCK_BUG_ON(lock->magic != RWLOCK_MAGIC, lock, "bad magic"); |
| 229 | RWLOCK_BUG_ON(lock->owner == current, lock, "recursion"); |
| 230 | RWLOCK_BUG_ON(lock->owner_cpu == raw_smp_processor_id(), |
| 231 | lock, "cpu recursion"); |
| 232 | } |
| 233 | |
| 234 | static inline void debug_write_lock_after(rwlock_t *lock) |
| 235 | { |
| 236 | lock->owner_cpu = raw_smp_processor_id(); |
| 237 | lock->owner = current; |
| 238 | } |
| 239 | |
| 240 | static inline void debug_write_unlock(rwlock_t *lock) |
| 241 | { |
| 242 | RWLOCK_BUG_ON(lock->magic != RWLOCK_MAGIC, lock, "bad magic"); |
| 243 | RWLOCK_BUG_ON(lock->owner != current, lock, "wrong owner"); |
| 244 | RWLOCK_BUG_ON(lock->owner_cpu != raw_smp_processor_id(), |
| 245 | lock, "wrong CPU"); |
| 246 | lock->owner = SPINLOCK_OWNER_INIT; |
| 247 | lock->owner_cpu = -1; |
| 248 | } |
| 249 | |
Andrew Morton | 72f0b4e | 2006-08-05 12:13:47 -0700 | [diff] [blame] | 250 | #if 0 /* This can cause lockups */ |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 251 | static void __write_lock_debug(rwlock_t *lock) |
| 252 | { |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 253 | u64 i; |
Chuck Ebbert | c22f008 | 2006-09-29 01:59:14 -0700 | [diff] [blame] | 254 | u64 loops = loops_per_jiffy * HZ; |
| 255 | int print_once = 1; |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 256 | |
| 257 | for (;;) { |
Chuck Ebbert | c22f008 | 2006-09-29 01:59:14 -0700 | [diff] [blame] | 258 | for (i = 0; i < loops; i++) { |
Thomas Gleixner | e593194 | 2009-12-03 20:08:46 +0100 | [diff] [blame] | 259 | if (arch_write_trylock(&lock->raw_lock)) |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 260 | return; |
Ingo Molnar | e0a6029 | 2006-02-07 12:58:54 -0800 | [diff] [blame] | 261 | __delay(1); |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 262 | } |
| 263 | /* lockup suspected: */ |
| 264 | if (print_once) { |
| 265 | print_once = 0; |
Dave Jones | 51989b9 | 2006-01-09 20:51:32 -0800 | [diff] [blame] | 266 | printk(KERN_EMERG "BUG: write-lock lockup on CPU#%d, " |
| 267 | "%s/%d, %p\n", |
Ingo Molnar | bb44f11 | 2005-12-20 11:54:17 +0100 | [diff] [blame] | 268 | raw_smp_processor_id(), current->comm, |
| 269 | current->pid, lock); |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 270 | dump_stack(); |
| 271 | } |
| 272 | } |
| 273 | } |
Andrew Morton | 72f0b4e | 2006-08-05 12:13:47 -0700 | [diff] [blame] | 274 | #endif |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 275 | |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 276 | void do_raw_write_lock(rwlock_t *lock) |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 277 | { |
| 278 | debug_write_lock_before(lock); |
Thomas Gleixner | e593194 | 2009-12-03 20:08:46 +0100 | [diff] [blame] | 279 | arch_write_lock(&lock->raw_lock); |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 280 | debug_write_lock_after(lock); |
| 281 | } |
| 282 | |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 283 | int do_raw_write_trylock(rwlock_t *lock) |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 284 | { |
Thomas Gleixner | e593194 | 2009-12-03 20:08:46 +0100 | [diff] [blame] | 285 | int ret = arch_write_trylock(&lock->raw_lock); |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 286 | |
| 287 | if (ret) |
| 288 | debug_write_lock_after(lock); |
| 289 | #ifndef CONFIG_SMP |
| 290 | /* |
| 291 | * Must not happen on UP: |
| 292 | */ |
| 293 | RWLOCK_BUG_ON(!ret, lock, "trylock failure on UP"); |
| 294 | #endif |
| 295 | return ret; |
| 296 | } |
| 297 | |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 298 | void do_raw_write_unlock(rwlock_t *lock) |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 299 | { |
| 300 | debug_write_unlock(lock); |
Thomas Gleixner | e593194 | 2009-12-03 20:08:46 +0100 | [diff] [blame] | 301 | arch_write_unlock(&lock->raw_lock); |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 302 | } |