diff options
author | Peter Rosin <peda@axentia.se> | 2018-07-20 04:39:13 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2018-07-25 05:22:19 -0400 |
commit | 62cedf3e60af03e47849fe2bd6a03ec179422a8a (patch) | |
tree | 59dad6e595452aa0a96442424e481b768771eda8 | |
parent | d72e90f33aa4709ebecc5005562f52335e106a60 (diff) |
locking/rtmutex: Allow specifying a subclass for nested locking
Needed for annotating rt_mutex locks.
Tested-by: John Sperbeck <jsperbeck@google.com>
Signed-off-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Deepa Dinamani <deepadinamani@google.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Chang <dpf@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
Link: http://lkml.kernel.org/r/20180720083914.1950-2-peda@axentia.se
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | include/linux/rtmutex.h | 7 | ||||
-rw-r--r-- | kernel/locking/rtmutex.c | 29 |
2 files changed, 32 insertions, 4 deletions
diff --git a/include/linux/rtmutex.h b/include/linux/rtmutex.h index 1b92a28dd672..6fd615a0eea9 100644 --- a/include/linux/rtmutex.h +++ b/include/linux/rtmutex.h | |||
@@ -106,7 +106,14 @@ static inline int rt_mutex_is_locked(struct rt_mutex *lock) | |||
106 | extern void __rt_mutex_init(struct rt_mutex *lock, const char *name, struct lock_class_key *key); | 106 | extern void __rt_mutex_init(struct rt_mutex *lock, const char *name, struct lock_class_key *key); |
107 | extern void rt_mutex_destroy(struct rt_mutex *lock); | 107 | extern void rt_mutex_destroy(struct rt_mutex *lock); |
108 | 108 | ||
109 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
110 | extern void rt_mutex_lock_nested(struct rt_mutex *lock, unsigned int subclass); | ||
111 | #define rt_mutex_lock(lock) rt_mutex_lock_nested(lock, 0) | ||
112 | #else | ||
109 | extern void rt_mutex_lock(struct rt_mutex *lock); | 113 | extern void rt_mutex_lock(struct rt_mutex *lock); |
114 | #define rt_mutex_lock_nested(lock, subclass) rt_mutex_lock(lock) | ||
115 | #endif | ||
116 | |||
110 | extern int rt_mutex_lock_interruptible(struct rt_mutex *lock); | 117 | extern int rt_mutex_lock_interruptible(struct rt_mutex *lock); |
111 | extern int rt_mutex_timed_lock(struct rt_mutex *lock, | 118 | extern int rt_mutex_timed_lock(struct rt_mutex *lock, |
112 | struct hrtimer_sleeper *timeout); | 119 | struct hrtimer_sleeper *timeout); |
diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c index 4f014be7a4b8..2823d4163a37 100644 --- a/kernel/locking/rtmutex.c +++ b/kernel/locking/rtmutex.c | |||
@@ -1465,6 +1465,29 @@ rt_mutex_fastunlock(struct rt_mutex *lock, | |||
1465 | rt_mutex_postunlock(&wake_q); | 1465 | rt_mutex_postunlock(&wake_q); |
1466 | } | 1466 | } |
1467 | 1467 | ||
1468 | static inline void __rt_mutex_lock(struct rt_mutex *lock, unsigned int subclass) | ||
1469 | { | ||
1470 | might_sleep(); | ||
1471 | |||
1472 | mutex_acquire(&lock->dep_map, subclass, 0, _RET_IP_); | ||
1473 | rt_mutex_fastlock(lock, TASK_UNINTERRUPTIBLE, rt_mutex_slowlock); | ||
1474 | } | ||
1475 | |||
1476 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
1477 | /** | ||
1478 | * rt_mutex_lock_nested - lock a rt_mutex | ||
1479 | * | ||
1480 | * @lock: the rt_mutex to be locked | ||
1481 | * @subclass: the lockdep subclass | ||
1482 | */ | ||
1483 | void __sched rt_mutex_lock_nested(struct rt_mutex *lock, unsigned int subclass) | ||
1484 | { | ||
1485 | __rt_mutex_lock(lock, subclass); | ||
1486 | } | ||
1487 | EXPORT_SYMBOL_GPL(rt_mutex_lock_nested); | ||
1488 | #endif | ||
1489 | |||
1490 | #ifndef CONFIG_DEBUG_LOCK_ALLOC | ||
1468 | /** | 1491 | /** |
1469 | * rt_mutex_lock - lock a rt_mutex | 1492 | * rt_mutex_lock - lock a rt_mutex |
1470 | * | 1493 | * |
@@ -1472,12 +1495,10 @@ rt_mutex_fastunlock(struct rt_mutex *lock, | |||
1472 | */ | 1495 | */ |
1473 | void __sched rt_mutex_lock(struct rt_mutex *lock) | 1496 | void __sched rt_mutex_lock(struct rt_mutex *lock) |
1474 | { | 1497 | { |
1475 | might_sleep(); | 1498 | __rt_mutex_lock(lock, 0); |
1476 | |||
1477 | mutex_acquire(&lock->dep_map, 0, 0, _RET_IP_); | ||
1478 | rt_mutex_fastlock(lock, TASK_UNINTERRUPTIBLE, rt_mutex_slowlock); | ||
1479 | } | 1499 | } |
1480 | EXPORT_SYMBOL_GPL(rt_mutex_lock); | 1500 | EXPORT_SYMBOL_GPL(rt_mutex_lock); |
1501 | #endif | ||
1481 | 1502 | ||
1482 | /** | 1503 | /** |
1483 | * rt_mutex_lock_interruptible - lock a rt_mutex interruptible | 1504 | * rt_mutex_lock_interruptible - lock a rt_mutex interruptible |