Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1823123imm; Mon, 3 Sep 2018 10:21:04 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbyzjUslOgnnqSTX4tpINz1j6/VgCLD8sh7jnvW+KpMZUUY/ceHNhJjBXOzfZrg9gcZ7PUc X-Received: by 2002:a65:608b:: with SMTP id t11-v6mr12796244pgu.259.1535995263957; Mon, 03 Sep 2018 10:21:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535995263; cv=none; d=google.com; s=arc-20160816; b=oPYVwuh33minORMhCiXr/fTvMi4lPC6d1ymAp4e4FcoxgscM8WvL4RHsa+OWEv2v86 3lNb4ERhIPePR8Fyp2uDvLOjGLugawZSTvaw/k95QeHy8PhBvN+25FQwm0cS4UxRu9sk eplJqe20mf3rZEzihzmnOwoUiYP7vZhzA+NHWKfFd3msNz3tl91szlvyw72EY7Jlwj7V SNqZV90s0j0eHZYCvV6b4cJ9w8y1RdoekqbLtI2lzw9qdDSpOGSfCnA+tTVsJ8jteP5+ hdIfWi68iwu9Hy5hmx2VqaHS/v0NuWVnTYZAaAjR2X9fdo9jpz+55BzgBZElZl4uAb/2 iyvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=y19womZszAz7s3AUtxKG8bFoQrVhQLU28cdIFqBrPqk=; b=UYcDP3W6tkOC6u6LmOQDm+mptxCCfa7+MzbriLfWLy9g+ORxVwSMs2LdiI7FkJnjjA ZbpIO4hgbsVYwAeLyDQN3Cb8jQXvcHuJoSG8bgEaIbjZp1Su4l2Zso/QCbs1b5/NPMZE 6S41akTtIrfRslmurXZ7u0BCHGlz3BVst9AkShPmmLsJUNTOpMC2ByS2RqBtPfBMVixd 7smnxvN9i0xT+uGMRyjlFxDXX4IzdFPN0AKH2gBE1h3nAokOpPcDusXm1rpwZSrtIHbE j5DxDralwB2f0EvnzVFney55q0OL6kG4NWLQ5PBVyGzfcLYMS45nta++fFQVWDlpspI3 xPow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s126-v6si20042085pfc.222.2018.09.03.10.20.48; Mon, 03 Sep 2018 10:21:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730185AbeICVik (ORCPT + 99 others); Mon, 3 Sep 2018 17:38:40 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:42822 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729157AbeICVij (ORCPT ); Mon, 3 Sep 2018 17:38:39 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 476E1D09; Mon, 3 Sep 2018 17:17:34 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John Sperbeck , Peter Rosin , "Peter Zijlstra (Intel)" , Davidlohr Bueso , Deepa Dinamani , Linus Torvalds , Peter Chang , Philippe Ombredanne , Thomas Gleixner , Will Deacon , Wolfram Sang , Ingo Molnar , Sasha Levin Subject: [PATCH 4.14 047/165] locking/rtmutex: Allow specifying a subclass for nested locking Date: Mon, 3 Sep 2018 18:55:33 +0200 Message-Id: <20180903165657.485495108@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180903165655.003605184@linuxfoundation.org> References: <20180903165655.003605184@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Peter Rosin [ Upstream commit 62cedf3e60af03e47849fe2bd6a03ec179422a8a ] Needed for annotating rt_mutex locks. Tested-by: John Sperbeck Signed-off-by: Peter Rosin Signed-off-by: Peter Zijlstra (Intel) Cc: Davidlohr Bueso Cc: Deepa Dinamani Cc: Greg Kroah-Hartman Cc: Linus Torvalds Cc: Peter Chang Cc: Peter Zijlstra Cc: Philippe Ombredanne Cc: Thomas Gleixner Cc: Will Deacon Cc: Wolfram Sang Link: http://lkml.kernel.org/r/20180720083914.1950-2-peda@axentia.se Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- 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