From patchwork Mon Mar 23 15:20:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 1260113 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48mJPN3WZVz9sR4 for ; Tue, 24 Mar 2020 02:35:52 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linutronix.de Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48mJPN0XQvzDqbq for ; Tue, 24 Mar 2020 02:35:52 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=linutronix.de (client-ip=2a0a:51c0:0:12e:550::1; helo=galois.linutronix.de; envelope-from=bigeasy@linutronix.de; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA256 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48mJ461jHyzDqkp for ; Tue, 24 Mar 2020 02:20:54 +1100 (AEDT) Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1jGOsF-000148-59; Mon, 23 Mar 2020 16:20:19 +0100 Date: Mon, 23 Mar 2020 16:20:19 +0100 From: Sebastian Siewior To: Thomas Gleixner Subject: [PATCH] completion: Use lockdep_assert_RT_in_threaded_ctx() in complete_all() Message-ID: <20200323152019.4qjwluldohuh3by5@linutronix.de> References: <20200321112544.878032781@linutronix.de> <20200321113242.317954042@linutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200321113242.317954042@linutronix.de> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Randy Dunlap , linux-ia64@vger.kernel.org, Peter Zijlstra , linux-pci@vger.kernel.org, Oleg Nesterov , Guo Ren , Joel Fernandes , Vincent Chen , Ingo Molnar , Jonathan Corbet , Davidlohr Bueso , linux-acpi@vger.kernel.org, Brian Cain , Davidlohr Bueso , "Paul E . McKenney" , linux-hexagon@vger.kernel.org, "Rafael J. Wysocki" , linux-csky@vger.kernel.org, Linus Torvalds , Darren Hart , Zhang Rui , Len Brown , Fenghua Yu , Arnd Bergmann , linux-pm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Greentime Hu , Bjorn Helgaas , Kurt Schwemmer , platform-driver-x86@vger.kernel.org, Kalle Valo , kbuild test robot , Felipe Balbi , Michal Simek , Tony Luck , Nick Hu , Geoff Levand , netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-wireless@vger.kernel.org, LKML , Greg Kroah-Hartman , Logan Gunthorpe , "David S. Miller" , Andy Shevchenko Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" The warning was intended to spot complete_all() users from hardirq context on PREEMPT_RT. The warning as-is will also trigger in interrupt handlers, which are threaded on PREEMPT_RT, which was not intended. Use lockdep_assert_RT_in_threaded_ctx() which triggers in non-preemptive context on PREEMPT_RT. Suggested-by: Peter Zijlstra Reported-by: kernel test robot Signed-off-by: Sebastian Andrzej Siewior --- include/linux/lockdep.h | 15 +++++++++++++++ kernel/sched/completion.c | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index 425b4ceb7cd07..206774ac69460 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -711,6 +711,21 @@ do { \ # define lockdep_assert_in_irq() do { } while (0) #endif +#ifdef CONFIG_PROVE_RAW_LOCK_NESTING + +# define lockdep_assert_RT_in_threaded_ctx() do { \ + WARN_ONCE(debug_locks && !current->lockdep_recursion && \ + current->hardirq_context && \ + !(current->hardirq_threaded || current->irq_config), \ + "Not in threaded context on PREEMPT_RT as expected\n"); \ +} while (0) + +#else + +# define lockdep_assert_RT_in_threaded_ctx() do { } while (0) + +#endif + #ifdef CONFIG_LOCKDEP void lockdep_rcu_suspicious(const char *file, const int line, const char *s); #else diff --git a/kernel/sched/completion.c b/kernel/sched/completion.c index f15e96164ff1e..a778554f9dad7 100644 --- a/kernel/sched/completion.c +++ b/kernel/sched/completion.c @@ -58,7 +58,7 @@ void complete_all(struct completion *x) { unsigned long flags; - WARN_ON(irqs_disabled()); + lockdep_assert_RT_in_threaded_ctx(); raw_spin_lock_irqsave(&x->wait.lock, flags); x->done = UINT_MAX;