All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Marc Zyngier <maz@kernel.org>, Rich Felker <dalias@libc.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Paul McKenney <paulmck@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
	linux-sh@vger.kernel.org, Peter Zijlstra <peterz@infradead.org>,
	Richard Weinberger <richard@nod.at>,
	Frederic Weisbecker <frederic@kernel.org>,
	Valentin Schneider <valentin.schneider@arm.com>,
	Jeff Dike <jdike@addtoit.com>,
	Russell King <linux@armlinux.org.uk>,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	linux-parisc@vger.kernel.org, Helge Deller <deller@gmx.de>,
	linux-um@lists.infradead.org, Will Deacon <will@kernel.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	linux-arm-kernel@lists.infradead.org,
	Anton Ivanov <anton.ivanov@cambridgegreys.com>
Subject: [patch 15/19] tick/sched: Prevent false positive softirq pending warnings on RT
Date: Fri, 13 Nov 2020 14:02:22 +0000	[thread overview]
Message-ID: <20201113141734.442990268@linutronix.de> (raw)
In-Reply-To: 20201113140207.499353218@linutronix.de

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 <tglx@linutronix.de>
---
 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());

WARNING: multiple messages have this Message-ID (diff)
From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Frederic Weisbecker <frederic@kernel.org>,
	Paul McKenney <paulmck@kernel.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Arnd Bergmann <arnd@arndb.de>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	Helge Deller <deller@gmx.de>,
	linux-parisc@vger.kernel.org,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	Rich Felker <dalias@libc.org>,
	linux-sh@vger.kernel.org, Jeff Dike <jdike@addtoit.com>,
	Richard Weinberger <richard@nod.at>,
	Anton Ivanov <anton.ivanov@cambridgegreys.com>,
	linux-um@lists.infradead.org,
	Russell King <linux@armlinux.org.uk>,
	Marc Zyngier <maz@kernel.org>,
	Valentin Schneider <valentin.schneider@arm.com>,
	linux-arm-kernel@lists.infradead.org,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>
Subject: [patch 15/19] tick/sched: Prevent false positive softirq pending warnings on RT
Date: Fri, 13 Nov 2020 15:02:22 +0100	[thread overview]
Message-ID: <20201113141734.442990268@linutronix.de> (raw)
In-Reply-To: 20201113140207.499353218@linutronix.de

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 <tglx@linutronix.de>
---
 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());


WARNING: multiple messages have this Message-ID (diff)
From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Marc Zyngier <maz@kernel.org>, Rich Felker <dalias@libc.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Paul McKenney <paulmck@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
	linux-sh@vger.kernel.org, Peter Zijlstra <peterz@infradead.org>,
	Richard Weinberger <richard@nod.at>,
	Frederic Weisbecker <frederic@kernel.org>,
	Valentin Schneider <valentin.schneider@arm.com>,
	Jeff Dike <jdike@addtoit.com>,
	Russell King <linux@armlinux.org.uk>,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	linux-parisc@vger.kernel.org, Helge Deller <deller@gmx.de>,
	linux-um@lists.infradead.org, Will Deacon <will@kernel.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	linux-arm-kernel@lists.infradead.org,
	Anton Ivanov <anton.ivanov@cambridgegreys.com>
Subject: [patch 15/19] tick/sched: Prevent false positive softirq pending warnings on RT
Date: Fri, 13 Nov 2020 15:02:22 +0100	[thread overview]
Message-ID: <20201113141734.442990268@linutronix.de> (raw)
In-Reply-To: 20201113140207.499353218@linutronix.de

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 <tglx@linutronix.de>
---
 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());


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2020-11-13 14:02 UTC|newest]

Thread overview: 136+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-13 14:02 [patch 00/19] softirq: Cleanups and RT awareness Thomas Gleixner
2020-11-13 14:02 ` Thomas Gleixner
2020-11-13 14:02 ` Thomas Gleixner
2020-11-13 14:02 ` [patch 01/19] parisc: Remove bogus __IRQ_STAT macro Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-23 22:51   ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2020-11-13 14:02 ` [patch 02/19] sh: Get rid of nmi_count() Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-23 22:51   ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2021-01-01 14:27   ` [patch 02/19] " John Paul Adrian Glaubitz
2021-01-01 14:27     ` John Paul Adrian Glaubitz
2021-01-01 14:27     ` John Paul Adrian Glaubitz
2020-11-13 14:02 ` [patch 03/19] irqstat: Get rid of nmi_count() and __IRQ_STAT() Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-23 22:51   ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2020-11-13 14:02 ` [patch 04/19] um/irqstat: Get rid of the duplicated declarations Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-23 22:51   ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2020-11-13 14:02 ` [patch 05/19] ARM: irqstat: Get rid of duplicated declaration Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-16 18:19   ` Valentin Schneider
2020-11-16 18:19     ` Valentin Schneider
2020-11-16 18:19     ` Valentin Schneider
2020-11-23 22:51   ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2020-11-13 14:02 ` [patch 06/19] arm64: " Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-16 10:01   ` Will Deacon
2020-11-16 10:01     ` Will Deacon
2020-11-16 10:01     ` Will Deacon
2020-11-16 10:01     ` Will Deacon
2020-11-16 10:51   ` Marc Zyngier
2020-11-16 10:51     ` Marc Zyngier
2020-11-16 10:51     ` Marc Zyngier
2020-11-23 22:51   ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2020-11-13 14:02 ` [patch 07/19] asm-generic/irqstat: Add optional __nmi_count member Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-23 22:51   ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2020-11-13 14:02 ` [patch 08/19] sh: irqstat: Use the generic irq_cpustat_t Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-23 22:51   ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2020-11-13 14:02 ` [patch 09/19] irqstat: Move declaration into asm-generic/hardirq.h Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-23 22:51   ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2020-11-13 14:02 ` [patch 10/19] preempt: Cleanup the macro maze a bit Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-16 12:17   ` Peter Zijlstra
2020-11-16 12:17     ` Peter Zijlstra
2020-11-16 12:17     ` Peter Zijlstra
2020-11-16 12:17     ` Peter Zijlstra
2020-11-16 17:42     ` Thomas Gleixner
2020-11-16 17:42       ` Thomas Gleixner
2020-11-16 17:42       ` Thomas Gleixner
2020-11-17 10:21       ` Peter Zijlstra
2020-11-17 10:21         ` Peter Zijlstra
2020-11-17 10:21         ` Peter Zijlstra
2020-11-23 22:51   ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2020-11-13 14:02 ` [patch 11/19] softirq: Move related code into one section Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-19 12:20   ` Frederic Weisbecker
2020-11-19 12:20     ` Frederic Weisbecker
2020-11-23 22:51   ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2020-11-13 14:02 ` [patch 12/19] softirq: Add RT specific softirq accounting Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-19 12:18   ` Frederic Weisbecker
2020-11-19 12:18     ` Frederic Weisbecker
2020-11-19 12:18     ` Frederic Weisbecker
2020-11-19 18:34     ` Thomas Gleixner
2020-11-19 18:34       ` Thomas Gleixner
2020-11-19 18:34       ` Thomas Gleixner
2020-11-19 22:52       ` Frederic Weisbecker
2020-11-19 22:52         ` Frederic Weisbecker
2020-11-13 14:02 ` [patch 13/19] softirq: Move various protections into inline helpers Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02 ` [patch 14/19] softirq: Make softirq control and processing RT aware Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-20  0:26   ` Frederic Weisbecker
2020-11-20  0:26     ` Frederic Weisbecker
2020-11-20  0:26     ` Frederic Weisbecker
2020-11-20 13:27     ` Thomas Gleixner
2020-11-20 13:27       ` Thomas Gleixner
2020-11-20 13:27       ` Thomas Gleixner
2020-11-23 13:44   ` Frederic Weisbecker
2020-11-23 13:44     ` Frederic Weisbecker
2020-11-23 13:44     ` Frederic Weisbecker
2020-11-23 19:27     ` Thomas Gleixner
2020-11-23 19:27       ` Thomas Gleixner
2020-11-23 19:56       ` Frederic Weisbecker
2020-11-23 19:56         ` Frederic Weisbecker
2020-11-23 19:56         ` Frederic Weisbecker
2020-11-23 23:58       ` Frederic Weisbecker
2020-11-23 23:58         ` Frederic Weisbecker
2020-11-23 23:58         ` Frederic Weisbecker
2020-11-24  0:06         ` Thomas Gleixner
2020-11-24  0:06           ` Thomas Gleixner
2020-11-24  0:06           ` Thomas Gleixner
2020-11-24  0:13           ` Frederic Weisbecker
2020-11-24  0:13             ` Frederic Weisbecker
2020-11-24  0:13             ` Frederic Weisbecker
2020-11-24  0:22             ` Thomas Gleixner
2020-11-24  0:22               ` Thomas Gleixner
2020-11-24  0:22               ` Thomas Gleixner
2020-11-13 14:02 ` Thomas Gleixner [this message]
2020-11-13 14:02   ` [patch 15/19] tick/sched: Prevent false positive softirq pending warnings on RT Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02 ` [patch 16/19] rcu: Prevent false positive softirq warning " Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02 ` [patch 17/19] softirq: Replace barrier() with cpu_relax() in tasklet_unlock_wait() Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02 ` [patch 18/19] tasklets: Use static inlines for stub implementations Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02 ` [patch 19/19] tasklets: Prevent kill/unlock_wait deadlock on RT Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner
2020-11-13 14:02   ` Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201113141734.442990268@linutronix.de \
    --to=tglx@linutronix.de \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=anton.ivanov@cambridgegreys.com \
    --cc=arnd@arndb.de \
    --cc=bigeasy@linutronix.de \
    --cc=catalin.marinas@arm.com \
    --cc=dalias@libc.org \
    --cc=deller@gmx.de \
    --cc=frederic@kernel.org \
    --cc=jdike@addtoit.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=linux-um@lists.infradead.org \
    --cc=linux@armlinux.org.uk \
    --cc=maz@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=richard@nod.at \
    --cc=valentin.schneider@arm.com \
    --cc=will@kernel.org \
    --cc=ysato@users.sourceforge.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.