aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/spinlock.c
diff options
context:
space:
mode:
authorHeiko Carstens <heiko.carstens@de.ibm.com>2009-08-31 08:43:36 -0400
committerIngo Molnar <mingo@elte.hu>2009-08-31 12:08:50 -0400
commit69d0ee7377eef808e34ba5542b554ec97244b871 (patch)
treef46c756b897cf51497fda2ad22f9f12a3512e23b /kernel/spinlock.c
parent0ee000e5e8fa2e5c760250be0d78d5906e3eb94b (diff)
locking: Move spinlock function bodies to header file
Move spinlock function bodies to header file by creating a static inline version of each variant. Use the inline version on the out-of-line code. This shouldn't make any difference besides that the spinlock code can now be used to generate inlined spinlock code. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Horst Hartmann <horsth@linux.vnet.ibm.com> Cc: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: David Miller <davem@davemloft.net> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Roman Zippel <zippel@linux-m68k.org> Cc: <linux-arch@vger.kernel.org> LKML-Reference: <20090831124417.859022429@de.ibm.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/spinlock.c')
-rw-r--r--kernel/spinlock.c174
1 files changed, 28 insertions, 146 deletions
diff --git a/kernel/spinlock.c b/kernel/spinlock.c
index 7932653c4ebd..2c000f5c070b 100644
--- a/kernel/spinlock.c
+++ b/kernel/spinlock.c
@@ -23,40 +23,19 @@
23 23
24int __lockfunc _spin_trylock(spinlock_t *lock) 24int __lockfunc _spin_trylock(spinlock_t *lock)
25{ 25{
26 preempt_disable(); 26 return __spin_trylock(lock);
27 if (_raw_spin_trylock(lock)) {
28 spin_acquire(&lock->dep_map, 0, 1, _RET_IP_);
29 return 1;
30 }
31
32 preempt_enable();
33 return 0;
34} 27}
35EXPORT_SYMBOL(_spin_trylock); 28EXPORT_SYMBOL(_spin_trylock);
36 29
37int __lockfunc _read_trylock(rwlock_t *lock) 30int __lockfunc _read_trylock(rwlock_t *lock)
38{ 31{
39 preempt_disable(); 32 return __read_trylock(lock);
40 if (_raw_read_trylock(lock)) {
41 rwlock_acquire_read(&lock->dep_map, 0, 1, _RET_IP_);
42 return 1;
43 }
44
45 preempt_enable();
46 return 0;
47} 33}
48EXPORT_SYMBOL(_read_trylock); 34EXPORT_SYMBOL(_read_trylock);
49 35
50int __lockfunc _write_trylock(rwlock_t *lock) 36int __lockfunc _write_trylock(rwlock_t *lock)
51{ 37{
52 preempt_disable(); 38 return __write_trylock(lock);
53 if (_raw_write_trylock(lock)) {
54 rwlock_acquire(&lock->dep_map, 0, 1, _RET_IP_);
55 return 1;
56 }
57
58 preempt_enable();
59 return 0;
60} 39}
61EXPORT_SYMBOL(_write_trylock); 40EXPORT_SYMBOL(_write_trylock);
62 41
@@ -69,129 +48,74 @@ EXPORT_SYMBOL(_write_trylock);
69 48
70void __lockfunc _read_lock(rwlock_t *lock) 49void __lockfunc _read_lock(rwlock_t *lock)
71{ 50{
72 preempt_disable(); 51 __read_lock(lock);
73 rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_);
74 LOCK_CONTENDED(lock, _raw_read_trylock, _raw_read_lock);
75} 52}
76EXPORT_SYMBOL(_read_lock); 53EXPORT_SYMBOL(_read_lock);
77 54
78unsigned long __lockfunc _spin_lock_irqsave(spinlock_t *lock) 55unsigned long __lockfunc _spin_lock_irqsave(spinlock_t *lock)
79{ 56{
80 unsigned long flags; 57 return __spin_lock_irqsave(lock);
81
82 local_irq_save(flags);
83 preempt_disable();
84 spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
85 /*
86 * On lockdep we dont want the hand-coded irq-enable of
87 * _raw_spin_lock_flags() code, because lockdep assumes
88 * that interrupts are not re-enabled during lock-acquire:
89 */
90#ifdef CONFIG_LOCKDEP
91 LOCK_CONTENDED(lock, _raw_spin_trylock, _raw_spin_lock);
92#else
93 _raw_spin_lock_flags(lock, &flags);
94#endif
95 return flags;
96} 58}
97EXPORT_SYMBOL(_spin_lock_irqsave); 59EXPORT_SYMBOL(_spin_lock_irqsave);
98 60
99void __lockfunc _spin_lock_irq(spinlock_t *lock) 61void __lockfunc _spin_lock_irq(spinlock_t *lock)
100{ 62{
101 local_irq_disable(); 63 __spin_lock_irq(lock);
102 preempt_disable();
103 spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
104 LOCK_CONTENDED(lock, _raw_spin_trylock, _raw_spin_lock);
105} 64}
106EXPORT_SYMBOL(_spin_lock_irq); 65EXPORT_SYMBOL(_spin_lock_irq);
107 66
108void __lockfunc _spin_lock_bh(spinlock_t *lock) 67void __lockfunc _spin_lock_bh(spinlock_t *lock)
109{ 68{
110 local_bh_disable(); 69 __spin_lock_bh(lock);
111 preempt_disable();
112 spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
113 LOCK_CONTENDED(lock, _raw_spin_trylock, _raw_spin_lock);
114} 70}
115EXPORT_SYMBOL(_spin_lock_bh); 71EXPORT_SYMBOL(_spin_lock_bh);
116 72
117unsigned long __lockfunc _read_lock_irqsave(rwlock_t *lock) 73unsigned long __lockfunc _read_lock_irqsave(rwlock_t *lock)
118{ 74{
119 unsigned long flags; 75 return __read_lock_irqsave(lock);
120
121 local_irq_save(flags);
122 preempt_disable();
123 rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_);
124 LOCK_CONTENDED_FLAGS(lock, _raw_read_trylock, _raw_read_lock,
125 _raw_read_lock_flags, &flags);
126 return flags;
127} 76}
128EXPORT_SYMBOL(_read_lock_irqsave); 77EXPORT_SYMBOL(_read_lock_irqsave);
129 78
130void __lockfunc _read_lock_irq(rwlock_t *lock) 79void __lockfunc _read_lock_irq(rwlock_t *lock)
131{ 80{
132 local_irq_disable(); 81 __read_lock_irq(lock);
133 preempt_disable();
134 rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_);
135 LOCK_CONTENDED(lock, _raw_read_trylock, _raw_read_lock);
136} 82}
137EXPORT_SYMBOL(_read_lock_irq); 83EXPORT_SYMBOL(_read_lock_irq);
138 84
139void __lockfunc _read_lock_bh(rwlock_t *lock) 85void __lockfunc _read_lock_bh(rwlock_t *lock)
140{ 86{
141 local_bh_disable(); 87 __read_lock_bh(lock);
142 preempt_disable();
143 rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_);
144 LOCK_CONTENDED(lock, _raw_read_trylock, _raw_read_lock);
145} 88}
146EXPORT_SYMBOL(_read_lock_bh); 89EXPORT_SYMBOL(_read_lock_bh);
147 90
148unsigned long __lockfunc _write_lock_irqsave(rwlock_t *lock) 91unsigned long __lockfunc _write_lock_irqsave(rwlock_t *lock)
149{ 92{
150 unsigned long flags; 93 return __write_lock_irqsave(lock);
151
152 local_irq_save(flags);
153 preempt_disable();
154 rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_);
155 LOCK_CONTENDED_FLAGS(lock, _raw_write_trylock, _raw_write_lock,
156 _raw_write_lock_flags, &flags);
157 return flags;
158} 94}
159EXPORT_SYMBOL(_write_lock_irqsave); 95EXPORT_SYMBOL(_write_lock_irqsave);
160 96
161void __lockfunc _write_lock_irq(rwlock_t *lock) 97void __lockfunc _write_lock_irq(rwlock_t *lock)
162{ 98{
163 local_irq_disable(); 99 __write_lock_irq(lock);
164 preempt_disable();
165 rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_);
166 LOCK_CONTENDED(lock, _raw_write_trylock, _raw_write_lock);
167} 100}
168EXPORT_SYMBOL(_write_lock_irq); 101EXPORT_SYMBOL(_write_lock_irq);
169 102
170void __lockfunc _write_lock_bh(rwlock_t *lock) 103void __lockfunc _write_lock_bh(rwlock_t *lock)
171{ 104{
172 local_bh_disable(); 105 __write_lock_bh(lock);
173 preempt_disable();
174 rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_);
175 LOCK_CONTENDED(lock, _raw_write_trylock, _raw_write_lock);
176} 106}
177EXPORT_SYMBOL(_write_lock_bh); 107EXPORT_SYMBOL(_write_lock_bh);
178 108
179void __lockfunc _spin_lock(spinlock_t *lock) 109void __lockfunc _spin_lock(spinlock_t *lock)
180{ 110{
181 preempt_disable(); 111 __spin_lock(lock);
182 spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
183 LOCK_CONTENDED(lock, _raw_spin_trylock, _raw_spin_lock);
184} 112}
185
186EXPORT_SYMBOL(_spin_lock); 113EXPORT_SYMBOL(_spin_lock);
187 114
188void __lockfunc _write_lock(rwlock_t *lock) 115void __lockfunc _write_lock(rwlock_t *lock)
189{ 116{
190 preempt_disable(); 117 __write_lock(lock);
191 rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_);
192 LOCK_CONTENDED(lock, _raw_write_trylock, _raw_write_lock);
193} 118}
194
195EXPORT_SYMBOL(_write_lock); 119EXPORT_SYMBOL(_write_lock);
196 120
197#else /* CONFIG_PREEMPT: */ 121#else /* CONFIG_PREEMPT: */
@@ -320,121 +244,79 @@ EXPORT_SYMBOL(_spin_lock_nest_lock);
320 244
321void __lockfunc _spin_unlock(spinlock_t *lock) 245void __lockfunc _spin_unlock(spinlock_t *lock)
322{ 246{
323 spin_release(&lock->dep_map, 1, _RET_IP_); 247 __spin_unlock(lock);
324 _raw_spin_unlock(lock);
325 preempt_enable();
326} 248}
327EXPORT_SYMBOL(_spin_unlock); 249EXPORT_SYMBOL(_spin_unlock);
328 250
329void __lockfunc _write_unlock(rwlock_t *lock) 251void __lockfunc _write_unlock(rwlock_t *lock)
330{ 252{
331 rwlock_release(&lock->dep_map, 1, _RET_IP_); 253 __write_unlock(lock);
332 _raw_write_unlock(lock);
333 preempt_enable();
334} 254}
335EXPORT_SYMBOL(_write_unlock); 255EXPORT_SYMBOL(_write_unlock);
336 256
337void __lockfunc _read_unlock(rwlock_t *lock) 257void __lockfunc _read_unlock(rwlock_t *lock)
338{ 258{
339 rwlock_release(&lock->dep_map, 1, _RET_IP_); 259 __read_unlock(lock);
340 _raw_read_unlock(lock);
341 preempt_enable();
342} 260}
343EXPORT_SYMBOL(_read_unlock); 261EXPORT_SYMBOL(_read_unlock);
344 262
345void __lockfunc _spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) 263void __lockfunc _spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags)
346{ 264{
347 spin_release(&lock->dep_map, 1, _RET_IP_); 265 __spin_unlock_irqrestore(lock, flags);
348 _raw_spin_unlock(lock);
349 local_irq_restore(flags);
350 preempt_enable();
351} 266}
352EXPORT_SYMBOL(_spin_unlock_irqrestore); 267EXPORT_SYMBOL(_spin_unlock_irqrestore);
353 268
354void __lockfunc _spin_unlock_irq(spinlock_t *lock) 269void __lockfunc _spin_unlock_irq(spinlock_t *lock)
355{ 270{
356 spin_release(&lock->dep_map, 1, _RET_IP_); 271 __spin_unlock_irq(lock);
357 _raw_spin_unlock(lock);
358 local_irq_enable();
359 preempt_enable();
360} 272}
361EXPORT_SYMBOL(_spin_unlock_irq); 273EXPORT_SYMBOL(_spin_unlock_irq);
362 274
363void __lockfunc _spin_unlock_bh(spinlock_t *lock) 275void __lockfunc _spin_unlock_bh(spinlock_t *lock)
364{ 276{
365 spin_release(&lock->dep_map, 1, _RET_IP_); 277 __spin_unlock_bh(lock);
366 _raw_spin_unlock(lock);
367 preempt_enable_no_resched();
368 local_bh_enable_ip((unsigned long)__builtin_return_address(0));
369} 278}
370EXPORT_SYMBOL(_spin_unlock_bh); 279EXPORT_SYMBOL(_spin_unlock_bh);
371 280
372void __lockfunc _read_unlock_irqrestore(rwlock_t *lock, unsigned long flags) 281void __lockfunc _read_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
373{ 282{
374 rwlock_release(&lock->dep_map, 1, _RET_IP_); 283 __read_unlock_irqrestore(lock, flags);
375 _raw_read_unlock(lock);
376 local_irq_restore(flags);
377 preempt_enable();
378} 284}
379EXPORT_SYMBOL(_read_unlock_irqrestore); 285EXPORT_SYMBOL(_read_unlock_irqrestore);
380 286
381void __lockfunc _read_unlock_irq(rwlock_t *lock) 287void __lockfunc _read_unlock_irq(rwlock_t *lock)
382{ 288{
383 rwlock_release(&lock->dep_map, 1, _RET_IP_); 289 __read_unlock_irq(lock);
384 _raw_read_unlock(lock);
385 local_irq_enable();
386 preempt_enable();
387} 290}
388EXPORT_SYMBOL(_read_unlock_irq); 291EXPORT_SYMBOL(_read_unlock_irq);
389 292
390void __lockfunc _read_unlock_bh(rwlock_t *lock) 293void __lockfunc _read_unlock_bh(rwlock_t *lock)
391{ 294{
392 rwlock_release(&lock->dep_map, 1, _RET_IP_); 295 __read_unlock_bh(lock);
393 _raw_read_unlock(lock);
394 preempt_enable_no_resched();
395 local_bh_enable_ip((unsigned long)__builtin_return_address(0));
396} 296}
397EXPORT_SYMBOL(_read_unlock_bh); 297EXPORT_SYMBOL(_read_unlock_bh);
398 298
399void __lockfunc _write_unlock_irqrestore(rwlock_t *lock, unsigned long flags) 299void __lockfunc _write_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
400{ 300{
401 rwlock_release(&lock->dep_map, 1, _RET_IP_); 301 __write_unlock_irqrestore(lock, flags);
402 _raw_write_unlock(lock);
403 local_irq_restore(flags);
404 preempt_enable();
405} 302}
406EXPORT_SYMBOL(_write_unlock_irqrestore); 303EXPORT_SYMBOL(_write_unlock_irqrestore);
407 304
408void __lockfunc _write_unlock_irq(rwlock_t *lock) 305void __lockfunc _write_unlock_irq(rwlock_t *lock)
409{ 306{
410 rwlock_release(&lock->dep_map, 1, _RET_IP_); 307 __write_unlock_irq(lock);
411 _raw_write_unlock(lock);
412 local_irq_enable();
413 preempt_enable();
414} 308}
415EXPORT_SYMBOL(_write_unlock_irq); 309EXPORT_SYMBOL(_write_unlock_irq);
416 310
417void __lockfunc _write_unlock_bh(rwlock_t *lock) 311void __lockfunc _write_unlock_bh(rwlock_t *lock)
418{ 312{
419 rwlock_release(&lock->dep_map, 1, _RET_IP_); 313 __write_unlock_bh(lock);
420 _raw_write_unlock(lock);
421 preempt_enable_no_resched();
422 local_bh_enable_ip((unsigned long)__builtin_return_address(0));
423} 314}
424EXPORT_SYMBOL(_write_unlock_bh); 315EXPORT_SYMBOL(_write_unlock_bh);
425 316
426int __lockfunc _spin_trylock_bh(spinlock_t *lock) 317int __lockfunc _spin_trylock_bh(spinlock_t *lock)
427{ 318{
428 local_bh_disable(); 319 return __spin_trylock_bh(lock);
429 preempt_disable();
430 if (_raw_spin_trylock(lock)) {
431 spin_acquire(&lock->dep_map, 0, 1, _RET_IP_);
432 return 1;
433 }
434
435 preempt_enable_no_resched();
436 local_bh_enable_ip((unsigned long)__builtin_return_address(0));
437 return 0;
438} 320}
439EXPORT_SYMBOL(_spin_trylock_bh); 321EXPORT_SYMBOL(_spin_trylock_bh);
440 322