From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D40B8C433F1 for ; Wed, 24 Mar 2021 07:23:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BAD3C61A03 for ; Wed, 24 Mar 2021 07:23:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235953AbhCXHXL (ORCPT ); Wed, 24 Mar 2021 03:23:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235829AbhCXHWc (ORCPT ); Wed, 24 Mar 2021 03:22:32 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBD02C0613DB; Wed, 24 Mar 2021 00:22:31 -0700 (PDT) Date: Wed, 24 Mar 2021 07:22:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1616570547; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xExuxbajKnozwYQkd1phRCEtqiLRViNaiB3MpSc/obM=; b=Q1mDFTWsysHS70efdiCDfqRPjiBXa7Xm0/5uv4YW76wUFtT8wPsuVTGEdEeb/CfAPdYapn xMzhH8S0kr4v4Gu7iLGNOCY2RyOk0XEH6eCiFm+94LTSrwRTzCL0c/JAoLiB43+mPJunK8 xobAldWqsTjXxfhhatHY50KzXH0TWf1KulbBEMVK9yd3QIxiEEYl+m2xGvMcU0SfVuOdmS 2Ljs8NVKr3jZB4rVlJk3rsUKuQ0fS5jZ/W/Gx3kzFL7yp1EYaF/EIir93oPOd0bCSlI/Qr B9Z6AZoDVMukt9qM91xzPttAJYFoCKelvEKuB1MKE+K+TcrPorSp+H7w0AeMKw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1616570547; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xExuxbajKnozwYQkd1phRCEtqiLRViNaiB3MpSc/obM=; b=QqXIWQBD3Vj9WUF/1oCHtneL2xlrAM7zx83rL0uTJuuxJDPFknkvju9bb36PVW1YE+cc1o 3VmS8fc8BVmrxWCA== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] locking/rtmutex: Restrict the trylock WARN_ON() to debug Cc: Thomas Gleixner , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20210323213708.908341972@linutronix.de> References: <20210323213708.908341972@linutronix.de> MIME-Version: 1.0 Message-ID: <161657054714.398.11163755719025601580.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the locking/core branch of tip: Commit-ID: 3ac7d0ecf0e18b44c2c7dc968ce5afc5beadf17c Gitweb: https://git.kernel.org/tip/3ac7d0ecf0e18b44c2c7dc968ce5afc5beadf17c Author: Thomas Gleixner AuthorDate: Tue, 23 Mar 2021 22:30:33 +01:00 Committer: Ingo Molnar CommitterDate: Wed, 24 Mar 2021 08:08:16 +01:00 locking/rtmutex: Restrict the trylock WARN_ON() to debug The warning as written is expensive and not really required for a production kernel. Make it depend on rt mutex debugging and use !in_task() for the condition which generates far better code and gives the same answer. Signed-off-by: Thomas Gleixner Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20210323213708.908341972@linutronix.de --- kernel/locking/rtmutex.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c index bece7aa..d584e32 100644 --- a/kernel/locking/rtmutex.c +++ b/kernel/locking/rtmutex.c @@ -1495,9 +1495,8 @@ int __sched __rt_mutex_futex_trylock(struct rt_mutex *lock) * * @lock: the rt_mutex to be locked * - * This function can only be called in thread context. It's safe to - * call it from atomic regions, but not from hard interrupt or soft - * interrupt context. + * This function can only be called in thread context. It's safe to call it + * from atomic regions, but not from hard or soft interrupt context. * * Returns 1 on success and 0 on contention */ @@ -1505,7 +1504,7 @@ int __sched rt_mutex_trylock(struct rt_mutex *lock) { int ret; - if (WARN_ON_ONCE(in_irq() || in_nmi() || in_serving_softirq())) + if (IS_ENABLED(CONFIG_RT_MUTEX_DEBUG) && WARN_ON_ONCE(!in_task())) return 0; ret = rt_mutex_fasttrylock(lock, rt_mutex_slowtrylock);