From patchwork Fri Nov 13 14:02:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 1399830 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linutronix.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=mAtWeb03; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=G1UREJyG; dkim=fail reason="signature verification failed" header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=Qk1c/61D; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CXgn309Pdz9s1l for ; Sat, 14 Nov 2020 01:28:23 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:Subject:To:From:Date: Message-Id:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Owner; bh=KQSzh4eq+3S4d1EN89e51sJ+Qet6Qya9wAV7Ni649RE=; b=mAtWeb03bFFduSEveP2hCWSdw eXi2Z5lQoAEBSq5/oGT2c5m6TErC6ig07wKFyJ3tCOMxLtMsixkgUWV9vQ6k0HmBPRo915yy9qX9L Gadomt11k1qP75PSybG8dqA/RABIs2O9w+V1rWg7NKWq0VkRIjssAwhcaNjhih8GGe9ZYWMZhdAC6 /01EwVY+MyVl3SubGnhQjl+J9LAZsXMJsQiKMTLBXjUh10YFsF2uf+UQmTb1TgZwtfCL/+WShsT+u HnEqT/N/oumjHTF7iYMvnq6GpGyS5uR3YgNKrWuRN4OaQPg3BKFZpYTQODPXGS3x5DLEpLqCYv3eH nM6nb3HYw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kda3j-0008IP-M6; Fri, 13 Nov 2020 14:28:15 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kda0A-0006N6-54; Fri, 13 Nov 2020 14:24:43 +0000 Message-Id: <20201113141734.442990268@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1605277472; h=from:from: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: references:references; bh=Ze6MlncdnmAY8gfHx7Z+rZEVhWAMCevnsPTsGbdb6v0=; b=G1UREJyGcaUjT+N2wtoQyCERcLxyjyMAfw8NfT+wy0zwm0us+pf2Ntglv96NgSHbt9/Yjp qoaQCmQHCEZLSl4tgh2fObbzd5Eg0IzKsZOwRDqSmqku7HiNL3S3LkyTYUFx3yi5dSfTxu MFctcDrCS9gok9I097XT39eWW13m7iPU863iXCxWWkLue2i4sFBBOxeCX2J3FMIX3WJFOU XfnbdSiKjTIyQx4waIuiaRF6W5mUn7JksZs9HbxgKcANUpu5giQHMT3WvlrsVLnuu9ttOJ 05xVo+iYIedu+Z/p/XcxdBOfYtlbWlAMcmQFwZfDQFcdF0rqvP2z6Iy7H5Dc2A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1605277472; h=from:from: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: references:references; bh=Ze6MlncdnmAY8gfHx7Z+rZEVhWAMCevnsPTsGbdb6v0=; b=Qk1c/61DOVl3kFFVW+aZ3dXfkp84eaNY2QVxxJLj8d6ltQSfXPHHs0VNAwsQ94XeTMC/Dx 80Ju8vg9dueyHvAQ== Date: Fri, 13 Nov 2020 15:02:22 +0100 From: Thomas Gleixner To: LKML Subject: [patch 15/19] tick/sched: Prevent false positive softirq pending warnings on RT References: <20201113140207.499353218@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201113_092434_477079_C07F7142 X-CRM114-Status: GOOD ( 14.91 ) X-Spam-Score: -0.9 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [2a0a:51c0:0:12e:550:0:0:1 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Rich Felker , Catalin Marinas , Paul McKenney , Arnd Bergmann , linux-sh@vger.kernel.org, Peter Zijlstra , Richard Weinberger , Frederic Weisbecker , Valentin Schneider , Jeff Dike , Russell King , Yoshinori Sato , "James E.J. Bottomley" , linux-parisc@vger.kernel.org, Helge Deller , linux-um@lists.infradead.org, Will Deacon , Sebastian Andrzej Siewior , linux-arm-kernel@lists.infradead.org, Anton Ivanov Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org On RT a task which has soft interrupts disabled can block on a lock and schedule out to idle while soft interrupts are pending. This triggers the warning in the NOHZ idle code which complains about going idle with pending soft interrupts. But as the task is blocked soft interrupt processing is temporarily blocked as well which means that such a warning is a false positive. To prevent that check the per CPU state which indicates that a scheduled out task has soft interrupts disabled. Signed-off-by: Thomas Gleixner --- include/linux/bottom_half.h | 6 ++++++ kernel/softirq.c | 15 +++++++++++++++ kernel/time/tick-sched.c | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) --- a/include/linux/bottom_half.h +++ b/include/linux/bottom_half.h @@ -32,4 +32,10 @@ static inline void local_bh_enable(void) __local_bh_enable_ip(_THIS_IP_, SOFTIRQ_DISABLE_OFFSET); } +#ifdef CONFIG_PREEMPT_RT +extern bool local_bh_blocked(void); +#else +static inline bool local_bh_blocked(void) { return false; } +#endif + #endif /* _LINUX_BH_H */ --- a/kernel/softirq.c +++ b/kernel/softirq.c @@ -138,6 +138,21 @@ static DEFINE_PER_CPU(struct softirq_ctr .lock = INIT_LOCAL_LOCK(softirq_ctrl.lock), }; +/** + * local_bh_blocked() - Check for idle whether BH processing is blocked + * + * Returns false if the per CPU softirq::cnt is 0 otherwise true. + * + * This is invoked from the idle task to guard against false positive + * softirq pending warnings, which would happen when the task which holds + * softirq_ctrl::lock was the only running task on the CPU and blocks on + * some other lock. + */ +bool local_bh_blocked(void) +{ + return this_cpu_read(softirq_ctrl.cnt) != 0; +} + void __local_bh_disable_ip(unsigned long ip, unsigned int cnt) { unsigned long flags; --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -925,7 +925,7 @@ static bool can_stop_idle_tick(int cpu, if (unlikely(local_softirq_pending())) { static int ratelimit; - if (ratelimit < 10 && + if (ratelimit < 10 && !local_bh_blocked() && (local_softirq_pending() & SOFTIRQ_STOP_IDLE_MASK)) { pr_warn("NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #%02x!!!\n", (unsigned int) local_softirq_pending());