diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2009-12-02 14:02:59 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2009-12-14 17:55:32 -0500 |
commit | c2f21ce2e31286a0a32f8da0a7856e9ca1122ef3 (patch) | |
tree | 6cc8d1fd37ffa6d02481353857b92734241f4dd0 /lib/spinlock_debug.c | |
parent | e5931943d02bf751b1ec849c0d2ade23d76a8d41 (diff) |
locking: Implement new raw_spinlock
Now that the raw_spin name space is freed up, we can implement
raw_spinlock and the related functions which are used to annotate the
locks which are not converted to sleeping spinlocks in preempt-rt.
A side effect is that only such locks can be used with the low level
lock fsunctions which circumvent lockdep.
For !rt spin_* functions are mapped to the raw_spin* implementations.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'lib/spinlock_debug.c')
-rw-r--r-- | lib/spinlock_debug.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/spinlock_debug.c b/lib/spinlock_debug.c index 0cea0bf6114e..e705848cc33c 100644 --- a/lib/spinlock_debug.c +++ b/lib/spinlock_debug.c | |||
@@ -13,8 +13,8 @@ | |||
13 | #include <linux/delay.h> | 13 | #include <linux/delay.h> |
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | 15 | ||
16 | void __spin_lock_init(spinlock_t *lock, const char *name, | 16 | void __raw_spin_lock_init(raw_spinlock_t *lock, const char *name, |
17 | struct lock_class_key *key) | 17 | struct lock_class_key *key) |
18 | { | 18 | { |
19 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 19 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
20 | /* | 20 | /* |
@@ -29,7 +29,7 @@ void __spin_lock_init(spinlock_t *lock, const char *name, | |||
29 | lock->owner_cpu = -1; | 29 | lock->owner_cpu = -1; |
30 | } | 30 | } |
31 | 31 | ||
32 | EXPORT_SYMBOL(__spin_lock_init); | 32 | EXPORT_SYMBOL(__raw_spin_lock_init); |
33 | 33 | ||
34 | void __rwlock_init(rwlock_t *lock, const char *name, | 34 | void __rwlock_init(rwlock_t *lock, const char *name, |
35 | struct lock_class_key *key) | 35 | struct lock_class_key *key) |
@@ -49,7 +49,7 @@ void __rwlock_init(rwlock_t *lock, const char *name, | |||
49 | 49 | ||
50 | EXPORT_SYMBOL(__rwlock_init); | 50 | EXPORT_SYMBOL(__rwlock_init); |
51 | 51 | ||
52 | static void spin_bug(spinlock_t *lock, const char *msg) | 52 | static void spin_bug(raw_spinlock_t *lock, const char *msg) |
53 | { | 53 | { |
54 | struct task_struct *owner = NULL; | 54 | struct task_struct *owner = NULL; |
55 | 55 | ||
@@ -73,7 +73,7 @@ static void spin_bug(spinlock_t *lock, const char *msg) | |||
73 | #define SPIN_BUG_ON(cond, lock, msg) if (unlikely(cond)) spin_bug(lock, msg) | 73 | #define SPIN_BUG_ON(cond, lock, msg) if (unlikely(cond)) spin_bug(lock, msg) |
74 | 74 | ||
75 | static inline void | 75 | static inline void |
76 | debug_spin_lock_before(spinlock_t *lock) | 76 | debug_spin_lock_before(raw_spinlock_t *lock) |
77 | { | 77 | { |
78 | SPIN_BUG_ON(lock->magic != SPINLOCK_MAGIC, lock, "bad magic"); | 78 | SPIN_BUG_ON(lock->magic != SPINLOCK_MAGIC, lock, "bad magic"); |
79 | SPIN_BUG_ON(lock->owner == current, lock, "recursion"); | 79 | SPIN_BUG_ON(lock->owner == current, lock, "recursion"); |
@@ -81,16 +81,16 @@ debug_spin_lock_before(spinlock_t *lock) | |||
81 | lock, "cpu recursion"); | 81 | lock, "cpu recursion"); |
82 | } | 82 | } |
83 | 83 | ||
84 | static inline void debug_spin_lock_after(spinlock_t *lock) | 84 | static inline void debug_spin_lock_after(raw_spinlock_t *lock) |
85 | { | 85 | { |
86 | lock->owner_cpu = raw_smp_processor_id(); | 86 | lock->owner_cpu = raw_smp_processor_id(); |
87 | lock->owner = current; | 87 | lock->owner = current; |
88 | } | 88 | } |
89 | 89 | ||
90 | static inline void debug_spin_unlock(spinlock_t *lock) | 90 | static inline void debug_spin_unlock(raw_spinlock_t *lock) |
91 | { | 91 | { |
92 | SPIN_BUG_ON(lock->magic != SPINLOCK_MAGIC, lock, "bad magic"); | 92 | SPIN_BUG_ON(lock->magic != SPINLOCK_MAGIC, lock, "bad magic"); |
93 | SPIN_BUG_ON(!spin_is_locked(lock), lock, "already unlocked"); | 93 | SPIN_BUG_ON(!raw_spin_is_locked(lock), lock, "already unlocked"); |
94 | SPIN_BUG_ON(lock->owner != current, lock, "wrong owner"); | 94 | SPIN_BUG_ON(lock->owner != current, lock, "wrong owner"); |
95 | SPIN_BUG_ON(lock->owner_cpu != raw_smp_processor_id(), | 95 | SPIN_BUG_ON(lock->owner_cpu != raw_smp_processor_id(), |
96 | lock, "wrong CPU"); | 96 | lock, "wrong CPU"); |
@@ -98,7 +98,7 @@ static inline void debug_spin_unlock(spinlock_t *lock) | |||
98 | lock->owner_cpu = -1; | 98 | lock->owner_cpu = -1; |
99 | } | 99 | } |
100 | 100 | ||
101 | static void __spin_lock_debug(spinlock_t *lock) | 101 | static void __spin_lock_debug(raw_spinlock_t *lock) |
102 | { | 102 | { |
103 | u64 i; | 103 | u64 i; |
104 | u64 loops = loops_per_jiffy * HZ; | 104 | u64 loops = loops_per_jiffy * HZ; |
@@ -125,7 +125,7 @@ static void __spin_lock_debug(spinlock_t *lock) | |||
125 | } | 125 | } |
126 | } | 126 | } |
127 | 127 | ||
128 | void _raw_spin_lock(spinlock_t *lock) | 128 | void _raw_spin_lock(raw_spinlock_t *lock) |
129 | { | 129 | { |
130 | debug_spin_lock_before(lock); | 130 | debug_spin_lock_before(lock); |
131 | if (unlikely(!arch_spin_trylock(&lock->raw_lock))) | 131 | if (unlikely(!arch_spin_trylock(&lock->raw_lock))) |
@@ -133,7 +133,7 @@ void _raw_spin_lock(spinlock_t *lock) | |||
133 | debug_spin_lock_after(lock); | 133 | debug_spin_lock_after(lock); |
134 | } | 134 | } |
135 | 135 | ||
136 | int _raw_spin_trylock(spinlock_t *lock) | 136 | int _raw_spin_trylock(raw_spinlock_t *lock) |
137 | { | 137 | { |
138 | int ret = arch_spin_trylock(&lock->raw_lock); | 138 | int ret = arch_spin_trylock(&lock->raw_lock); |
139 | 139 | ||
@@ -148,7 +148,7 @@ int _raw_spin_trylock(spinlock_t *lock) | |||
148 | return ret; | 148 | return ret; |
149 | } | 149 | } |
150 | 150 | ||
151 | void _raw_spin_unlock(spinlock_t *lock) | 151 | void _raw_spin_unlock(raw_spinlock_t *lock) |
152 | { | 152 | { |
153 | debug_spin_unlock(lock); | 153 | debug_spin_unlock(lock); |
154 | arch_spin_unlock(&lock->raw_lock); | 154 | arch_spin_unlock(&lock->raw_lock); |