aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2011-05-24 20:12:03 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-05-25 11:39:17 -0400
commite4c70a6629f9c74c4b0de258a3951890e9047c82 (patch)
treeaac3502b1fa1ed0f53d290aa1a18b9ce493c5a6b /include/linux
parente303297e6c3a7b847c4731eb14006ca6b435ecca (diff)
lockdep, mutex: provide mutex_lock_nest_lock
In order to convert i_mmap_lock to a mutex we need a mutex equivalent to spin_lock_nest_lock(), thus provide the mutex_lock_nest_lock() annotation. As with spin_lock_nest_lock(), mutex_lock_nest_lock() allows annotation of the locking pattern where an outer lock serializes the acquisition order of nested locks. That is, if every time you lock multiple locks A, say A1 and A2 you first acquire N, the order of acquiring A1 and A2 is irrelevant. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: David Miller <davem@davemloft.net> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Russell King <rmk@arm.linux.org.uk> Cc: Paul Mundt <lethal@linux-sh.org> Cc: Jeff Dike <jdike@addtoit.com> Cc: Richard Weinberger <richard@nod.at> Cc: Tony Luck <tony.luck@intel.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Hugh Dickins <hughd@google.com> Cc: Mel Gorman <mel@csn.ul.ie> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: Nick Piggin <npiggin@kernel.dk> Cc: Namhyung Kim <namhyung@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/lockdep.h3
-rw-r--r--include/linux/mutex.h9
2 files changed, 12 insertions, 0 deletions
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 4aef1dda6406..ef820a3c378b 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -487,12 +487,15 @@ static inline void print_irqtrace_events(struct task_struct *curr)
487#ifdef CONFIG_DEBUG_LOCK_ALLOC 487#ifdef CONFIG_DEBUG_LOCK_ALLOC
488# ifdef CONFIG_PROVE_LOCKING 488# ifdef CONFIG_PROVE_LOCKING
489# define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, NULL, i) 489# define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, NULL, i)
490# define mutex_acquire_nest(l, s, t, n, i) lock_acquire(l, s, t, 0, 2, n, i)
490# else 491# else
491# define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, NULL, i) 492# define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, NULL, i)
493# define mutex_acquire_nest(l, s, t, n, i) lock_acquire(l, s, t, 0, 1, n, i)
492# endif 494# endif
493# define mutex_release(l, n, i) lock_release(l, n, i) 495# define mutex_release(l, n, i) lock_release(l, n, i)
494#else 496#else
495# define mutex_acquire(l, s, t, i) do { } while (0) 497# define mutex_acquire(l, s, t, i) do { } while (0)
498# define mutex_acquire_nest(l, s, t, n, i) do { } while (0)
496# define mutex_release(l, n, i) do { } while (0) 499# define mutex_release(l, n, i) do { } while (0)
497#endif 500#endif
498 501
diff --git a/include/linux/mutex.h b/include/linux/mutex.h
index c75471db576e..a940fe435aca 100644
--- a/include/linux/mutex.h
+++ b/include/linux/mutex.h
@@ -132,6 +132,7 @@ static inline int mutex_is_locked(struct mutex *lock)
132 */ 132 */
133#ifdef CONFIG_DEBUG_LOCK_ALLOC 133#ifdef CONFIG_DEBUG_LOCK_ALLOC
134extern void mutex_lock_nested(struct mutex *lock, unsigned int subclass); 134extern void mutex_lock_nested(struct mutex *lock, unsigned int subclass);
135extern void _mutex_lock_nest_lock(struct mutex *lock, struct lockdep_map *nest_lock);
135extern int __must_check mutex_lock_interruptible_nested(struct mutex *lock, 136extern int __must_check mutex_lock_interruptible_nested(struct mutex *lock,
136 unsigned int subclass); 137 unsigned int subclass);
137extern int __must_check mutex_lock_killable_nested(struct mutex *lock, 138extern int __must_check mutex_lock_killable_nested(struct mutex *lock,
@@ -140,6 +141,13 @@ extern int __must_check mutex_lock_killable_nested(struct mutex *lock,
140#define mutex_lock(lock) mutex_lock_nested(lock, 0) 141#define mutex_lock(lock) mutex_lock_nested(lock, 0)
141#define mutex_lock_interruptible(lock) mutex_lock_interruptible_nested(lock, 0) 142#define mutex_lock_interruptible(lock) mutex_lock_interruptible_nested(lock, 0)
142#define mutex_lock_killable(lock) mutex_lock_killable_nested(lock, 0) 143#define mutex_lock_killable(lock) mutex_lock_killable_nested(lock, 0)
144
145#define mutex_lock_nest_lock(lock, nest_lock) \
146do { \
147 typecheck(struct lockdep_map *, &(nest_lock)->dep_map); \
148 _mutex_lock_nest_lock(lock, &(nest_lock)->dep_map); \
149} while (0)
150
143#else 151#else
144extern void mutex_lock(struct mutex *lock); 152extern void mutex_lock(struct mutex *lock);
145extern int __must_check mutex_lock_interruptible(struct mutex *lock); 153extern int __must_check mutex_lock_interruptible(struct mutex *lock);
@@ -148,6 +156,7 @@ extern int __must_check mutex_lock_killable(struct mutex *lock);
148# define mutex_lock_nested(lock, subclass) mutex_lock(lock) 156# define mutex_lock_nested(lock, subclass) mutex_lock(lock)
149# define mutex_lock_interruptible_nested(lock, subclass) mutex_lock_interruptible(lock) 157# define mutex_lock_interruptible_nested(lock, subclass) mutex_lock_interruptible(lock)
150# define mutex_lock_killable_nested(lock, subclass) mutex_lock_killable(lock) 158# define mutex_lock_killable_nested(lock, subclass) mutex_lock_killable(lock)
159# define mutex_lock_nest_lock(lock, nest_lock) mutex_lock(lock)
151#endif 160#endif
152 161
153/* 162/*