lkml.org 
[lkml]   [2018]   [Sep]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.14 047/165] locking/rtmutex: Allow specifying a subclass for nested locking
    Date
    4.14-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Peter Rosin <peda@axentia.se>

    [ Upstream commit 62cedf3e60af03e47849fe2bd6a03ec179422a8a ]

    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>
    Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    include/linux/rtmutex.h | 7 +++++++
    kernel/locking/rtmutex.c | 29 +++++++++++++++++++++++++----
    2 files changed, 32 insertions(+), 4 deletions(-)

    --- a/include/linux/rtmutex.h
    +++ b/include/linux/rtmutex.h
    @@ -106,7 +106,14 @@ static inline int rt_mutex_is_locked(str
    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);
    --- a/kernel/locking/rtmutex.c
    +++ b/kernel/locking/rtmutex.c
    @@ -1466,6 +1466,29 @@ rt_mutex_fastunlock(struct rt_mutex *loc
    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
    *
    @@ -1473,12 +1496,10 @@ rt_mutex_fastunlock(struct rt_mutex *loc
    */
    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

    \
     
     \ /
      Last update: 2018-09-03 19:22    [W:4.586 / U:0.220 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site