]> www.infradead.org Git - linux-platform-drivers-x86.git/commitdiff
tick/sched: Prevent false positive softirq pending warnings on RT
authorThomas Gleixner <tglx@linutronix.de>
Tue, 9 Mar 2021 08:55:57 +0000 (09:55 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 17 Mar 2021 15:34:11 +0000 (16:34 +0100)
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>
Tested-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Tested-by: Paul E. McKenney <paulmck@kernel.org>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20210309085727.527563866@linutronix.de
include/linux/bottom_half.h
kernel/softirq.c
kernel/time/tick-sched.c

index e4dd613a070e3c2465201e5c4b011dcdbd0aaec0..eed86eb0a1dea08a4f813537b198639730e87d45 100644 (file)
@@ -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 */
index 1ed1c55aa2a75bc1243116c047dd04c10e16d459..5a99696da86ac8fdd6d540a59f344f9859f4b530 100644 (file)
@@ -141,6 +141,21 @@ static DEFINE_PER_CPU(struct softirq_ctrl, softirq_ctrl) = {
        .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;
index e10a4af887373bc8a693b750fd27ff1e2460df3f..0cc55791b2b615979f0376386ffb5133a2e6ea71 100644 (file)
@@ -973,7 +973,7 @@ static bool can_stop_idle_tick(int cpu, struct tick_sched *ts)
        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());