diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2008-08-11 03:30:23 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-08-11 03:30:23 -0400 |
commit | 4f3e7524b2e703d9f8b02ac338153a53dd7ede66 (patch) | |
tree | 0033ade94f230d6044ad318e3791c55ad611069e | |
parent | f82b217e3513fe3af342c0f3ee1494e86250c21c (diff) |
lockdep: map_acquire
Most the free-standing lock_acquire() usages look remarkably similar, sweep
them into a new helper.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | fs/jbd/transaction.c | 4 | ||||
-rw-r--r-- | fs/jbd2/transaction.c | 4 | ||||
-rw-r--r-- | include/linux/lockdep.h | 12 | ||||
-rw-r--r-- | kernel/workqueue.c | 24 |
4 files changed, 28 insertions, 16 deletions
diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c index 8dee32007500..31a4bd7f78d7 100644 --- a/fs/jbd/transaction.c +++ b/fs/jbd/transaction.c | |||
@@ -291,7 +291,7 @@ handle_t *journal_start(journal_t *journal, int nblocks) | |||
291 | goto out; | 291 | goto out; |
292 | } | 292 | } |
293 | 293 | ||
294 | lock_acquire(&handle->h_lockdep_map, 0, 0, 0, 2, _THIS_IP_); | 294 | map_acquire(&handle->h_lockdep_map); |
295 | 295 | ||
296 | out: | 296 | out: |
297 | return handle; | 297 | return handle; |
@@ -1448,7 +1448,7 @@ int journal_stop(handle_t *handle) | |||
1448 | spin_unlock(&journal->j_state_lock); | 1448 | spin_unlock(&journal->j_state_lock); |
1449 | } | 1449 | } |
1450 | 1450 | ||
1451 | lock_release(&handle->h_lockdep_map, 1, _THIS_IP_); | 1451 | map_release(&handle->h_lockdep_map); |
1452 | 1452 | ||
1453 | jbd_free_handle(handle); | 1453 | jbd_free_handle(handle); |
1454 | return err; | 1454 | return err; |
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index 4f7cadbb19fa..c074971215ed 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c | |||
@@ -301,7 +301,7 @@ handle_t *jbd2_journal_start(journal_t *journal, int nblocks) | |||
301 | goto out; | 301 | goto out; |
302 | } | 302 | } |
303 | 303 | ||
304 | lock_acquire(&handle->h_lockdep_map, 0, 0, 0, 2, _THIS_IP_); | 304 | map_acquire(&handle->h_lockdep_map); |
305 | out: | 305 | out: |
306 | return handle; | 306 | return handle; |
307 | } | 307 | } |
@@ -1279,7 +1279,7 @@ int jbd2_journal_stop(handle_t *handle) | |||
1279 | spin_unlock(&journal->j_state_lock); | 1279 | spin_unlock(&journal->j_state_lock); |
1280 | } | 1280 | } |
1281 | 1281 | ||
1282 | lock_release(&handle->h_lockdep_map, 1, _THIS_IP_); | 1282 | map_release(&handle->h_lockdep_map); |
1283 | 1283 | ||
1284 | jbd2_free_handle(handle); | 1284 | jbd2_free_handle(handle); |
1285 | return err; | 1285 | return err; |
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index b49bfa8e4a5c..e431d1d6eaf3 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h | |||
@@ -459,4 +459,16 @@ static inline void print_irqtrace_events(struct task_struct *curr) | |||
459 | # define rwsem_release(l, n, i) do { } while (0) | 459 | # define rwsem_release(l, n, i) do { } while (0) |
460 | #endif | 460 | #endif |
461 | 461 | ||
462 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
463 | # ifdef CONFIG_PROVE_LOCKING | ||
464 | # define map_acquire(l) lock_acquire(l, 0, 0, 0, 2, _THIS_IP_) | ||
465 | # else | ||
466 | # define map_acquire(l) lock_acquire(l, 0, 0, 0, 1, _THIS_IP_) | ||
467 | # endif | ||
468 | # define map_release(l) lock_release(l, 1, _THIS_IP_) | ||
469 | #else | ||
470 | # define map_acquire(l) do { } while (0) | ||
471 | # define map_release(l) do { } while (0) | ||
472 | #endif | ||
473 | |||
462 | #endif /* __LINUX_LOCKDEP_H */ | 474 | #endif /* __LINUX_LOCKDEP_H */ |
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index ec7e4f62aaff..53564ae894a6 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
@@ -290,11 +290,11 @@ static void run_workqueue(struct cpu_workqueue_struct *cwq) | |||
290 | 290 | ||
291 | BUG_ON(get_wq_data(work) != cwq); | 291 | BUG_ON(get_wq_data(work) != cwq); |
292 | work_clear_pending(work); | 292 | work_clear_pending(work); |
293 | lock_acquire(&cwq->wq->lockdep_map, 0, 0, 0, 2, _THIS_IP_); | 293 | map_acquire(&cwq->wq->lockdep_map); |
294 | lock_acquire(&lockdep_map, 0, 0, 0, 2, _THIS_IP_); | 294 | map_acquire(&lockdep_map); |
295 | f(work); | 295 | f(work); |
296 | lock_release(&lockdep_map, 1, _THIS_IP_); | 296 | map_release(&lockdep_map); |
297 | lock_release(&cwq->wq->lockdep_map, 1, _THIS_IP_); | 297 | map_release(&cwq->wq->lockdep_map); |
298 | 298 | ||
299 | if (unlikely(in_atomic() || lockdep_depth(current) > 0)) { | 299 | if (unlikely(in_atomic() || lockdep_depth(current) > 0)) { |
300 | printk(KERN_ERR "BUG: workqueue leaked lock or atomic: " | 300 | printk(KERN_ERR "BUG: workqueue leaked lock or atomic: " |
@@ -413,8 +413,8 @@ void flush_workqueue(struct workqueue_struct *wq) | |||
413 | int cpu; | 413 | int cpu; |
414 | 414 | ||
415 | might_sleep(); | 415 | might_sleep(); |
416 | lock_acquire(&wq->lockdep_map, 0, 0, 0, 2, _THIS_IP_); | 416 | map_acquire(&wq->lockdep_map); |
417 | lock_release(&wq->lockdep_map, 1, _THIS_IP_); | 417 | map_release(&wq->lockdep_map); |
418 | for_each_cpu_mask_nr(cpu, *cpu_map) | 418 | for_each_cpu_mask_nr(cpu, *cpu_map) |
419 | flush_cpu_workqueue(per_cpu_ptr(wq->cpu_wq, cpu)); | 419 | flush_cpu_workqueue(per_cpu_ptr(wq->cpu_wq, cpu)); |
420 | } | 420 | } |
@@ -441,8 +441,8 @@ int flush_work(struct work_struct *work) | |||
441 | if (!cwq) | 441 | if (!cwq) |
442 | return 0; | 442 | return 0; |
443 | 443 | ||
444 | lock_acquire(&cwq->wq->lockdep_map, 0, 0, 0, 2, _THIS_IP_); | 444 | map_acquire(&cwq->wq->lockdep_map); |
445 | lock_release(&cwq->wq->lockdep_map, 1, _THIS_IP_); | 445 | map_release(&cwq->wq->lockdep_map); |
446 | 446 | ||
447 | prev = NULL; | 447 | prev = NULL; |
448 | spin_lock_irq(&cwq->lock); | 448 | spin_lock_irq(&cwq->lock); |
@@ -536,8 +536,8 @@ static void wait_on_work(struct work_struct *work) | |||
536 | 536 | ||
537 | might_sleep(); | 537 | might_sleep(); |
538 | 538 | ||
539 | lock_acquire(&work->lockdep_map, 0, 0, 0, 2, _THIS_IP_); | 539 | map_acquire(&work->lockdep_map); |
540 | lock_release(&work->lockdep_map, 1, _THIS_IP_); | 540 | map_release(&work->lockdep_map); |
541 | 541 | ||
542 | cwq = get_wq_data(work); | 542 | cwq = get_wq_data(work); |
543 | if (!cwq) | 543 | if (!cwq) |
@@ -861,8 +861,8 @@ static void cleanup_workqueue_thread(struct cpu_workqueue_struct *cwq) | |||
861 | if (cwq->thread == NULL) | 861 | if (cwq->thread == NULL) |
862 | return; | 862 | return; |
863 | 863 | ||
864 | lock_acquire(&cwq->wq->lockdep_map, 0, 0, 0, 2, _THIS_IP_); | 864 | map_acquire(&cwq->wq->lockdep_map); |
865 | lock_release(&cwq->wq->lockdep_map, 1, _THIS_IP_); | 865 | map_release(&cwq->wq->lockdep_map); |
866 | 866 | ||
867 | flush_cpu_workqueue(cwq); | 867 | flush_cpu_workqueue(cwq); |
868 | /* | 868 | /* |