From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Linus Torvalds <torvalds@linux-foundation.org>,
David Miller <davem@davemloft.net>,
jeremy@goop.org, hugh@veritas.com, mingo@elte.hu,
akpm@linux-foundation.org, a.p.zijlstra@chello.nl,
linux-kernel@vger.kernel.org, davej@redhat.com
Subject: [RFC][PATCH 5/7] lockdep: map_acquire
Date: Mon, 04 Aug 2008 15:03:22 +0200 [thread overview]
Message-ID: <20080804131012.076019775@chello.nl> (raw)
In-Reply-To: 20080804130317.994042639@chello.nl
[-- Attachment #1: lockdep-map_acquire.patch --]
[-- Type: text/plain, Size: 4486 bytes --]
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>
---
fs/jbd/transaction.c | 4 ++--
fs/jbd2/transaction.c | 4 ++--
include/linux/lockdep.h | 12 ++++++++++++
kernel/workqueue.c | 24 ++++++++++++------------
4 files changed, 28 insertions(+), 16 deletions(-)
Index: linux-2.6/fs/jbd/transaction.c
===================================================================
--- linux-2.6.orig/fs/jbd/transaction.c
+++ linux-2.6/fs/jbd/transaction.c
@@ -291,7 +291,7 @@ handle_t *journal_start(journal_t *journ
goto out;
}
- lock_acquire(&handle->h_lockdep_map, 0, 0, 0, 2, _THIS_IP_);
+ map_acquire(&handle->h_lockdep_map);
out:
return handle;
@@ -1448,7 +1448,7 @@ int journal_stop(handle_t *handle)
spin_unlock(&journal->j_state_lock);
}
- lock_release(&handle->h_lockdep_map, 1, _THIS_IP_);
+ map_release(&handle->h_lockdep_map);
jbd_free_handle(handle);
return err;
Index: linux-2.6/fs/jbd2/transaction.c
===================================================================
--- linux-2.6.orig/fs/jbd2/transaction.c
+++ linux-2.6/fs/jbd2/transaction.c
@@ -301,7 +301,7 @@ handle_t *jbd2_journal_start(journal_t *
goto out;
}
- lock_acquire(&handle->h_lockdep_map, 0, 0, 0, 2, _THIS_IP_);
+ map_acquire(&handle->h_lockdep_map);
out:
return handle;
}
@@ -1279,7 +1279,7 @@ int jbd2_journal_stop(handle_t *handle)
spin_unlock(&journal->j_state_lock);
}
- lock_release(&handle->h_lockdep_map, 1, _THIS_IP_);
+ map_release(&handle->h_lockdep_map);
jbd2_free_handle(handle);
return err;
Index: linux-2.6/include/linux/lockdep.h
===================================================================
--- linux-2.6.orig/include/linux/lockdep.h
+++ linux-2.6/include/linux/lockdep.h
@@ -459,4 +459,16 @@ static inline void print_irqtrace_events
# define rwsem_release(l, n, i) do { } while (0)
#endif
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+# ifdef CONFIG_PROVE_LOCKING
+# define map_acquire(l) lock_acquire(l, 0, 0, 0, 2, _THIS_IP_)
+# else
+# define map_acquire(l) lock_acquire(l, 0, 0, 0, 1, _THIS_IP_)
+# endif
+# define map_release(l) lock_release(l, 1, _THIS_IP_)
+#else
+# define map_acquire(l) do { } while (0)
+# define map_release(l) do { } while (0)
+#endif
+
#endif /* __LINUX_LOCKDEP_H */
Index: linux-2.6/kernel/workqueue.c
===================================================================
--- linux-2.6.orig/kernel/workqueue.c
+++ linux-2.6/kernel/workqueue.c
@@ -290,11 +290,11 @@ static void run_workqueue(struct cpu_wor
BUG_ON(get_wq_data(work) != cwq);
work_clear_pending(work);
- lock_acquire(&cwq->wq->lockdep_map, 0, 0, 0, 2, _THIS_IP_);
- lock_acquire(&lockdep_map, 0, 0, 0, 2, _THIS_IP_);
+ map_acquire(&cwq->wq->lockdep_map);
+ map_acquire(&lockdep_map);
f(work);
- lock_release(&lockdep_map, 1, _THIS_IP_);
- lock_release(&cwq->wq->lockdep_map, 1, _THIS_IP_);
+ map_release(&lockdep_map);
+ map_release(&cwq->wq->lockdep_map);
if (unlikely(in_atomic() || lockdep_depth(current) > 0)) {
printk(KERN_ERR "BUG: workqueue leaked lock or atomic: "
@@ -413,8 +413,8 @@ void flush_workqueue(struct workqueue_st
int cpu;
might_sleep();
- lock_acquire(&wq->lockdep_map, 0, 0, 0, 2, _THIS_IP_);
- lock_release(&wq->lockdep_map, 1, _THIS_IP_);
+ map_acquire(&wq->lockdep_map);
+ map_release(&wq->lockdep_map);
for_each_cpu_mask_nr(cpu, *cpu_map)
flush_cpu_workqueue(per_cpu_ptr(wq->cpu_wq, cpu));
}
@@ -441,8 +441,8 @@ int flush_work(struct work_struct *work)
if (!cwq)
return 0;
- lock_acquire(&cwq->wq->lockdep_map, 0, 0, 0, 2, _THIS_IP_);
- lock_release(&cwq->wq->lockdep_map, 1, _THIS_IP_);
+ map_acquire(&cwq->wq->lockdep_map);
+ map_release(&cwq->wq->lockdep_map);
prev = NULL;
spin_lock_irq(&cwq->lock);
@@ -536,8 +536,8 @@ static void wait_on_work(struct work_str
might_sleep();
- lock_acquire(&work->lockdep_map, 0, 0, 0, 2, _THIS_IP_);
- lock_release(&work->lockdep_map, 1, _THIS_IP_);
+ map_acquire(&work->lockdep_map);
+ map_release(&work->lockdep_map);
cwq = get_wq_data(work);
if (!cwq)
@@ -872,8 +872,8 @@ static void cleanup_workqueue_thread(str
if (cwq->thread == NULL)
return;
- lock_acquire(&cwq->wq->lockdep_map, 0, 0, 0, 2, _THIS_IP_);
- lock_release(&cwq->wq->lockdep_map, 1, _THIS_IP_);
+ map_acquire(&cwq->wq->lockdep_map);
+ map_release(&cwq->wq->lockdep_map);
flush_cpu_workqueue(cwq);
/*
--
next prev parent reply other threads:[~2008-08-04 13:20 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-04 13:03 [RFC][PATCH 0/7] lockdep Peter Zijlstra
2008-08-04 13:03 ` [RFC][PATCH 1/7] lockdep: Fix combinatorial explosion in lock subgraph traversal Peter Zijlstra
2008-08-05 8:34 ` David Miller
2008-08-05 8:46 ` Peter Zijlstra
2008-08-13 3:48 ` Tim Pepper
2008-08-13 10:56 ` Ingo Molnar
2008-08-04 13:03 ` [RFC][PATCH 2/7] lockdep: lock_set_subclass - reset a held locks subclass Peter Zijlstra
2008-08-05 8:35 ` David Miller
2008-08-04 13:03 ` [RFC][PATCH 3/7] lockdep: re-annotate scheduler runqueues Peter Zijlstra
2008-08-05 8:35 ` David Miller
2008-08-04 13:03 ` [RFC][PATCH 4/7] lockdep: shrink held_lock structure Peter Zijlstra
2008-08-05 16:08 ` Peter Zijlstra
2008-08-06 7:17 ` Peter Zijlstra
2008-08-04 13:03 ` Peter Zijlstra [this message]
2008-08-04 13:03 ` [RFC][PATCH 6/7] lockdep: lock protection locks Peter Zijlstra
2008-08-04 13:03 ` [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock() Peter Zijlstra
2008-08-04 14:07 ` Roland Dreier
2008-08-04 14:19 ` Peter Zijlstra
2008-08-04 14:26 ` Roland Dreier
2008-08-04 14:32 ` Peter Zijlstra
2008-08-04 14:53 ` Dave Jones
2008-08-04 14:56 ` Peter Zijlstra
2008-08-04 16:26 ` Andrea Arcangeli
2008-08-04 16:38 ` Peter Zijlstra
2008-08-04 17:27 ` Andrea Arcangeli
2008-08-04 17:46 ` Andrea Arcangeli
2008-08-04 17:57 ` [PATCH] workaround minor lockdep bug triggered by mm_take_all_locks Andrea Arcangeli
2008-08-04 18:48 ` Peter Zijlstra
2008-08-04 18:56 ` Roland Dreier
2008-08-04 19:05 ` Peter Zijlstra
2008-08-04 20:15 ` Andrea Arcangeli
2008-08-04 20:37 ` Peter Zijlstra
2008-08-04 21:09 ` Andrea Arcangeli
2008-08-04 21:14 ` Pekka Enberg
2008-08-04 21:30 ` Andrea Arcangeli
2008-08-04 21:41 ` Andrew Morton
2008-08-04 22:12 ` Andrea Arcangeli
2008-08-04 21:42 ` Arjan van de Ven
2008-08-04 22:30 ` Andrea Arcangeli
2008-08-04 23:38 ` Arjan van de Ven
2008-08-05 0:47 ` Andrea Arcangeli
2008-08-04 21:27 ` Arjan van de Ven
2008-08-04 21:54 ` Andrea Arcangeli
2008-08-04 21:57 ` David Miller
2008-08-05 2:00 ` Roland Dreier
2008-08-05 2:18 ` Andrea Arcangeli
2008-08-05 12:02 ` Roland Dreier
2008-08-05 12:20 ` Andrea Arcangeli
2008-08-04 18:48 ` [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock() Peter Zijlstra
2008-08-04 21:32 ` David Miller
2008-08-04 18:06 ` Jeremy Fitzhardinge
2008-08-04 18:54 ` Peter Zijlstra
2008-08-04 19:26 ` Jeremy Fitzhardinge
2008-08-04 19:31 ` Linus Torvalds
2008-08-04 19:39 ` Peter Zijlstra
2008-08-04 20:16 ` Jeremy Fitzhardinge
2008-10-08 15:27 ` Steven Rostedt
2008-10-08 15:43 ` Linus Torvalds
2008-10-08 16:03 ` Steven Rostedt
2008-10-08 16:19 ` Linus Torvalds
2008-10-08 16:53 ` Steven Rostedt
2008-10-08 15:52 ` Nick Piggin
2008-10-08 17:18 ` Steven Rostedt
2008-08-07 11:25 ` Peter Zijlstra
2008-08-07 11:25 ` [RFC][PATCH 8/7] lockdep: annotate mm_take_all_locks() Peter Zijlstra
2008-08-07 11:25 ` [RFC][PATCH 9/7] mm: fix mm_take_all_locks() locking order Peter Zijlstra
2008-08-07 12:14 ` Hugh Dickins
2008-08-07 12:41 ` Peter Zijlstra
2008-08-07 13:27 ` Hugh Dickins
2008-08-07 21:46 ` Andrea Arcangeli
2008-08-08 1:34 ` Andrea Arcangeli
2008-08-08 7:16 ` Peter Zijlstra
2008-08-11 10:08 ` [RFC][PATCH 0/7] lockdep Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080804131012.076019775@chello.nl \
--to=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=davej@redhat.com \
--cc=davem@davemloft.net \
--cc=hugh@veritas.com \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox