diff options
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/rwsem.h | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h index 03f3b05e8ec1..3e108f154cb6 100644 --- a/include/linux/rwsem.h +++ b/include/linux/rwsem.h | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | 16 | ||
| 17 | #include <linux/atomic.h> | 17 | #include <linux/atomic.h> |
| 18 | 18 | ||
| 19 | struct optimistic_spin_queue; | ||
| 19 | struct rw_semaphore; | 20 | struct rw_semaphore; |
| 20 | 21 | ||
| 21 | #ifdef CONFIG_RWSEM_GENERIC_SPINLOCK | 22 | #ifdef CONFIG_RWSEM_GENERIC_SPINLOCK |
| @@ -23,9 +24,17 @@ struct rw_semaphore; | |||
| 23 | #else | 24 | #else |
| 24 | /* All arch specific implementations share the same struct */ | 25 | /* All arch specific implementations share the same struct */ |
| 25 | struct rw_semaphore { | 26 | struct rw_semaphore { |
| 26 | long count; | 27 | long count; |
| 27 | raw_spinlock_t wait_lock; | 28 | raw_spinlock_t wait_lock; |
| 28 | struct list_head wait_list; | 29 | struct list_head wait_list; |
| 30 | #ifdef CONFIG_SMP | ||
| 31 | /* | ||
| 32 | * Write owner. Used as a speculative check to see | ||
| 33 | * if the owner is running on the cpu. | ||
| 34 | */ | ||
| 35 | struct task_struct *owner; | ||
| 36 | struct optimistic_spin_queue *osq; /* spinner MCS lock */ | ||
| 37 | #endif | ||
| 29 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 38 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
| 30 | struct lockdep_map dep_map; | 39 | struct lockdep_map dep_map; |
| 31 | #endif | 40 | #endif |
| @@ -55,11 +64,21 @@ static inline int rwsem_is_locked(struct rw_semaphore *sem) | |||
| 55 | # define __RWSEM_DEP_MAP_INIT(lockname) | 64 | # define __RWSEM_DEP_MAP_INIT(lockname) |
| 56 | #endif | 65 | #endif |
| 57 | 66 | ||
| 67 | #ifdef CONFIG_SMP | ||
| 68 | #define __RWSEM_INITIALIZER(name) \ | ||
| 69 | { RWSEM_UNLOCKED_VALUE, \ | ||
| 70 | __RAW_SPIN_LOCK_UNLOCKED(name.wait_lock), \ | ||
| 71 | LIST_HEAD_INIT((name).wait_list), \ | ||
| 72 | NULL, /* owner */ \ | ||
| 73 | NULL /* mcs lock */ \ | ||
| 74 | __RWSEM_DEP_MAP_INIT(name) } | ||
| 75 | #else | ||
| 58 | #define __RWSEM_INITIALIZER(name) \ | 76 | #define __RWSEM_INITIALIZER(name) \ |
| 59 | { RWSEM_UNLOCKED_VALUE, \ | 77 | { RWSEM_UNLOCKED_VALUE, \ |
| 60 | __RAW_SPIN_LOCK_UNLOCKED(name.wait_lock), \ | 78 | __RAW_SPIN_LOCK_UNLOCKED(name.wait_lock), \ |
| 61 | LIST_HEAD_INIT((name).wait_list) \ | 79 | LIST_HEAD_INIT((name).wait_list) \ |
| 62 | __RWSEM_DEP_MAP_INIT(name) } | 80 | __RWSEM_DEP_MAP_INIT(name) } |
| 81 | #endif | ||
| 63 | 82 | ||
| 64 | #define DECLARE_RWSEM(name) \ | 83 | #define DECLARE_RWSEM(name) \ |
| 65 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | 84 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) |
