[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <161657054714.398.11163755719025601580.tip-bot2@tip-bot2>
Date: Wed, 24 Mar 2021 07:22:27 -0000
From: "tip-bot2 for Thomas Gleixner" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...nel.org>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: locking/core] locking/rtmutex: Restrict the trylock WARN_ON() to debug
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 <tglx@...utronix.de>
AuthorDate: Tue, 23 Mar 2021 22:30:33 +01:00
Committer: Ingo Molnar <mingo@...nel.org>
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 <tglx@...utronix.de>
Signed-off-by: Ingo Molnar <mingo@...nel.org>
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);
Powered by blists - more mailing lists