diff options
author | Robin Holt <holt@sgi.com> | 2009-04-02 19:59:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-02 22:05:11 -0400 |
commit | f5f7eac41db827a47b2163330eecd7bb55ae9f12 (patch) | |
tree | ae8ab45dba49c1b3d5f2088051389e6fd3e4a24c | |
parent | e8c158bb313c1df421eab7dc4299cd39cbbf5895 (diff) |
Allow rwlocks to re-enable interrupts
Pass the original flags to rwlock arch-code, so that it can re-enable
interrupts if implemented for that architecture.
Initially, make __raw_read_lock_flags and __raw_write_lock_flags stubs
which just do the same thing as non-flags variants.
Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Signed-off-by: Robin Holt <holt@sgi.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: <linux-arch@vger.kernel.org>
Acked-by: Ingo Molnar <mingo@elte.hu>
Cc: "Luck, Tony" <tony.luck@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | arch/alpha/include/asm/spinlock.h | 3 | ||||
-rw-r--r-- | arch/arm/include/asm/spinlock.h | 3 | ||||
-rw-r--r-- | arch/cris/include/arch-v32/arch/spinlock.h | 2 | ||||
-rw-r--r-- | arch/ia64/include/asm/spinlock.h | 3 | ||||
-rw-r--r-- | arch/mips/include/asm/spinlock.h | 2 | ||||
-rw-r--r-- | arch/parisc/include/asm/spinlock.h | 3 | ||||
-rw-r--r-- | arch/powerpc/include/asm/spinlock.h | 3 | ||||
-rw-r--r-- | arch/s390/include/asm/spinlock.h | 3 | ||||
-rw-r--r-- | arch/sh/include/asm/spinlock.h | 3 | ||||
-rw-r--r-- | arch/sparc/include/asm/spinlock_32.h | 2 | ||||
-rw-r--r-- | arch/sparc/include/asm/spinlock_64.h | 2 | ||||
-rw-r--r-- | arch/x86/include/asm/spinlock.h | 3 | ||||
-rw-r--r-- | include/asm-m32r/spinlock.h | 3 | ||||
-rw-r--r-- | include/linux/spinlock.h | 6 | ||||
-rw-r--r-- | kernel/spinlock.c | 6 |
15 files changed, 45 insertions, 2 deletions
diff --git a/arch/alpha/include/asm/spinlock.h b/arch/alpha/include/asm/spinlock.h index aeeb125f6851..e38fb95cb335 100644 --- a/arch/alpha/include/asm/spinlock.h +++ b/arch/alpha/include/asm/spinlock.h | |||
@@ -166,6 +166,9 @@ static inline void __raw_write_unlock(raw_rwlock_t * lock) | |||
166 | lock->lock = 0; | 166 | lock->lock = 0; |
167 | } | 167 | } |
168 | 168 | ||
169 | #define __raw_read_lock_flags(lock, flags) __raw_read_lock(lock) | ||
170 | #define __raw_write_lock_flags(lock, flags) __raw_write_lock(lock) | ||
171 | |||
169 | #define _raw_spin_relax(lock) cpu_relax() | 172 | #define _raw_spin_relax(lock) cpu_relax() |
170 | #define _raw_read_relax(lock) cpu_relax() | 173 | #define _raw_read_relax(lock) cpu_relax() |
171 | #define _raw_write_relax(lock) cpu_relax() | 174 | #define _raw_write_relax(lock) cpu_relax() |
diff --git a/arch/arm/include/asm/spinlock.h b/arch/arm/include/asm/spinlock.h index 2b41ebbfa7ff..c13681ac1ede 100644 --- a/arch/arm/include/asm/spinlock.h +++ b/arch/arm/include/asm/spinlock.h | |||
@@ -217,6 +217,9 @@ static inline int __raw_read_trylock(raw_rwlock_t *rw) | |||
217 | /* read_can_lock - would read_trylock() succeed? */ | 217 | /* read_can_lock - would read_trylock() succeed? */ |
218 | #define __raw_read_can_lock(x) ((x)->lock < 0x80000000) | 218 | #define __raw_read_can_lock(x) ((x)->lock < 0x80000000) |
219 | 219 | ||
220 | #define __raw_read_lock_flags(lock, flags) __raw_read_lock(lock) | ||
221 | #define __raw_write_lock_flags(lock, flags) __raw_write_lock(lock) | ||
222 | |||
220 | #define _raw_spin_relax(lock) cpu_relax() | 223 | #define _raw_spin_relax(lock) cpu_relax() |
221 | #define _raw_read_relax(lock) cpu_relax() | 224 | #define _raw_read_relax(lock) cpu_relax() |
222 | #define _raw_write_relax(lock) cpu_relax() | 225 | #define _raw_write_relax(lock) cpu_relax() |
diff --git a/arch/cris/include/arch-v32/arch/spinlock.h b/arch/cris/include/arch-v32/arch/spinlock.h index 0d5709b983a1..129756b96661 100644 --- a/arch/cris/include/arch-v32/arch/spinlock.h +++ b/arch/cris/include/arch-v32/arch/spinlock.h | |||
@@ -121,6 +121,8 @@ static inline int __raw_write_trylock(raw_rwlock_t *rw) | |||
121 | return 1; | 121 | return 1; |
122 | } | 122 | } |
123 | 123 | ||
124 | #define _raw_read_lock_flags(lock, flags) _raw_read_lock(lock) | ||
125 | #define _raw_write_lock_flags(lock, flags) _raw_write_lock(lock) | ||
124 | 126 | ||
125 | #define _raw_spin_relax(lock) cpu_relax() | 127 | #define _raw_spin_relax(lock) cpu_relax() |
126 | #define _raw_read_relax(lock) cpu_relax() | 128 | #define _raw_read_relax(lock) cpu_relax() |
diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h index 0229fb95fb38..0a619618b2fa 100644 --- a/arch/ia64/include/asm/spinlock.h +++ b/arch/ia64/include/asm/spinlock.h | |||
@@ -213,6 +213,9 @@ static inline int __raw_read_trylock(raw_rwlock_t *x) | |||
213 | return (u32)ia64_cmpxchg4_acq((__u32 *)(x), new.word, old.word) == old.word; | 213 | return (u32)ia64_cmpxchg4_acq((__u32 *)(x), new.word, old.word) == old.word; |
214 | } | 214 | } |
215 | 215 | ||
216 | #define __raw_read_lock_flags(lock, flags) __raw_read_lock(lock) | ||
217 | #define __raw_write_lock_flags(lock, flags) __raw_write_lock(lock) | ||
218 | |||
216 | #define _raw_spin_relax(lock) cpu_relax() | 219 | #define _raw_spin_relax(lock) cpu_relax() |
217 | #define _raw_read_relax(lock) cpu_relax() | 220 | #define _raw_read_relax(lock) cpu_relax() |
218 | #define _raw_write_relax(lock) cpu_relax() | 221 | #define _raw_write_relax(lock) cpu_relax() |
diff --git a/arch/mips/include/asm/spinlock.h b/arch/mips/include/asm/spinlock.h index 10e82441b496..5b60a09a0f08 100644 --- a/arch/mips/include/asm/spinlock.h +++ b/arch/mips/include/asm/spinlock.h | |||
@@ -480,6 +480,8 @@ static inline int __raw_write_trylock(raw_rwlock_t *rw) | |||
480 | return ret; | 480 | return ret; |
481 | } | 481 | } |
482 | 482 | ||
483 | #define __raw_read_lock_flags(lock, flags) __raw_read_lock(lock) | ||
484 | #define __raw_write_lock_flags(lock, flags) __raw_write_lock(lock) | ||
483 | 485 | ||
484 | #define _raw_spin_relax(lock) cpu_relax() | 486 | #define _raw_spin_relax(lock) cpu_relax() |
485 | #define _raw_read_relax(lock) cpu_relax() | 487 | #define _raw_read_relax(lock) cpu_relax() |
diff --git a/arch/parisc/include/asm/spinlock.h b/arch/parisc/include/asm/spinlock.h index f3d2090a18dc..fae03e136fa8 100644 --- a/arch/parisc/include/asm/spinlock.h +++ b/arch/parisc/include/asm/spinlock.h | |||
@@ -187,6 +187,9 @@ static __inline__ int __raw_write_can_lock(raw_rwlock_t *rw) | |||
187 | return !rw->counter; | 187 | return !rw->counter; |
188 | } | 188 | } |
189 | 189 | ||
190 | #define __raw_read_lock_flags(lock, flags) __raw_read_lock(lock) | ||
191 | #define __raw_write_lock_flags(lock, flags) __raw_write_lock(lock) | ||
192 | |||
190 | #define _raw_spin_relax(lock) cpu_relax() | 193 | #define _raw_spin_relax(lock) cpu_relax() |
191 | #define _raw_read_relax(lock) cpu_relax() | 194 | #define _raw_read_relax(lock) cpu_relax() |
192 | #define _raw_write_relax(lock) cpu_relax() | 195 | #define _raw_write_relax(lock) cpu_relax() |
diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h index 36864364e601..c3b193121f81 100644 --- a/arch/powerpc/include/asm/spinlock.h +++ b/arch/powerpc/include/asm/spinlock.h | |||
@@ -287,6 +287,9 @@ static inline void __raw_write_unlock(raw_rwlock_t *rw) | |||
287 | rw->lock = 0; | 287 | rw->lock = 0; |
288 | } | 288 | } |
289 | 289 | ||
290 | #define __raw_read_lock_flags(lock, flags) __raw_read_lock(lock) | ||
291 | #define __raw_write_lock_flags(lock, flags) __raw_write_lock(lock) | ||
292 | |||
290 | #define _raw_spin_relax(lock) __spin_yield(lock) | 293 | #define _raw_spin_relax(lock) __spin_yield(lock) |
291 | #define _raw_read_relax(lock) __rw_yield(lock) | 294 | #define _raw_read_relax(lock) __rw_yield(lock) |
292 | #define _raw_write_relax(lock) __rw_yield(lock) | 295 | #define _raw_write_relax(lock) __rw_yield(lock) |
diff --git a/arch/s390/include/asm/spinlock.h b/arch/s390/include/asm/spinlock.h index df84ae96915f..f3861b09ebb0 100644 --- a/arch/s390/include/asm/spinlock.h +++ b/arch/s390/include/asm/spinlock.h | |||
@@ -172,6 +172,9 @@ static inline int __raw_write_trylock(raw_rwlock_t *rw) | |||
172 | return _raw_write_trylock_retry(rw); | 172 | return _raw_write_trylock_retry(rw); |
173 | } | 173 | } |
174 | 174 | ||
175 | #define __raw_read_lock_flags(lock, flags) __raw_read_lock(lock) | ||
176 | #define __raw_write_lock_flags(lock, flags) __raw_write_lock(lock) | ||
177 | |||
175 | #define _raw_read_relax(lock) cpu_relax() | 178 | #define _raw_read_relax(lock) cpu_relax() |
176 | #define _raw_write_relax(lock) cpu_relax() | 179 | #define _raw_write_relax(lock) cpu_relax() |
177 | 180 | ||
diff --git a/arch/sh/include/asm/spinlock.h b/arch/sh/include/asm/spinlock.h index e793181d64da..60283565f89b 100644 --- a/arch/sh/include/asm/spinlock.h +++ b/arch/sh/include/asm/spinlock.h | |||
@@ -216,6 +216,9 @@ static inline int __raw_write_trylock(raw_rwlock_t *rw) | |||
216 | return (oldval > (RW_LOCK_BIAS - 1)); | 216 | return (oldval > (RW_LOCK_BIAS - 1)); |
217 | } | 217 | } |
218 | 218 | ||
219 | #define __raw_read_lock_flags(lock, flags) __raw_read_lock(lock) | ||
220 | #define __raw_write_lock_flags(lock, flags) __raw_write_lock(lock) | ||
221 | |||
219 | #define _raw_spin_relax(lock) cpu_relax() | 222 | #define _raw_spin_relax(lock) cpu_relax() |
220 | #define _raw_read_relax(lock) cpu_relax() | 223 | #define _raw_read_relax(lock) cpu_relax() |
221 | #define _raw_write_relax(lock) cpu_relax() | 224 | #define _raw_write_relax(lock) cpu_relax() |
diff --git a/arch/sparc/include/asm/spinlock_32.h b/arch/sparc/include/asm/spinlock_32.h index bf2d532593e3..46f91ab66a50 100644 --- a/arch/sparc/include/asm/spinlock_32.h +++ b/arch/sparc/include/asm/spinlock_32.h | |||
@@ -177,6 +177,8 @@ static inline int __read_trylock(raw_rwlock_t *rw) | |||
177 | #define __raw_write_unlock(rw) do { (rw)->lock = 0; } while(0) | 177 | #define __raw_write_unlock(rw) do { (rw)->lock = 0; } while(0) |
178 | 178 | ||
179 | #define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock) | 179 | #define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock) |
180 | #define __raw_read_lock_flags(rw, flags) __raw_read_lock(rw) | ||
181 | #define __raw_write_lock_flags(rw, flags) __raw_write_lock(rw) | ||
180 | 182 | ||
181 | #define _raw_spin_relax(lock) cpu_relax() | 183 | #define _raw_spin_relax(lock) cpu_relax() |
182 | #define _raw_read_relax(lock) cpu_relax() | 184 | #define _raw_read_relax(lock) cpu_relax() |
diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h index c4d274d330e9..f6b2b92ad8d2 100644 --- a/arch/sparc/include/asm/spinlock_64.h +++ b/arch/sparc/include/asm/spinlock_64.h | |||
@@ -211,9 +211,11 @@ static int inline __write_trylock(raw_rwlock_t *lock) | |||
211 | } | 211 | } |
212 | 212 | ||
213 | #define __raw_read_lock(p) __read_lock(p) | 213 | #define __raw_read_lock(p) __read_lock(p) |
214 | #define __raw_read_lock_flags(p, f) __read_lock(p) | ||
214 | #define __raw_read_trylock(p) __read_trylock(p) | 215 | #define __raw_read_trylock(p) __read_trylock(p) |
215 | #define __raw_read_unlock(p) __read_unlock(p) | 216 | #define __raw_read_unlock(p) __read_unlock(p) |
216 | #define __raw_write_lock(p) __write_lock(p) | 217 | #define __raw_write_lock(p) __write_lock(p) |
218 | #define __raw_write_lock_flags(p, f) __write_lock(p) | ||
217 | #define __raw_write_unlock(p) __write_unlock(p) | 219 | #define __raw_write_unlock(p) __write_unlock(p) |
218 | #define __raw_write_trylock(p) __write_trylock(p) | 220 | #define __raw_write_trylock(p) __write_trylock(p) |
219 | 221 | ||
diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h index 3a5696656680..e5e6caffec87 100644 --- a/arch/x86/include/asm/spinlock.h +++ b/arch/x86/include/asm/spinlock.h | |||
@@ -295,6 +295,9 @@ static inline void __raw_write_unlock(raw_rwlock_t *rw) | |||
295 | : "+m" (rw->lock) : "i" (RW_LOCK_BIAS) : "memory"); | 295 | : "+m" (rw->lock) : "i" (RW_LOCK_BIAS) : "memory"); |
296 | } | 296 | } |
297 | 297 | ||
298 | #define __raw_read_lock_flags(lock, flags) __raw_read_lock(lock) | ||
299 | #define __raw_write_lock_flags(lock, flags) __raw_write_lock(lock) | ||
300 | |||
298 | #define _raw_spin_relax(lock) cpu_relax() | 301 | #define _raw_spin_relax(lock) cpu_relax() |
299 | #define _raw_read_relax(lock) cpu_relax() | 302 | #define _raw_read_relax(lock) cpu_relax() |
300 | #define _raw_write_relax(lock) cpu_relax() | 303 | #define _raw_write_relax(lock) cpu_relax() |
diff --git a/include/asm-m32r/spinlock.h b/include/asm-m32r/spinlock.h index f5cfba81ee10..dded923883b2 100644 --- a/include/asm-m32r/spinlock.h +++ b/include/asm-m32r/spinlock.h | |||
@@ -316,6 +316,9 @@ static inline int __raw_write_trylock(raw_rwlock_t *lock) | |||
316 | return 0; | 316 | return 0; |
317 | } | 317 | } |
318 | 318 | ||
319 | #define __raw_read_lock_flags(lock, flags) __raw_read_lock(lock) | ||
320 | #define __raw_write_lock_flags(lock, flags) __raw_write_lock(lock) | ||
321 | |||
319 | #define _raw_spin_relax(lock) cpu_relax() | 322 | #define _raw_spin_relax(lock) cpu_relax() |
320 | #define _raw_read_relax(lock) cpu_relax() | 323 | #define _raw_read_relax(lock) cpu_relax() |
321 | #define _raw_write_relax(lock) cpu_relax() | 324 | #define _raw_write_relax(lock) cpu_relax() |
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h index a0c66a2e00ad..252b245cfcf4 100644 --- a/include/linux/spinlock.h +++ b/include/linux/spinlock.h | |||
@@ -153,9 +153,11 @@ do { \ | |||
153 | extern int _raw_spin_trylock(spinlock_t *lock); | 153 | extern int _raw_spin_trylock(spinlock_t *lock); |
154 | extern void _raw_spin_unlock(spinlock_t *lock); | 154 | extern void _raw_spin_unlock(spinlock_t *lock); |
155 | extern void _raw_read_lock(rwlock_t *lock); | 155 | extern void _raw_read_lock(rwlock_t *lock); |
156 | #define _raw_read_lock_flags(lock, flags) _raw_read_lock(lock) | ||
156 | extern int _raw_read_trylock(rwlock_t *lock); | 157 | extern int _raw_read_trylock(rwlock_t *lock); |
157 | extern void _raw_read_unlock(rwlock_t *lock); | 158 | extern void _raw_read_unlock(rwlock_t *lock); |
158 | extern void _raw_write_lock(rwlock_t *lock); | 159 | extern void _raw_write_lock(rwlock_t *lock); |
160 | #define _raw_write_lock_flags(lock, flags) _raw_write_lock(lock) | ||
159 | extern int _raw_write_trylock(rwlock_t *lock); | 161 | extern int _raw_write_trylock(rwlock_t *lock); |
160 | extern void _raw_write_unlock(rwlock_t *lock); | 162 | extern void _raw_write_unlock(rwlock_t *lock); |
161 | #else | 163 | #else |
@@ -165,9 +167,13 @@ do { \ | |||
165 | # define _raw_spin_trylock(lock) __raw_spin_trylock(&(lock)->raw_lock) | 167 | # define _raw_spin_trylock(lock) __raw_spin_trylock(&(lock)->raw_lock) |
166 | # define _raw_spin_unlock(lock) __raw_spin_unlock(&(lock)->raw_lock) | 168 | # define _raw_spin_unlock(lock) __raw_spin_unlock(&(lock)->raw_lock) |
167 | # define _raw_read_lock(rwlock) __raw_read_lock(&(rwlock)->raw_lock) | 169 | # define _raw_read_lock(rwlock) __raw_read_lock(&(rwlock)->raw_lock) |
170 | # define _raw_read_lock_flags(lock, flags) \ | ||
171 | __raw_read_lock_flags(&(lock)->raw_lock, *(flags)) | ||
168 | # define _raw_read_trylock(rwlock) __raw_read_trylock(&(rwlock)->raw_lock) | 172 | # define _raw_read_trylock(rwlock) __raw_read_trylock(&(rwlock)->raw_lock) |
169 | # define _raw_read_unlock(rwlock) __raw_read_unlock(&(rwlock)->raw_lock) | 173 | # define _raw_read_unlock(rwlock) __raw_read_unlock(&(rwlock)->raw_lock) |
170 | # define _raw_write_lock(rwlock) __raw_write_lock(&(rwlock)->raw_lock) | 174 | # define _raw_write_lock(rwlock) __raw_write_lock(&(rwlock)->raw_lock) |
175 | # define _raw_write_lock_flags(lock, flags) \ | ||
176 | __raw_write_lock_flags(&(lock)->raw_lock, *(flags)) | ||
171 | # define _raw_write_trylock(rwlock) __raw_write_trylock(&(rwlock)->raw_lock) | 177 | # define _raw_write_trylock(rwlock) __raw_write_trylock(&(rwlock)->raw_lock) |
172 | # define _raw_write_unlock(rwlock) __raw_write_unlock(&(rwlock)->raw_lock) | 178 | # define _raw_write_unlock(rwlock) __raw_write_unlock(&(rwlock)->raw_lock) |
173 | #endif | 179 | #endif |
diff --git a/kernel/spinlock.c b/kernel/spinlock.c index 7283c6dc2d59..7932653c4ebd 100644 --- a/kernel/spinlock.c +++ b/kernel/spinlock.c | |||
@@ -121,7 +121,8 @@ unsigned long __lockfunc _read_lock_irqsave(rwlock_t *lock) | |||
121 | local_irq_save(flags); | 121 | local_irq_save(flags); |
122 | preempt_disable(); | 122 | preempt_disable(); |
123 | rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_); | 123 | rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_); |
124 | LOCK_CONTENDED(lock, _raw_read_trylock, _raw_read_lock); | 124 | LOCK_CONTENDED_FLAGS(lock, _raw_read_trylock, _raw_read_lock, |
125 | _raw_read_lock_flags, &flags); | ||
125 | return flags; | 126 | return flags; |
126 | } | 127 | } |
127 | EXPORT_SYMBOL(_read_lock_irqsave); | 128 | EXPORT_SYMBOL(_read_lock_irqsave); |
@@ -151,7 +152,8 @@ unsigned long __lockfunc _write_lock_irqsave(rwlock_t *lock) | |||
151 | local_irq_save(flags); | 152 | local_irq_save(flags); |
152 | preempt_disable(); | 153 | preempt_disable(); |
153 | rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_); | 154 | rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_); |
154 | LOCK_CONTENDED(lock, _raw_write_trylock, _raw_write_lock); | 155 | LOCK_CONTENDED_FLAGS(lock, _raw_write_trylock, _raw_write_lock, |
156 | _raw_write_lock_flags, &flags); | ||
155 | return flags; | 157 | return flags; |
156 | } | 158 | } |
157 | EXPORT_SYMBOL(_write_lock_irqsave); | 159 | EXPORT_SYMBOL(_write_lock_irqsave); |