From: tip-bot for Peter Rosin <tipbot@zytor.com> To: linux-tip-commits@vger.kernel.org Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org, peda@axentia.se, mingo@kernel.org, gregkh@linuxfoundation.org, will.deacon@arm.com, wsa@the-dreams.de, deepadinamani@google.com, dave@stgolabs.net, peterz@infradead.org, torvalds@linux-foundation.org, jsperbeck@google.com, hpa@zytor.com, dpf@google.com, pombredanne@nexb.com Subject: [tip:locking/urgent] locking/rtmutex: Allow specifying a subclass for nested locking Date: Wed, 25 Jul 2018 07:18:59 -0700 [thread overview] Message-ID: <tip-62cedf3e60af03e47849fe2bd6a03ec179422a8a@git.kernel.org> (raw) In-Reply-To: <20180720083914.1950-2-peda@axentia.se> Commit-ID: 62cedf3e60af03e47849fe2bd6a03ec179422a8a Gitweb: https://git.kernel.org/tip/62cedf3e60af03e47849fe2bd6a03ec179422a8a Author: Peter Rosin <peda@axentia.se> AuthorDate: Fri, 20 Jul 2018 10:39:13 +0200 Committer: Ingo Molnar <mingo@kernel.org> CommitDate: Wed, 25 Jul 2018 11:22:19 +0200 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> --- include/linux/rtmutex.h | 7 +++++++ 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) extern void __rt_mutex_init(struct rt_mutex *lock, const char *name, struct lock_class_key *key); extern void rt_mutex_destroy(struct rt_mutex *lock); +#ifdef CONFIG_DEBUG_LOCK_ALLOC +extern void rt_mutex_lock_nested(struct rt_mutex *lock, unsigned int subclass); +#define rt_mutex_lock(lock) rt_mutex_lock_nested(lock, 0) +#else extern void rt_mutex_lock(struct rt_mutex *lock); +#define rt_mutex_lock_nested(lock, subclass) rt_mutex_lock(lock) +#endif + extern int rt_mutex_lock_interruptible(struct rt_mutex *lock); extern int rt_mutex_timed_lock(struct rt_mutex *lock, 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, rt_mutex_postunlock(&wake_q); } +static inline void __rt_mutex_lock(struct rt_mutex *lock, unsigned int subclass) +{ + might_sleep(); + + mutex_acquire(&lock->dep_map, subclass, 0, _RET_IP_); + rt_mutex_fastlock(lock, TASK_UNINTERRUPTIBLE, rt_mutex_slowlock); +} + +#ifdef CONFIG_DEBUG_LOCK_ALLOC +/** + * rt_mutex_lock_nested - lock a rt_mutex + * + * @lock: the rt_mutex to be locked + * @subclass: the lockdep subclass + */ +void __sched rt_mutex_lock_nested(struct rt_mutex *lock, unsigned int subclass) +{ + __rt_mutex_lock(lock, subclass); +} +EXPORT_SYMBOL_GPL(rt_mutex_lock_nested); +#endif + +#ifndef CONFIG_DEBUG_LOCK_ALLOC /** * rt_mutex_lock - lock a rt_mutex * @@ -1472,12 +1495,10 @@ rt_mutex_fastunlock(struct rt_mutex *lock, */ void __sched rt_mutex_lock(struct rt_mutex *lock) { - might_sleep(); - - mutex_acquire(&lock->dep_map, 0, 0, _RET_IP_); - rt_mutex_fastlock(lock, TASK_UNINTERRUPTIBLE, rt_mutex_slowlock); + __rt_mutex_lock(lock, 0); } EXPORT_SYMBOL_GPL(rt_mutex_lock); +#endif /** * rt_mutex_lock_interruptible - lock a rt_mutex interruptible
next prev parent reply other threads:[~2018-07-25 14:19 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-07-20 8:39 [PATCH v4 0/2] Fix lockdep warning with nested instances of i2c-mux Peter Rosin 2018-07-20 8:39 ` [PATCH v4 1/2] rtmutex: allow specifying a subclass for nested locking Peter Rosin 2018-07-25 14:18 ` tip-bot for Peter Rosin [this message] 2018-09-10 23:27 ` Steven Rostedt 2018-09-11 0:58 ` Peter Rosin 2018-07-20 8:39 ` [PATCH v4 2/2] i2c: mux: annotate the nested rt_mutex usage Peter Rosin 2018-07-25 14:19 ` [tip:locking/urgent] i2c/mux, locking/core: Annotate " tip-bot for Peter Rosin 2018-07-30 16:09 ` Peter Rosin 2018-07-30 17:17 ` 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=tip-62cedf3e60af03e47849fe2bd6a03ec179422a8a@git.kernel.org \ --to=tipbot@zytor.com \ --cc=dave@stgolabs.net \ --cc=deepadinamani@google.com \ --cc=dpf@google.com \ --cc=gregkh@linuxfoundation.org \ --cc=hpa@zytor.com \ --cc=jsperbeck@google.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-tip-commits@vger.kernel.org \ --cc=mingo@kernel.org \ --cc=peda@axentia.se \ --cc=peterz@infradead.org \ --cc=pombredanne@nexb.com \ --cc=tglx@linutronix.de \ --cc=torvalds@linux-foundation.org \ --cc=will.deacon@arm.com \ --cc=wsa@the-dreams.de \ --subject='Re: [tip:locking/urgent] locking/rtmutex: Allow specifying a subclass for nested locking' \ /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
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.