diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-08-11 18:11:49 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-08-11 18:11:49 -0400 |
commit | 23a0ee908cbfba3264d19729c67c22b20fa73886 (patch) | |
tree | 541103f6283cbac6b82cff88a7b91128acfce046 /include | |
parent | cc7a486cac78f6fc1a24e8cd63036bae8d2ab431 (diff) | |
parent | 0f2bc27be27ca1dcc66b96131e44bf7648b959c6 (diff) |
Merge branch 'core/locking' into core/urgent
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/lockdep.h | 70 | ||||
-rw-r--r-- | include/linux/rcuclassic.h | 2 | ||||
-rw-r--r-- | include/linux/spinlock.h | 6 | ||||
-rw-r--r-- | include/linux/spinlock_api_smp.h | 2 |
4 files changed, 58 insertions, 22 deletions
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index 2486eb4edbf..331e5f1c2d8 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h | |||
@@ -89,6 +89,7 @@ struct lock_class { | |||
89 | 89 | ||
90 | struct lockdep_subclass_key *key; | 90 | struct lockdep_subclass_key *key; |
91 | unsigned int subclass; | 91 | unsigned int subclass; |
92 | unsigned int dep_gen_id; | ||
92 | 93 | ||
93 | /* | 94 | /* |
94 | * IRQ/softirq usage tracking bits: | 95 | * IRQ/softirq usage tracking bits: |
@@ -189,6 +190,14 @@ struct lock_chain { | |||
189 | u64 chain_key; | 190 | u64 chain_key; |
190 | }; | 191 | }; |
191 | 192 | ||
193 | #define MAX_LOCKDEP_KEYS_BITS 13 | ||
194 | /* | ||
195 | * Subtract one because we offset hlock->class_idx by 1 in order | ||
196 | * to make 0 mean no class. This avoids overflowing the class_idx | ||
197 | * bitfield and hitting the BUG in hlock_class(). | ||
198 | */ | ||
199 | #define MAX_LOCKDEP_KEYS ((1UL << MAX_LOCKDEP_KEYS_BITS) - 1) | ||
200 | |||
192 | struct held_lock { | 201 | struct held_lock { |
193 | /* | 202 | /* |
194 | * One-way hash of the dependency chain up to this point. We | 203 | * One-way hash of the dependency chain up to this point. We |
@@ -205,14 +214,14 @@ struct held_lock { | |||
205 | * with zero), here we store the previous hash value: | 214 | * with zero), here we store the previous hash value: |
206 | */ | 215 | */ |
207 | u64 prev_chain_key; | 216 | u64 prev_chain_key; |
208 | struct lock_class *class; | ||
209 | unsigned long acquire_ip; | 217 | unsigned long acquire_ip; |
210 | struct lockdep_map *instance; | 218 | struct lockdep_map *instance; |
211 | 219 | struct lockdep_map *nest_lock; | |
212 | #ifdef CONFIG_LOCK_STAT | 220 | #ifdef CONFIG_LOCK_STAT |
213 | u64 waittime_stamp; | 221 | u64 waittime_stamp; |
214 | u64 holdtime_stamp; | 222 | u64 holdtime_stamp; |
215 | #endif | 223 | #endif |
224 | unsigned int class_idx:MAX_LOCKDEP_KEYS_BITS; | ||
216 | /* | 225 | /* |
217 | * The lock-stack is unified in that the lock chains of interrupt | 226 | * The lock-stack is unified in that the lock chains of interrupt |
218 | * contexts nest ontop of process context chains, but we 'separate' | 227 | * contexts nest ontop of process context chains, but we 'separate' |
@@ -226,11 +235,11 @@ struct held_lock { | |||
226 | * The following field is used to detect when we cross into an | 235 | * The following field is used to detect when we cross into an |
227 | * interrupt context: | 236 | * interrupt context: |
228 | */ | 237 | */ |
229 | int irq_context; | 238 | unsigned int irq_context:2; /* bit 0 - soft, bit 1 - hard */ |
230 | int trylock; | 239 | unsigned int trylock:1; |
231 | int read; | 240 | unsigned int read:2; /* see lock_acquire() comment */ |
232 | int check; | 241 | unsigned int check:2; /* see lock_acquire() comment */ |
233 | int hardirqs_off; | 242 | unsigned int hardirqs_off:1; |
234 | }; | 243 | }; |
235 | 244 | ||
236 | /* | 245 | /* |
@@ -294,11 +303,15 @@ extern void lockdep_init_map(struct lockdep_map *lock, const char *name, | |||
294 | * 2: full validation | 303 | * 2: full validation |
295 | */ | 304 | */ |
296 | extern void lock_acquire(struct lockdep_map *lock, unsigned int subclass, | 305 | extern void lock_acquire(struct lockdep_map *lock, unsigned int subclass, |
297 | int trylock, int read, int check, unsigned long ip); | 306 | int trylock, int read, int check, |
307 | struct lockdep_map *nest_lock, unsigned long ip); | ||
298 | 308 | ||
299 | extern void lock_release(struct lockdep_map *lock, int nested, | 309 | extern void lock_release(struct lockdep_map *lock, int nested, |
300 | unsigned long ip); | 310 | unsigned long ip); |
301 | 311 | ||
312 | extern void lock_set_subclass(struct lockdep_map *lock, unsigned int subclass, | ||
313 | unsigned long ip); | ||
314 | |||
302 | # define INIT_LOCKDEP .lockdep_recursion = 0, | 315 | # define INIT_LOCKDEP .lockdep_recursion = 0, |
303 | 316 | ||
304 | #define lockdep_depth(tsk) (debug_locks ? (tsk)->lockdep_depth : 0) | 317 | #define lockdep_depth(tsk) (debug_locks ? (tsk)->lockdep_depth : 0) |
@@ -313,8 +326,9 @@ static inline void lockdep_on(void) | |||
313 | { | 326 | { |
314 | } | 327 | } |
315 | 328 | ||
316 | # define lock_acquire(l, s, t, r, c, i) do { } while (0) | 329 | # define lock_acquire(l, s, t, r, c, n, i) do { } while (0) |
317 | # define lock_release(l, n, i) do { } while (0) | 330 | # define lock_release(l, n, i) do { } while (0) |
331 | # define lock_set_subclass(l, s, i) do { } while (0) | ||
318 | # define lockdep_init() do { } while (0) | 332 | # define lockdep_init() do { } while (0) |
319 | # define lockdep_info() do { } while (0) | 333 | # define lockdep_info() do { } while (0) |
320 | # define lockdep_init_map(lock, name, key, sub) do { (void)(key); } while (0) | 334 | # define lockdep_init_map(lock, name, key, sub) do { (void)(key); } while (0) |
@@ -400,9 +414,11 @@ static inline void print_irqtrace_events(struct task_struct *curr) | |||
400 | 414 | ||
401 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 415 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
402 | # ifdef CONFIG_PROVE_LOCKING | 416 | # ifdef CONFIG_PROVE_LOCKING |
403 | # define spin_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, i) | 417 | # define spin_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, NULL, i) |
418 | # define spin_acquire_nest(l, s, t, n, i) lock_acquire(l, s, t, 0, 2, n, i) | ||
404 | # else | 419 | # else |
405 | # define spin_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, i) | 420 | # define spin_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, NULL, i) |
421 | # define spin_acquire_nest(l, s, t, n, i) lock_acquire(l, s, t, 0, 1, NULL, i) | ||
406 | # endif | 422 | # endif |
407 | # define spin_release(l, n, i) lock_release(l, n, i) | 423 | # define spin_release(l, n, i) lock_release(l, n, i) |
408 | #else | 424 | #else |
@@ -412,11 +428,11 @@ static inline void print_irqtrace_events(struct task_struct *curr) | |||
412 | 428 | ||
413 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 429 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
414 | # ifdef CONFIG_PROVE_LOCKING | 430 | # ifdef CONFIG_PROVE_LOCKING |
415 | # define rwlock_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, i) | 431 | # define rwlock_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, NULL, i) |
416 | # define rwlock_acquire_read(l, s, t, i) lock_acquire(l, s, t, 2, 2, i) | 432 | # define rwlock_acquire_read(l, s, t, i) lock_acquire(l, s, t, 2, 2, NULL, i) |
417 | # else | 433 | # else |
418 | # define rwlock_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, i) | 434 | # define rwlock_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, NULL, i) |
419 | # define rwlock_acquire_read(l, s, t, i) lock_acquire(l, s, t, 2, 1, i) | 435 | # define rwlock_acquire_read(l, s, t, i) lock_acquire(l, s, t, 2, 1, NULL, i) |
420 | # endif | 436 | # endif |
421 | # define rwlock_release(l, n, i) lock_release(l, n, i) | 437 | # define rwlock_release(l, n, i) lock_release(l, n, i) |
422 | #else | 438 | #else |
@@ -427,9 +443,9 @@ static inline void print_irqtrace_events(struct task_struct *curr) | |||
427 | 443 | ||
428 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 444 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
429 | # ifdef CONFIG_PROVE_LOCKING | 445 | # ifdef CONFIG_PROVE_LOCKING |
430 | # define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, i) | 446 | # define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, NULL, i) |
431 | # else | 447 | # else |
432 | # define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, i) | 448 | # define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, NULL, i) |
433 | # endif | 449 | # endif |
434 | # define mutex_release(l, n, i) lock_release(l, n, i) | 450 | # define mutex_release(l, n, i) lock_release(l, n, i) |
435 | #else | 451 | #else |
@@ -439,11 +455,11 @@ static inline void print_irqtrace_events(struct task_struct *curr) | |||
439 | 455 | ||
440 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 456 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
441 | # ifdef CONFIG_PROVE_LOCKING | 457 | # ifdef CONFIG_PROVE_LOCKING |
442 | # define rwsem_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, i) | 458 | # define rwsem_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, NULL, i) |
443 | # define rwsem_acquire_read(l, s, t, i) lock_acquire(l, s, t, 1, 2, i) | 459 | # define rwsem_acquire_read(l, s, t, i) lock_acquire(l, s, t, 1, 2, NULL, i) |
444 | # else | 460 | # else |
445 | # define rwsem_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, i) | 461 | # define rwsem_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, NULL, i) |
446 | # define rwsem_acquire_read(l, s, t, i) lock_acquire(l, s, t, 1, 1, i) | 462 | # define rwsem_acquire_read(l, s, t, i) lock_acquire(l, s, t, 1, 1, NULL, i) |
447 | # endif | 463 | # endif |
448 | # define rwsem_release(l, n, i) lock_release(l, n, i) | 464 | # define rwsem_release(l, n, i) lock_release(l, n, i) |
449 | #else | 465 | #else |
@@ -452,4 +468,16 @@ static inline void print_irqtrace_events(struct task_struct *curr) | |||
452 | # define rwsem_release(l, n, i) do { } while (0) | 468 | # define rwsem_release(l, n, i) do { } while (0) |
453 | #endif | 469 | #endif |
454 | 470 | ||
471 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
472 | # ifdef CONFIG_PROVE_LOCKING | ||
473 | # define lock_map_acquire(l) lock_acquire(l, 0, 0, 0, 2, NULL, _THIS_IP_) | ||
474 | # else | ||
475 | # define lock_map_acquire(l) lock_acquire(l, 0, 0, 0, 1, NULL, _THIS_IP_) | ||
476 | # endif | ||
477 | # define lock_map_release(l) lock_release(l, 1, _THIS_IP_) | ||
478 | #else | ||
479 | # define lock_map_acquire(l) do { } while (0) | ||
480 | # define lock_map_release(l) do { } while (0) | ||
481 | #endif | ||
482 | |||
455 | #endif /* __LINUX_LOCKDEP_H */ | 483 | #endif /* __LINUX_LOCKDEP_H */ |
diff --git a/include/linux/rcuclassic.h b/include/linux/rcuclassic.h index 8c774905dcf..4ab84362272 100644 --- a/include/linux/rcuclassic.h +++ b/include/linux/rcuclassic.h | |||
@@ -117,7 +117,7 @@ extern int rcu_needs_cpu(int cpu); | |||
117 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 117 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
118 | extern struct lockdep_map rcu_lock_map; | 118 | extern struct lockdep_map rcu_lock_map; |
119 | # define rcu_read_acquire() \ | 119 | # define rcu_read_acquire() \ |
120 | lock_acquire(&rcu_lock_map, 0, 0, 2, 1, _THIS_IP_) | 120 | lock_acquire(&rcu_lock_map, 0, 0, 2, 1, NULL, _THIS_IP_) |
121 | # define rcu_read_release() lock_release(&rcu_lock_map, 1, _THIS_IP_) | 121 | # define rcu_read_release() lock_release(&rcu_lock_map, 1, _THIS_IP_) |
122 | #else | 122 | #else |
123 | # define rcu_read_acquire() do { } while (0) | 123 | # define rcu_read_acquire() do { } while (0) |
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h index 61e5610ad16..e0c0fccced4 100644 --- a/include/linux/spinlock.h +++ b/include/linux/spinlock.h | |||
@@ -183,8 +183,14 @@ do { \ | |||
183 | 183 | ||
184 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 184 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
185 | # define spin_lock_nested(lock, subclass) _spin_lock_nested(lock, subclass) | 185 | # define spin_lock_nested(lock, subclass) _spin_lock_nested(lock, subclass) |
186 | # define spin_lock_nest_lock(lock, nest_lock) \ | ||
187 | do { \ | ||
188 | typecheck(struct lockdep_map *, &(nest_lock)->dep_map);\ | ||
189 | _spin_lock_nest_lock(lock, &(nest_lock)->dep_map); \ | ||
190 | } while (0) | ||
186 | #else | 191 | #else |
187 | # define spin_lock_nested(lock, subclass) _spin_lock(lock) | 192 | # define spin_lock_nested(lock, subclass) _spin_lock(lock) |
193 | # define spin_lock_nest_lock(lock, nest_lock) _spin_lock(lock) | ||
188 | #endif | 194 | #endif |
189 | 195 | ||
190 | #define write_lock(lock) _write_lock(lock) | 196 | #define write_lock(lock) _write_lock(lock) |
diff --git a/include/linux/spinlock_api_smp.h b/include/linux/spinlock_api_smp.h index 8a2307ce729..d79845d034b 100644 --- a/include/linux/spinlock_api_smp.h +++ b/include/linux/spinlock_api_smp.h | |||
@@ -22,6 +22,8 @@ int in_lock_functions(unsigned long addr); | |||
22 | void __lockfunc _spin_lock(spinlock_t *lock) __acquires(lock); | 22 | void __lockfunc _spin_lock(spinlock_t *lock) __acquires(lock); |
23 | void __lockfunc _spin_lock_nested(spinlock_t *lock, int subclass) | 23 | void __lockfunc _spin_lock_nested(spinlock_t *lock, int subclass) |
24 | __acquires(lock); | 24 | __acquires(lock); |
25 | void __lockfunc _spin_lock_nest_lock(spinlock_t *lock, struct lockdep_map *map) | ||
26 | __acquires(lock); | ||
25 | void __lockfunc _read_lock(rwlock_t *lock) __acquires(lock); | 27 | void __lockfunc _read_lock(rwlock_t *lock) __acquires(lock); |
26 | void __lockfunc _write_lock(rwlock_t *lock) __acquires(lock); | 28 | void __lockfunc _write_lock(rwlock_t *lock) __acquires(lock); |
27 | void __lockfunc _spin_lock_bh(spinlock_t *lock) __acquires(lock); | 29 | void __lockfunc _spin_lock_bh(spinlock_t *lock) __acquires(lock); |