diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-15 21:28:30 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-15 21:28:30 -0400 |
| commit | 0586bed3e8563c2eb89bc7256e30ce633ae06cfb (patch) | |
| tree | 7a59610f45f7222f25b3212c53fa28636bb4427c | |
| parent | b80cd62b7d4406bbe8c573fe4381dcc71a2850fd (diff) | |
| parent | dbebbfbb1605f0179e7c0d900d941cc9c45de569 (diff) | |
Merge branch 'core-locking-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'core-locking-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
rtmutex: tester: Remove the remaining BKL leftovers
lockdep/timers: Explain in detail the locking problems del_timer_sync() may cause
rtmutex: Simplify PI algorithm and make highest prio task get lock
rwsem: Remove redundant asmregparm annotation
rwsem: Move duplicate function prototypes to linux/rwsem.h
rwsem: Unify the duplicate rwsem_is_locked() inlines
rwsem: Move duplicate init macros and functions to linux/rwsem.h
rwsem: Move duplicate struct rwsem declaration to linux/rwsem.h
x86: Cleanup rwsem_count_t typedef
rwsem: Cleanup includes
locking: Remove deprecated lock initializers
cred: Replace deprecated spinlock initialization
kthread: Replace deprecated spinlock initialization
xtensa: Replace deprecated spinlock initialization
um: Replace deprecated spinlock initialization
sparc: Replace deprecated spinlock initialization
mips: Replace deprecated spinlock initialization
cris: Replace deprecated spinlock initialization
alpha: Replace deprecated spinlock initialization
rtmutex-tester: Remove BKL tests
40 files changed, 228 insertions, 816 deletions
diff --git a/Documentation/spinlocks.txt b/Documentation/spinlocks.txt index 178c831b907..2e3c64b1a6a 100644 --- a/Documentation/spinlocks.txt +++ b/Documentation/spinlocks.txt | |||
| @@ -86,7 +86,7 @@ to change the variables it has to get an exclusive write lock. | |||
| 86 | 86 | ||
| 87 | The routines look the same as above: | 87 | The routines look the same as above: |
| 88 | 88 | ||
| 89 | rwlock_t xxx_lock = RW_LOCK_UNLOCKED; | 89 | rwlock_t xxx_lock = __RW_LOCK_UNLOCKED(xxx_lock); |
| 90 | 90 | ||
| 91 | unsigned long flags; | 91 | unsigned long flags; |
| 92 | 92 | ||
| @@ -196,25 +196,3 @@ appropriate: | |||
| 196 | 196 | ||
| 197 | For static initialization, use DEFINE_SPINLOCK() / DEFINE_RWLOCK() or | 197 | For static initialization, use DEFINE_SPINLOCK() / DEFINE_RWLOCK() or |
| 198 | __SPIN_LOCK_UNLOCKED() / __RW_LOCK_UNLOCKED() as appropriate. | 198 | __SPIN_LOCK_UNLOCKED() / __RW_LOCK_UNLOCKED() as appropriate. |
| 199 | |||
| 200 | SPIN_LOCK_UNLOCKED and RW_LOCK_UNLOCKED are deprecated. These interfere | ||
| 201 | with lockdep state tracking. | ||
| 202 | |||
| 203 | Most of the time, you can simply turn: | ||
| 204 | static spinlock_t xxx_lock = SPIN_LOCK_UNLOCKED; | ||
| 205 | into: | ||
| 206 | static DEFINE_SPINLOCK(xxx_lock); | ||
| 207 | |||
| 208 | Static structure member variables go from: | ||
| 209 | |||
| 210 | struct foo bar { | ||
| 211 | .lock = SPIN_LOCK_UNLOCKED; | ||
| 212 | }; | ||
| 213 | |||
| 214 | to: | ||
| 215 | |||
| 216 | struct foo bar { | ||
| 217 | .lock = __SPIN_LOCK_UNLOCKED(bar.lock); | ||
| 218 | }; | ||
| 219 | |||
| 220 | Declaration of static rw_locks undergo a similar transformation. | ||
diff --git a/arch/alpha/include/asm/rwsem.h b/arch/alpha/include/asm/rwsem.h index 1570c0b5433..a83bbea62c6 100644 --- a/arch/alpha/include/asm/rwsem.h +++ b/arch/alpha/include/asm/rwsem.h | |||
| @@ -13,44 +13,13 @@ | |||
| 13 | #ifdef __KERNEL__ | 13 | #ifdef __KERNEL__ |
| 14 | 14 | ||
| 15 | #include <linux/compiler.h> | 15 | #include <linux/compiler.h> |
| 16 | #include <linux/list.h> | ||
| 17 | #include <linux/spinlock.h> | ||
| 18 | 16 | ||
| 19 | struct rwsem_waiter; | ||
| 20 | |||
| 21 | extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem); | ||
| 22 | extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); | ||
| 23 | extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *); | ||
| 24 | extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); | ||
| 25 | |||
| 26 | /* | ||
| 27 | * the semaphore definition | ||
| 28 | */ | ||
| 29 | struct rw_semaphore { | ||
| 30 | long count; | ||
| 31 | #define RWSEM_UNLOCKED_VALUE 0x0000000000000000L | 17 | #define RWSEM_UNLOCKED_VALUE 0x0000000000000000L |
| 32 | #define RWSEM_ACTIVE_BIAS 0x0000000000000001L | 18 | #define RWSEM_ACTIVE_BIAS 0x0000000000000001L |
| 33 | #define RWSEM_ACTIVE_MASK 0x00000000ffffffffL | 19 | #define RWSEM_ACTIVE_MASK 0x00000000ffffffffL |
| 34 | #define RWSEM_WAITING_BIAS (-0x0000000100000000L) | 20 | #define RWSEM_WAITING_BIAS (-0x0000000100000000L) |
| 35 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS | 21 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS |
| 36 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) | 22 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) |
| 37 | spinlock_t wait_lock; | ||
| 38 | struct list_head wait_list; | ||
| 39 | }; | ||
| 40 | |||
| 41 | #define __RWSEM_INITIALIZER(name) \ | ||
| 42 | { RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, \ | ||
| 43 | LIST_HEAD_INIT((name).wait_list) } | ||
| 44 | |||
| 45 | #define DECLARE_RWSEM(name) \ | ||
| 46 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | ||
| 47 | |||
| 48 | static inline void init_rwsem(struct rw_semaphore *sem) | ||
| 49 | { | ||
| 50 | sem->count = RWSEM_UNLOCKED_VALUE; | ||
| 51 | spin_lock_init(&sem->wait_lock); | ||
| 52 | INIT_LIST_HEAD(&sem->wait_list); | ||
| 53 | } | ||
| 54 | 23 | ||
| 55 | static inline void __down_read(struct rw_semaphore *sem) | 24 | static inline void __down_read(struct rw_semaphore *sem) |
| 56 | { | 25 | { |
| @@ -250,10 +219,5 @@ static inline long rwsem_atomic_update(long val, struct rw_semaphore *sem) | |||
| 250 | #endif | 219 | #endif |
| 251 | } | 220 | } |
| 252 | 221 | ||
| 253 | static inline int rwsem_is_locked(struct rw_semaphore *sem) | ||
| 254 | { | ||
| 255 | return (sem->count != 0); | ||
| 256 | } | ||
| 257 | |||
| 258 | #endif /* __KERNEL__ */ | 222 | #endif /* __KERNEL__ */ |
| 259 | #endif /* _ALPHA_RWSEM_H */ | 223 | #endif /* _ALPHA_RWSEM_H */ |
diff --git a/arch/cris/arch-v32/kernel/smp.c b/arch/cris/arch-v32/kernel/smp.c index 84fed3b4b07..4c9e3e1ba5d 100644 --- a/arch/cris/arch-v32/kernel/smp.c +++ b/arch/cris/arch-v32/kernel/smp.c | |||
| @@ -26,7 +26,9 @@ | |||
| 26 | #define FLUSH_ALL (void*)0xffffffff | 26 | #define FLUSH_ALL (void*)0xffffffff |
| 27 | 27 | ||
| 28 | /* Vector of locks used for various atomic operations */ | 28 | /* Vector of locks used for various atomic operations */ |
| 29 | spinlock_t cris_atomic_locks[] = { [0 ... LOCK_COUNT - 1] = SPIN_LOCK_UNLOCKED}; | 29 | spinlock_t cris_atomic_locks[] = { |
| 30 | [0 ... LOCK_COUNT - 1] = __SPIN_LOCK_UNLOCKED(cris_atomic_locks) | ||
| 31 | }; | ||
| 30 | 32 | ||
| 31 | /* CPU masks */ | 33 | /* CPU masks */ |
| 32 | cpumask_t phys_cpu_present_map = CPU_MASK_NONE; | 34 | cpumask_t phys_cpu_present_map = CPU_MASK_NONE; |
diff --git a/arch/ia64/include/asm/rwsem.h b/arch/ia64/include/asm/rwsem.h index 215d5454c7d..3027e7516d8 100644 --- a/arch/ia64/include/asm/rwsem.h +++ b/arch/ia64/include/asm/rwsem.h | |||
| @@ -25,20 +25,8 @@ | |||
| 25 | #error "Please don't include <asm/rwsem.h> directly, use <linux/rwsem.h> instead." | 25 | #error "Please don't include <asm/rwsem.h> directly, use <linux/rwsem.h> instead." |
| 26 | #endif | 26 | #endif |
| 27 | 27 | ||
| 28 | #include <linux/list.h> | ||
| 29 | #include <linux/spinlock.h> | ||
| 30 | |||
| 31 | #include <asm/intrinsics.h> | 28 | #include <asm/intrinsics.h> |
| 32 | 29 | ||
| 33 | /* | ||
| 34 | * the semaphore definition | ||
| 35 | */ | ||
| 36 | struct rw_semaphore { | ||
| 37 | signed long count; | ||
| 38 | spinlock_t wait_lock; | ||
| 39 | struct list_head wait_list; | ||
| 40 | }; | ||
| 41 | |||
| 42 | #define RWSEM_UNLOCKED_VALUE __IA64_UL_CONST(0x0000000000000000) | 30 | #define RWSEM_UNLOCKED_VALUE __IA64_UL_CONST(0x0000000000000000) |
| 43 | #define RWSEM_ACTIVE_BIAS (1L) | ||
