Blame view

kernel/locking/spinlock.c 10.1 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)
c14c338cb   Will Deacon   kernel/spinlock.c...
36
37
38
39
40
41
42
43
44
45
46
47
48
  
  /*
   * Some architectures can relax in favour of the CPU owning the lock.
   */
  #ifndef arch_read_relax
  # define arch_read_relax(l)	cpu_relax()
  #endif
  #ifndef arch_write_relax
  # define arch_write_relax(l)	cpu_relax()
  #endif
  #ifndef arch_spin_relax
  # define arch_spin_relax(l)	cpu_relax()
  #endif
8e13c7b77   Thomas Gleixner   locking: Reduce i...
49
50
51
52
53
54
55
56
57
58
  /*
   * 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 ...
59
  void __lockfunc __raw_##op##_lock(locktype##_t *lock)			\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
60
61
62
  {									\
  	for (;;) {							\
  		preempt_disable();					\
9828ea9d7   Thomas Gleixner   locking: Further ...
63
  		if (likely(do_raw_##op##_trylock(lock)))		\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
64
65
66
67
68
  			break;						\
  		preempt_enable();					\
  									\
  		if (!(lock)->break_lock)				\
  			(lock)->break_lock = 1;				\
c2f21ce2e   Thomas Gleixner   locking: Implemen...
69
  		while (!raw_##op##_can_lock(lock) && (lock)->break_lock)\
0199c4e68   Thomas Gleixner   locking: Convert ...
70
  			arch_##op##_relax(&lock->raw_lock);		\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
71
72
73
74
  	}								\
  	(lock)->break_lock = 0;						\
  }									\
  									\
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
75
  unsigned long __lockfunc __raw_##op##_lock_irqsave(locktype##_t *lock)	\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
76
77
78
79
80
81
  {									\
  	unsigned long flags;						\
  									\
  	for (;;) {							\
  		preempt_disable();					\
  		local_irq_save(flags);					\
9828ea9d7   Thomas Gleixner   locking: Further ...
82
  		if (likely(do_raw_##op##_trylock(lock)))		\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
83
84
85
86
87
88
  			break;						\
  		local_irq_restore(flags);				\
  		preempt_enable();					\
  									\
  		if (!(lock)->break_lock)				\
  			(lock)->break_lock = 1;				\
c2f21ce2e   Thomas Gleixner   locking: Implemen...
89
  		while (!raw_##op##_can_lock(lock) && (lock)->break_lock)\
0199c4e68   Thomas Gleixner   locking: Convert ...
90
  			arch_##op##_relax(&lock->raw_lock);		\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
91
92
93
94
95
  	}								\
  	(lock)->break_lock = 0;						\
  	return flags;							\
  }									\
  									\
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
96
  void __lockfunc __raw_##op##_lock_irq(locktype##_t *lock)		\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
97
  {									\
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
98
  	_raw_##op##_lock_irqsave(lock);					\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
99
100
  }									\
  									\
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
101
  void __lockfunc __raw_##op##_lock_bh(locktype##_t *lock)		\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
102
103
104
105
106
107
108
109
  {									\
  	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 ...
110
  	flags = _raw_##op##_lock_irqsave(lock);				\
8e13c7b77   Thomas Gleixner   locking: Reduce i...
111
112
113
114
115
116
117
118
119
120
121
122
123
  	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...
124
  BUILD_LOCK_OPS(spin, raw_spinlock);
8e13c7b77   Thomas Gleixner   locking: Reduce i...
125
126
127
128
  BUILD_LOCK_OPS(read, rwlock);
  BUILD_LOCK_OPS(write, rwlock);
  
  #endif
6beb00092   Thomas Gleixner   locking: Make inl...
129
  #ifndef CONFIG_INLINE_SPIN_TRYLOCK
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
130
  int __lockfunc _raw_spin_trylock(raw_spinlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
131
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
132
  	return __raw_spin_trylock(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
133
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
134
  EXPORT_SYMBOL(_raw_spin_trylock);
892a7c67c   Heiko Carstens   locking: Allow ar...
135
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
136

b7b40ade5   Thomas Gleixner   locking: Reorder ...
137
  #ifndef CONFIG_INLINE_SPIN_TRYLOCK_BH
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
138
  int __lockfunc _raw_spin_trylock_bh(raw_spinlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
139
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
140
  	return __raw_spin_trylock_bh(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
141
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
142
  EXPORT_SYMBOL(_raw_spin_trylock_bh);
892a7c67c   Heiko Carstens   locking: Allow ar...
143
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
144

b7b40ade5   Thomas Gleixner   locking: Reorder ...
145
  #ifndef CONFIG_INLINE_SPIN_LOCK
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
146
  void __lockfunc _raw_spin_lock(raw_spinlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
147
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
148
  	__raw_spin_lock(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
149
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
150
  EXPORT_SYMBOL(_raw_spin_lock);
892a7c67c   Heiko Carstens   locking: Allow ar...
151
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
152

6beb00092   Thomas Gleixner   locking: Make inl...
153
  #ifndef CONFIG_INLINE_SPIN_LOCK_IRQSAVE
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
154
  unsigned long __lockfunc _raw_spin_lock_irqsave(raw_spinlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
155
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
156
  	return __raw_spin_lock_irqsave(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
157
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
158
  EXPORT_SYMBOL(_raw_spin_lock_irqsave);
892a7c67c   Heiko Carstens   locking: Allow ar...
159
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
160

6beb00092   Thomas Gleixner   locking: Make inl...
161
  #ifndef CONFIG_INLINE_SPIN_LOCK_IRQ
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
162
  void __lockfunc _raw_spin_lock_irq(raw_spinlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
163
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
164
  	__raw_spin_lock_irq(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
165
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
166
  EXPORT_SYMBOL(_raw_spin_lock_irq);
892a7c67c   Heiko Carstens   locking: Allow ar...
167
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
168

6beb00092   Thomas Gleixner   locking: Make inl...
169
  #ifndef CONFIG_INLINE_SPIN_LOCK_BH
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
170
  void __lockfunc _raw_spin_lock_bh(raw_spinlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
171
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
172
  	__raw_spin_lock_bh(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
173
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
174
  EXPORT_SYMBOL(_raw_spin_lock_bh);
892a7c67c   Heiko Carstens   locking: Allow ar...
175
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
176

e335e3eb8   Raghavendra K T   locking/kconfig: ...
177
  #ifdef CONFIG_UNINLINE_SPIN_UNLOCK
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
178
  void __lockfunc _raw_spin_unlock(raw_spinlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
179
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
180
  	__raw_spin_unlock(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
181
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
182
  EXPORT_SYMBOL(_raw_spin_unlock);
892a7c67c   Heiko Carstens   locking: Allow ar...
183
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
184

b7b40ade5   Thomas Gleixner   locking: Reorder ...
185
  #ifndef CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
186
  void __lockfunc _raw_spin_unlock_irqrestore(raw_spinlock_t *lock, unsigned long flags)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
187
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
188
  	__raw_spin_unlock_irqrestore(lock, flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
189
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
190
  EXPORT_SYMBOL(_raw_spin_unlock_irqrestore);
892a7c67c   Heiko Carstens   locking: Allow ar...
191
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
192

b7b40ade5   Thomas Gleixner   locking: Reorder ...
193
  #ifndef CONFIG_INLINE_SPIN_UNLOCK_IRQ
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
194
  void __lockfunc _raw_spin_unlock_irq(raw_spinlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
195
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
196
  	__raw_spin_unlock_irq(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
197
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
198
  EXPORT_SYMBOL(_raw_spin_unlock_irq);
892a7c67c   Heiko Carstens   locking: Allow ar...
199
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
200

b7b40ade5   Thomas Gleixner   locking: Reorder ...
201
  #ifndef CONFIG_INLINE_SPIN_UNLOCK_BH
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
202
  void __lockfunc _raw_spin_unlock_bh(raw_spinlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
203
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
204
  	__raw_spin_unlock_bh(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
205
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
206
  EXPORT_SYMBOL(_raw_spin_unlock_bh);
892a7c67c   Heiko Carstens   locking: Allow ar...
207
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
208

b7b40ade5   Thomas Gleixner   locking: Reorder ...
209
  #ifndef CONFIG_INLINE_READ_TRYLOCK
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
210
  int __lockfunc _raw_read_trylock(rwlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
211
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
212
  	return __raw_read_trylock(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
213
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
214
  EXPORT_SYMBOL(_raw_read_trylock);
892a7c67c   Heiko Carstens   locking: Allow ar...
215
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
216

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

b7b40ade5   Thomas Gleixner   locking: Reorder ...
225
  #ifndef CONFIG_INLINE_READ_LOCK_IRQSAVE
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
226
  unsigned long __lockfunc _raw_read_lock_irqsave(rwlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
227
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
228
  	return __raw_read_lock_irqsave(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
229
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
230
  EXPORT_SYMBOL(_raw_read_lock_irqsave);
892a7c67c   Heiko Carstens   locking: Allow ar...
231
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
232

b7b40ade5   Thomas Gleixner   locking: Reorder ...
233
  #ifndef CONFIG_INLINE_READ_LOCK_IRQ
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
234
  void __lockfunc _raw_read_lock_irq(rwlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
235
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
236
  	__raw_read_lock_irq(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
237
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
238
  EXPORT_SYMBOL(_raw_read_lock_irq);
892a7c67c   Heiko Carstens   locking: Allow ar...
239
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
240

b7b40ade5   Thomas Gleixner   locking: Reorder ...
241
  #ifndef CONFIG_INLINE_READ_LOCK_BH
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
242
  void __lockfunc _raw_read_lock_bh(rwlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
243
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
244
  	__raw_read_lock_bh(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
245
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
246
  EXPORT_SYMBOL(_raw_read_lock_bh);
892a7c67c   Heiko Carstens   locking: Allow ar...
247
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
248

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

6beb00092   Thomas Gleixner   locking: Make inl...
257
  #ifndef CONFIG_INLINE_READ_UNLOCK_IRQRESTORE
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
258
  void __lockfunc _raw_read_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
259
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
260
  	__raw_read_unlock_irqrestore(lock, flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
261
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
262
  EXPORT_SYMBOL(_raw_read_unlock_irqrestore);
892a7c67c   Heiko Carstens   locking: Allow ar...
263
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
264

6beb00092   Thomas Gleixner   locking: Make inl...
265
  #ifndef CONFIG_INLINE_READ_UNLOCK_IRQ
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
266
  void __lockfunc _raw_read_unlock_irq(rwlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
267
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
268
  	__raw_read_unlock_irq(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
269
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
270
  EXPORT_SYMBOL(_raw_read_unlock_irq);
892a7c67c   Heiko Carstens   locking: Allow ar...
271
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
272

6beb00092   Thomas Gleixner   locking: Make inl...
273
  #ifndef CONFIG_INLINE_READ_UNLOCK_BH
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
274
  void __lockfunc _raw_read_unlock_bh(rwlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
275
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
276
  	__raw_read_unlock_bh(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
277
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
278
  EXPORT_SYMBOL(_raw_read_unlock_bh);
892a7c67c   Heiko Carstens   locking: Allow ar...
279
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
280

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

6beb00092   Thomas Gleixner   locking: Make inl...
336
  #ifndef CONFIG_INLINE_WRITE_UNLOCK_IRQ
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
337
  void __lockfunc _raw_write_unlock_irq(rwlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
338
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
339
  	__raw_write_unlock_irq(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
340
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
341
  EXPORT_SYMBOL(_raw_write_unlock_irq);
892a7c67c   Heiko Carstens   locking: Allow ar...
342
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
343

6beb00092   Thomas Gleixner   locking: Make inl...
344
  #ifndef CONFIG_INLINE_WRITE_UNLOCK_BH
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
345
  void __lockfunc _raw_write_unlock_bh(rwlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
346
  {
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
347
  	__raw_write_unlock_bh(lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
348
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
349
  EXPORT_SYMBOL(_raw_write_unlock_bh);
892a7c67c   Heiko Carstens   locking: Allow ar...
350
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
351

b7b40ade5   Thomas Gleixner   locking: Reorder ...
352
  #ifdef CONFIG_DEBUG_LOCK_ALLOC
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
353
  void __lockfunc _raw_spin_lock_nested(raw_spinlock_t *lock, int subclass)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
354
  {
b7b40ade5   Thomas Gleixner   locking: Reorder ...
355
356
  	preempt_disable();
  	spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_);
9828ea9d7   Thomas Gleixner   locking: Further ...
357
  	LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
358
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
359
  EXPORT_SYMBOL(_raw_spin_lock_nested);
b7b40ade5   Thomas Gleixner   locking: Reorder ...
360

113948d84   Thomas Graf   spinlock: Add spi...
361
362
363
364
365
366
367
  void __lockfunc _raw_spin_lock_bh_nested(raw_spinlock_t *lock, int subclass)
  {
  	__local_bh_disable_ip(_RET_IP_, SOFTIRQ_LOCK_OFFSET);
  	spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_);
  	LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock);
  }
  EXPORT_SYMBOL(_raw_spin_lock_bh_nested);
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
368
  unsigned long __lockfunc _raw_spin_lock_irqsave_nested(raw_spinlock_t *lock,
b7b40ade5   Thomas Gleixner   locking: Reorder ...
369
370
371
372
373
374
375
  						   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 ...
376
377
  	LOCK_CONTENDED_FLAGS(lock, do_raw_spin_trylock, do_raw_spin_lock,
  				do_raw_spin_lock_flags, &flags);
b7b40ade5   Thomas Gleixner   locking: Reorder ...
378
379
  	return flags;
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
380
  EXPORT_SYMBOL(_raw_spin_lock_irqsave_nested);
b7b40ade5   Thomas Gleixner   locking: Reorder ...
381

9c1721aa4   Thomas Gleixner   locking: Cleanup ...
382
  void __lockfunc _raw_spin_lock_nest_lock(raw_spinlock_t *lock,
b7b40ade5   Thomas Gleixner   locking: Reorder ...
383
384
385
386
  				     struct lockdep_map *nest_lock)
  {
  	preempt_disable();
  	spin_acquire_nest(&lock->dep_map, 0, 0, nest_lock, _RET_IP_);
9828ea9d7   Thomas Gleixner   locking: Further ...
387
  	LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock);
b7b40ade5   Thomas Gleixner   locking: Reorder ...
388
  }
9c1721aa4   Thomas Gleixner   locking: Cleanup ...
389
  EXPORT_SYMBOL(_raw_spin_lock_nest_lock);
b7b40ade5   Thomas Gleixner   locking: Reorder ...
390

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

0764d23cf   Steven Rostedt   ftrace: lockdep n...
393
  notrace int in_lock_functions(unsigned long addr)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
394
395
396
397
398
399
400
401
  {
  	/* 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);