Blame view

kernel/spinlock.c 9.5 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
  /*
   * Copyright (2004) Linus Torvalds
   *
   * Author: Zwane Mwaikambo <zwane@fsmlabs.com>
   *
fb1c8f93d   Ingo Molnar   [PATCH] spinlock ...
6
7
8
9
   * Copyright (2004, 2005) Ingo Molnar
   *
   * This file contains the spinlock/rwlock implementations for the
   * SMP and the DEBUG_SPINLOCK cases. (UP-nondebug inlines them)
0cb91a229   Andi Kleen   [PATCH] i386: Acc...
10
11
12
13
14
   *
   * Note that some architectures have special knowledge about the
   * stack frames of these functions in their profile_pc. If you
   * change anything significant here that could change the stack
   * frame contact the architecture maintainers.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
15
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
16
17
18
19
  #include <linux/linkage.h>
  #include <linux/preempt.h>
  #include <linux/spinlock.h>
  #include <linux/interrupt.h>
8a25d5deb   Ingo Molnar   [PATCH] lockdep: ...
20
  #include <linux/debug_locks.h>
9984de1a5   Paul Gortmaker   kernel: Map most ...
21
  #include <linux/export.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
22

8e13c7b77   Thomas Gleixner   locking: Reduce i...
23
24
25
26
27
28
29
30
31
32
33
  /*
   * If lockdep is enabled then we use the non-preemption spin-ops
   * even on CONFIG_PREEMPT, because lockdep assumes that interrupts are
   * not re-enabled during lock-acquire (which the preempt-spin-ops do):
   */
  #if !defined(CONFIG_GENERIC_LOCKBREAK) || defined(CONFIG_DEBUG_LOCK_ALLOC)
  /*
   * The __lock_function inlines are taken from
   * include/linux/spinlock_api_smp.h
   */
  #else
c2f21ce2e   Thomas Gleixner   locking: Implemen...
34
35
  #define raw_read_can_lock(l)	read_can_lock(l)
  #define raw_write_can_lock(l)	write_can_lock(l)
8e13c7b77   Thomas Gleixner   locking: Reduce i...
36
37
38
39
40
41
42
43
44
45
  /*
   * We build the __lock_function inlines here. They are too large for
   * inlining all over the place, but here is only one user per function
   * which embedds them into the calling _lock_function below.
   *
   * This could be a long-held lock. We both prepare to spin for a long
   * time (making _this_ CPU preemptable if possible), and we also signal
   * towards that other CPU that it should break the lock ASAP.
   */
  #define BUILD_LOCK_OPS(op, locktype)					\
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
46
  void __lockfunc __raw_##op##_lock(locktype##_t *lock)			\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
47
48
49
  {									\
  	for (;;) {							\
  		preempt_disable();					\
9828ea9d7   Thomas Gleixner   locking: Further ...
50
  		if (likely(do_raw_##op##_trylock(lock)))		\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
51
52
53
54
55
  			break;						\
  		preempt_enable();					\
  									\
  		if (!(lock)->break_lock)				\
  			(lock)->break_lock = 1;				\
c2f21ce2e   Thomas Gleixner   locking: Implemen...
56
  		while (!raw_##op##_can_lock(lock) && (lock)->break_lock)\
0199c4e68   Thomas Gleixner   locking: Convert ...
57
  			arch_##op##_relax(&lock->raw_lock);		\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
58
59
60
61
  	}								\
  	(lock)->break_lock = 0;						\
  }									\
  									\
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
62
  unsigned long __lockfunc __raw_##op##_lock_irqsave(locktype##_t *lock)	\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
63
64
65
66
67
68
  {									\
  	unsigned long flags;						\
  									\
  	for (;;) {							\
  		preempt_disable();					\
  		local_irq_save(flags);					\
9828ea9d7   Thomas Gleixner   locking: Further ...
69
  		if (likely(do_raw_##op##_trylock(lock)))		\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
70
71
72
73
74
75
  			break;						\
  		local_irq_restore(flags);				\
  		preempt_enable();					\
  									\
  		if (!(lock)->break_lock)				\
  			(lock)->break_lock = 1;				\
c2f21ce2e   Thomas Gleixner   locking: Implemen...
76
  		while (!raw_##op##_can_lock(lock) && (lock)->break_lock)\
0199c4e68   Thomas Gleixner   locking: Convert ...
77
  			arch_##op##_relax(&lock->raw_lock);		\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
78
79
80
81
82
  	}								\
  	(lock)->break_lock = 0;						\
  	return flags;							\
  }									\
  									\
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
83
  void __lockfunc __raw_##op##_lock_irq(locktype##_t *lock)		\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
84
  {									\
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
85
  	_raw_##op##_lock_irqsave(lock);					\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
86
87
  }									\
  									\
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
88
  void __lockfunc __raw_##op##_lock_bh(locktype##_t *lock)		\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
89
90
91
92
93
94
95
96
  {									\
  	unsigned long flags;						\
  									\
  	/*							*/	\
  	/* Careful: we must exclude softirqs too, hence the	*/	\
  	/* irq-disabling. We use the generic preemption-aware	*/	\
  	/* function:						*/	\
  	/**/								\
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
97
  	flags = _raw_##op##_lock_irqsave(lock);				\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
98
99
100
101
102
103
104
105
106
107
108
109
110
  	local_bh_disable();						\
  	local_irq_restore(flags);					\
  }									\
  
  /*
   * Build preemption-friendly versions of the following
   * lock-spinning functions:
   *
   *         __[spin|read|write]_lock()
   *         __[spin|read|write]_lock_irq()
   *         __[spin|read|write]_lock_irqsave()
   *         __[spin|read|write]_lock_bh()
   */
c2f21ce2e   Thomas Gleixner   locking: Implemen...
111
  BUILD_LOCK_OPS(spin, raw_spinlock);
8e13c7b77   Thomas Gleixner   locking: Reduce i...
112
113
114
115
  BUILD_LOCK_OPS(read, rwlock);
  BUILD_LOCK_OPS(write, rwlock);
  
  #endif
6beb00092   Thomas Gleixner   locking: Make inl...
116
  #ifndef CONFIG_INLINE_SPIN_TRYLOCK
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
117
  int __lockfunc _raw_spin_trylock(raw_spinlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
118
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
119
  	return __raw_spin_trylock(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
120
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
121
  EXPORT_SYMBOL(_raw_spin_trylock);
892a7c67c   Heiko Carstens   locking: Allow ar...
122
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
123

b7b40ade5   Thomas Gleixner   locking: Reorder ...
124
  #ifndef CONFIG_INLINE_SPIN_TRYLOCK_BH
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
125
  int __lockfunc _raw_spin_trylock_bh(raw_spinlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
126
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
127
  	return __raw_spin_trylock_bh(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
128
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
129
  EXPORT_SYMBOL(_raw_spin_trylock_bh);
892a7c67c   Heiko Carstens   locking: Allow ar...
130
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
131

b7b40ade5   Thomas Gleixner   locking: Reorder ...
132
  #ifndef CONFIG_INLINE_SPIN_LOCK
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
133
  void __lockfunc _raw_spin_lock(raw_spinlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
134
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
135
  	__raw_spin_lock(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
136
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
137
  EXPORT_SYMBOL(_raw_spin_lock);
892a7c67c   Heiko Carstens   locking: Allow ar...
138
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
139

6beb00092   Thomas Gleixner   locking: Make inl...
140
  #ifndef CONFIG_INLINE_SPIN_LOCK_IRQSAVE
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
141
  unsigned long __lockfunc _raw_spin_lock_irqsave(raw_spinlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
142
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
143
  	return __raw_spin_lock_irqsave(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
144
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
145
  EXPORT_SYMBOL(_raw_spin_lock_irqsave);
892a7c67c   Heiko Carstens   locking: Allow ar...
146
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
147

6beb00092   Thomas Gleixner   locking: Make inl...
148
  #ifndef CONFIG_INLINE_SPIN_LOCK_IRQ
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
149
  void __lockfunc _raw_spin_lock_irq(raw_spinlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
150
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
151
  	__raw_spin_lock_irq(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
152
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
153
  EXPORT_SYMBOL(_raw_spin_lock_irq);
892a7c67c   Heiko Carstens   locking: Allow ar...
154
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
155

6beb00092   Thomas Gleixner   locking: Make inl...
156
  #ifndef CONFIG_INLINE_SPIN_LOCK_BH
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
157
  void __lockfunc _raw_spin_lock_bh(raw_spinlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
158
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
159
  	__raw_spin_lock_bh(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
160
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
161
  EXPORT_SYMBOL(_raw_spin_lock_bh);
892a7c67c   Heiko Carstens   locking: Allow ar...
162
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
163

b7b40ade5   Thomas Gleixner   locking: Reorder ...
164
  #ifndef CONFIG_INLINE_SPIN_UNLOCK
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
165
  void __lockfunc _raw_spin_unlock(raw_spinlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
166
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
167
  	__raw_spin_unlock(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
168
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
169
  EXPORT_SYMBOL(_raw_spin_unlock);
892a7c67c   Heiko Carstens   locking: Allow ar...
170
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
171

b7b40ade5   Thomas Gleixner   locking: Reorder ...
172
  #ifndef CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
173
  void __lockfunc _raw_spin_unlock_irqrestore(raw_spinlock_t *lock, unsigned long flags)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
174
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
175
  	__raw_spin_unlock_irqrestore(lock, flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
176
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
177
  EXPORT_SYMBOL(_raw_spin_unlock_irqrestore);
892a7c67c   Heiko Carstens   locking: Allow ar...
178
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
179

b7b40ade5   Thomas Gleixner   locking: Reorder ...
180
  #ifndef CONFIG_INLINE_SPIN_UNLOCK_IRQ
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
181
  void __lockfunc _raw_spin_unlock_irq(raw_spinlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
182
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
183
  	__raw_spin_unlock_irq(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
184
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
185
  EXPORT_SYMBOL(_raw_spin_unlock_irq);
892a7c67c   Heiko Carstens   locking: Allow ar...
186
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
187

b7b40ade5   Thomas Gleixner   locking: Reorder ...
188
  #ifndef CONFIG_INLINE_SPIN_UNLOCK_BH
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
189
  void __lockfunc _raw_spin_unlock_bh(raw_spinlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
190
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
191
  	__raw_spin_unlock_bh(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
192
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
193
  EXPORT_SYMBOL(_raw_spin_unlock_bh);
892a7c67c   Heiko Carstens   locking: Allow ar...
194
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
195

b7b40ade5   Thomas Gleixner   locking: Reorder ...
196
  #ifndef CONFIG_INLINE_READ_TRYLOCK
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
197
  int __lockfunc _raw_read_trylock(rwlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
198
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
199
  	return __raw_read_trylock(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
200
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
201
  EXPORT_SYMBOL(_raw_read_trylock);
892a7c67c   Heiko Carstens   locking: Allow ar...
202
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
203

b7b40ade5   Thomas Gleixner   locking: Reorder ...
204
  #ifndef CONFIG_INLINE_READ_LOCK
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
205
  void __lockfunc _raw_read_lock(rwlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
206
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
207
  	__raw_read_lock(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
208
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
209
  EXPORT_SYMBOL(_raw_read_lock);
892a7c67c   Heiko Carstens   locking: Allow ar...
210
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
211

b7b40ade5   Thomas Gleixner   locking: Reorder ...
212
  #ifndef CONFIG_INLINE_READ_LOCK_IRQSAVE
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
213
  unsigned long __lockfunc _raw_read_lock_irqsave(rwlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
214
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
215
  	return __raw_read_lock_irqsave(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
216
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
217
  EXPORT_SYMBOL(_raw_read_lock_irqsave);
892a7c67c   Heiko Carstens   locking: Allow ar...
218
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
219

b7b40ade5   Thomas Gleixner   locking: Reorder ...
220
  #ifndef CONFIG_INLINE_READ_LOCK_IRQ
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
221
  void __lockfunc _raw_read_lock_irq(rwlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
222
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
223
  	__raw_read_lock_irq(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
224
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
225
  EXPORT_SYMBOL(_raw_read_lock_irq);
892a7c67c   Heiko Carstens   locking: Allow ar...
226
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
227

b7b40ade5   Thomas Gleixner   locking: Reorder ...
228
  #ifndef CONFIG_INLINE_READ_LOCK_BH
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
229
  void __lockfunc _raw_read_lock_bh(rwlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
230
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
231
  	__raw_read_lock_bh(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
232
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
233
  EXPORT_SYMBOL(_raw_read_lock_bh);
892a7c67c   Heiko Carstens   locking: Allow ar...
234
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
235

6beb00092   Thomas Gleixner   locking: Make inl...
236
  #ifndef CONFIG_INLINE_READ_UNLOCK
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
237
  void __lockfunc _raw_read_unlock(rwlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
238
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
239
  	__raw_read_unlock(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
240
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
241
  EXPORT_SYMBOL(_raw_read_unlock);
892a7c67c   Heiko Carstens   locking: Allow ar...
242
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
243

6beb00092   Thomas Gleixner   locking: Make inl...
244
  #ifndef CONFIG_INLINE_READ_UNLOCK_IRQRESTORE
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
245
  void __lockfunc _raw_read_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
246
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
247
  	__raw_read_unlock_irqrestore(lock, flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
248
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
249
  EXPORT_SYMBOL(_raw_read_unlock_irqrestore);
892a7c67c   Heiko Carstens   locking: Allow ar...
250
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
251

6beb00092   Thomas Gleixner   locking: Make inl...
252
  #ifndef CONFIG_INLINE_READ_UNLOCK_IRQ
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
253
  void __lockfunc _raw_read_unlock_irq(rwlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
254
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
255
  	__raw_read_unlock_irq(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
256
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
257
  EXPORT_SYMBOL(_raw_read_unlock_irq);
892a7c67c   Heiko Carstens   locking: Allow ar...
258
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
259

6beb00092   Thomas Gleixner   locking: Make inl...
260
  #ifndef CONFIG_INLINE_READ_UNLOCK_BH
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
261
  void __lockfunc _raw_read_unlock_bh(rwlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
262
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
263
  	__raw_read_unlock_bh(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
264
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
265
  EXPORT_SYMBOL(_raw_read_unlock_bh);
892a7c67c   Heiko Carstens   locking: Allow ar...
266
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
267

b7b40ade5   Thomas Gleixner   locking: Reorder ...
268
  #ifndef CONFIG_INLINE_WRITE_TRYLOCK
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
269
  int __lockfunc _raw_write_trylock(rwlock_t *lock)
b7b40ade5   Thomas Gleixner   locking: Reorder ...
270
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
271
  	return __raw_write_trylock(lock);
b7b40ade5   Thomas Gleixner   locking: Reorder ...
272
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
273
  EXPORT_SYMBOL(_raw_write_trylock);
b7b40ade5   Thomas Gleixner   locking: Reorder ...
274
275
276
  #endif
  
  #ifndef CONFIG_INLINE_WRITE_LOCK
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
277
  void __lockfunc _raw_write_lock(rwlock_t *lock)
b7b40ade5   Thomas Gleixner   locking: Reorder ...
278
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
279
  	__raw_write_lock(lock);
b7b40ade5   Thomas Gleixner   locking: Reorder ...
280
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
281
  EXPORT_SYMBOL(_raw_write_lock);
b7b40ade5   Thomas Gleixner   locking: Reorder ...
282
283
284
  #endif
  
  #ifndef CONFIG_INLINE_WRITE_LOCK_IRQSAVE
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
285
  unsigned long __lockfunc _raw_write_lock_irqsave(rwlock_t *lock)
b7b40ade5   Thomas Gleixner   locking: Reorder ...
286
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
287
  	return __raw_write_lock_irqsave(lock);
b7b40ade5   Thomas Gleixner   locking: Reorder ...
288
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
289
  EXPORT_SYMBOL(_raw_write_lock_irqsave);
b7b40ade5   Thomas Gleixner   locking: Reorder ...
290
291
292
  #endif
  
  #ifndef CONFIG_INLINE_WRITE_LOCK_IRQ
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
293
  void __lockfunc _raw_write_lock_irq(rwlock_t *lock)
b7b40ade5   Thomas Gleixner   locking: Reorder ...
294
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
295
  	__raw_write_lock_irq(lock);
b7b40ade5   Thomas Gleixner   locking: Reorder ...
296
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
297
  EXPORT_SYMBOL(_raw_write_lock_irq);
b7b40ade5   Thomas Gleixner   locking: Reorder ...
298
299
300
  #endif
  
  #ifndef CONFIG_INLINE_WRITE_LOCK_BH
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
301
  void __lockfunc _raw_write_lock_bh(rwlock_t *lock)
b7b40ade5   Thomas Gleixner   locking: Reorder ...
302
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
303
  	__raw_write_lock_bh(lock);
b7b40ade5   Thomas Gleixner   locking: Reorder ...
304
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
305
  EXPORT_SYMBOL(_raw_write_lock_bh);
b7b40ade5   Thomas Gleixner   locking: Reorder ...
306
307
308
  #endif
  
  #ifndef CONFIG_INLINE_WRITE_UNLOCK
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
309
  void __lockfunc _raw_write_unlock(rwlock_t *lock)
b7b40ade5   Thomas Gleixner   locking: Reorder ...
310
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
311
  	__raw_write_unlock(lock);
b7b40ade5   Thomas Gleixner   locking: Reorder ...
312
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
313
  EXPORT_SYMBOL(_raw_write_unlock);
b7b40ade5   Thomas Gleixner   locking: Reorder ...
314
  #endif
6beb00092   Thomas Gleixner   locking: Make inl...
315
  #ifndef CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
316
  void __lockfunc _raw_write_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
317
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
318
  	__raw_write_unlock_irqrestore(lock, flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
319
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
320
  EXPORT_SYMBOL(_raw_write_unlock_irqrestore);
892a7c67c   Heiko Carstens   locking: Allow ar...
321
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
322

6beb00092   Thomas Gleixner   locking: Make inl...
323
  #ifndef CONFIG_INLINE_WRITE_UNLOCK_IRQ
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
324
  void __lockfunc _raw_write_unlock_irq(rwlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
325
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
326
  	__raw_write_unlock_irq(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
327
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
328
  EXPORT_SYMBOL(_raw_write_unlock_irq);
892a7c67c   Heiko Carstens   locking: Allow ar...
329
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
330

6beb00092   Thomas Gleixner   locking: Make inl...
331
  #ifndef CONFIG_INLINE_WRITE_UNLOCK_BH
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
332
  void __lockfunc _raw_write_unlock_bh(rwlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
333
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
334
  	__raw_write_unlock_bh(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
335
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
336
  EXPORT_SYMBOL(_raw_write_unlock_bh);
892a7c67c   Heiko Carstens   locking: Allow ar...
337
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
338

b7b40ade5   Thomas Gleixner   locking: Reorder ...
339
  #ifdef CONFIG_DEBUG_LOCK_ALLOC
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
340
  void __lockfunc _raw_spin_lock_nested(raw_spinlock_t *lock, int subclass)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
341
  {
b7b40ade5   Thomas Gleixner   locking: Reorder ...
342
343
  	preempt_disable();
  	spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_);
9828ea9d7   Thomas Gleixner   locking: Further ...
344
  	LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
345
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
346
  EXPORT_SYMBOL(_raw_spin_lock_nested);
b7b40ade5   Thomas Gleixner   locking: Reorder ...
347

9c1721aa4   Thomas Gleixner   locking: Cleanup ...
348
  unsigned long __lockfunc _raw_spin_lock_irqsave_nested(raw_spinlock_t *lock,
b7b40ade5   Thomas Gleixner   locking: Reorder ...
349
350
351
352
353
354
355
  						   int subclass)
  {
  	unsigned long flags;
  
  	local_irq_save(flags);
  	preempt_disable();
  	spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_);
9828ea9d7   Thomas Gleixner   locking: Further ...
356
357
  	LOCK_CONTENDED_FLAGS(lock, do_raw_spin_trylock, do_raw_spin_lock,
  				do_raw_spin_lock_flags, &flags);
b7b40ade5   Thomas Gleixner   locking: Reorder ...
358
359
  	return flags;
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
360
  EXPORT_SYMBOL(_raw_spin_lock_irqsave_nested);
b7b40ade5   Thomas Gleixner   locking: Reorder ...
361

9c1721aa4   Thomas Gleixner   locking: Cleanup ...
362
  void __lockfunc _raw_spin_lock_nest_lock(raw_spinlock_t *lock,
b7b40ade5   Thomas Gleixner   locking: Reorder ...
363
364
365
366
  				     struct lockdep_map *nest_lock)
  {
  	preempt_disable();
  	spin_acquire_nest(&lock->dep_map, 0, 0, nest_lock, _RET_IP_);
9828ea9d7   Thomas Gleixner   locking: Further ...
367
  	LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock);
b7b40ade5   Thomas Gleixner   locking: Reorder ...
368
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
369
  EXPORT_SYMBOL(_raw_spin_lock_nest_lock);
b7b40ade5   Thomas Gleixner   locking: Reorder ...
370

892a7c67c   Heiko Carstens   locking: Allow ar...
371
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
372

0764d23cf   Steven Rostedt   ftrace: lockdep n...
373
  notrace int in_lock_functions(unsigned long addr)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
374
375
376
377
378
379
380
381
  {
  	/* Linker adds these: start and end of __lockfunc functions */
  	extern char __lock_text_start[], __lock_text_end[];
  
  	return addr >= (unsigned long)__lock_text_start
  	&& addr < (unsigned long)__lock_text_end;
  }
  EXPORT_SYMBOL(in_lock_functions);