From: Thomas Gleixner Date: Fri, 26 Mar 2021 15:29:43 +0000 (+0100) Subject: locking/rtmutex: Restrict the trylock WARN_ON() to debug X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=c2c360ed7f28fd6b7eb7e39e70af2d2ae405f466;p=linux.git 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 Acked-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/r/20210326153944.436565064@linutronix.de --- diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c index 512b400bd9618..c68542dbbd0a7 100644 --- a/kernel/locking/rtmutex.c +++ b/kernel/locking/rtmutex.c @@ -1456,7 +1456,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_DEBUG_RT_MUTEXES) && WARN_ON_ONCE(!in_task())) return 0; /*