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