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>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
21
  #include <linux/module.h>
8e13c7b77   Thomas Gleixner   locking: Reduce i...
22
23
24
25
26
27
28
29
30
31
32
  /*
   * 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...
33
34
  #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...
35
36
37
38
39
40
41
42
43
44
  /*
   * 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 ...
45
  void __lockfunc __raw_##op##_lock(locktype##_t *lock)			\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
46
47
48
  {									\
  	for (;;) {							\
  		preempt_disable();					\
9828ea9d7   Thomas Gleixner   locking: Further ...
49
  		if (likely(do_raw_##op##_trylock(lock)))		\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
50
51
52
53
54
  			break;						\
  		preempt_enable();					\
  									\
  		if (!(lock)->break_lock)				\
  			(lock)->break_lock = 1;				\
c2f21ce2e   Thomas Gleixner   locking: Implemen...
55
  		while (!raw_##op##_can_lock(lock) && (lock)->break_lock)\
0199c4e68   Thomas Gleixner   locking: Convert ...
56
  			arch_##op##_relax(&lock->raw_lock);		\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
57
58
59
60
  	}								\
  	(lock)->break_lock = 0;						\
  }									\
  									\
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
61
  unsigned long __lockfunc __raw_##op##_lock_irqsave(locktype##_t *lock)	\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
62
63
64
65
66
67
  {									\
  	unsigned long flags;						\
  									\
  	for (;;) {							\
  		preempt_disable();					\
  		local_irq_save(flags);					\
9828ea9d7   Thomas Gleixner   locking: Further ...
68
  		if (likely(do_raw_##op##_trylock(lock)))		\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
69
70
71
72
73
74
  			break;						\
  		local_irq_restore(flags);				\
  		preempt_enable();					\
  									\
  		if (!(lock)->break_lock)				\
  			(lock)->break_lock = 1;				\
c2f21ce2e   Thomas Gleixner   locking: Implemen...
75
  		while (!raw_##op##_can_lock(lock) && (lock)->break_lock)\
0199c4e68   Thomas Gleixner   locking: Convert ...
76
  			arch_##op##_relax(&lock->raw_lock);		\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
77
78
79
80
81
  	}								\
  	(lock)->break_lock = 0;						\
  	return flags;							\
  }									\
  									\
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
82
  void __lockfunc __raw_##op##_lock_irq(locktype##_t *lock)		\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
83
  {									\
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
84
  	_raw_##op##_lock_irqsave(lock);					\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
85
86
  }									\
  									\
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
87
  void __lockfunc __raw_##op##_lock_bh(locktype##_t *lock)		\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
88
89
90
91
92
93
94
95
  {									\
  	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 ...
96
  	flags = _raw_##op##_lock_irqsave(lock);				\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
97
98
99
100
101
102
103
104
105
106
107
108
109
  	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...
110
  BUILD_LOCK_OPS(spin, raw_spinlock);
8e13c7b77   Thomas Gleixner   locking: Reduce i...
111
112
113
114
  BUILD_LOCK_OPS(read, rwlock);
  BUILD_LOCK_OPS(write, rwlock);
  
  #endif
6beb00092   Thomas Gleixner   locking: Make inl...
115
  #ifndef CONFIG_INLINE_SPIN_TRYLOCK
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
116
  int __lockfunc _raw_spin_trylock(raw_spinlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
117
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
118
  	return __raw_spin_trylock(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
119
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
120
  EXPORT_SYMBOL(_raw_spin_trylock);
892a7c67c   Heiko Carstens   locking: Allow ar...
121
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
122

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

9c1721aa4   Thomas Gleixner   locking: Cleanup ...
347
  unsigned long __lockfunc _raw_spin_lock_irqsave_nested(raw_spinlock_t *lock,
b7b40ade5   Thomas Gleixner   locking: Reorder ...
348
349
350
351
352
353
354
  						   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 ...
355
356
  	LOCK_CONTENDED_FLAGS(lock, do_raw_spin_trylock, do_raw_spin_lock,
  				do_raw_spin_lock_flags, &flags);
b7b40ade5   Thomas Gleixner   locking: Reorder ...
357
358
  	return flags;
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
359
  EXPORT_SYMBOL(_raw_spin_lock_irqsave_nested);
b7b40ade5   Thomas Gleixner   locking: Reorder ...
360

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

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

0764d23cf   Steven Rostedt   ftrace: lockdep n...
372
  notrace int in_lock_functions(unsigned long addr)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
373
374
375
376
377
378
379
380
  {
  	/* 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);