linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nohz: Fix missing tick reprog while interrupting inline timer softirq
@ 2018-07-31 22:52 Frederic Weisbecker
  2018-08-01 12:03 ` Anna-Maria Gleixner
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Frederic Weisbecker @ 2018-07-31 22:52 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, Frederic Weisbecker, Ingo Molnar, Anna-Maria Gleixner

Before updating the full nohz tick or the idle time on IRQ exit, we
check first if we are not in a nesting interrupt, whether the inner
interrupt is a hard or a soft IRQ.

There is a historical reason for that: the dyntick idle mode used to
reprogram the tick on IRQ exit, after softirq processing, and there was
no point in doing that job in the outer nesting interrupt because the
tick update will be performed through the end of the inner interrupt
eventually, with even potential new timer updates.

One corner case could show up though: if an idle tick interrupts a softirq
executing inline in the idle loop (through a call to local_bh_enable())
after we entered in dynticks mode, the IRQ won't reprogram the tick
because it assumes the softirq executes on an inner IRQ-tail. As a
result we might put the CPU in sleep mode with the tick completely
stopped whereas a timer can still be enqueued. Indeed there is no tick
reprogramming in local_bh_enable(). We probably asssumed there was no bh
disabled section in idle, although there didn't seem to be debug code
ensuring that.

Nowadays the nesting interrupt optimization still stands but only concern
full dynticks. The tick is stopped on IRQ exit in full dynticks mode
and we want to wait for the end of the inner IRQ to reprogramm the tick.
But in_interrupt() doesn't make a difference between softirqs executing
on IRQ tail and those executing inline. What was to be considered a
corner case in dynticks-idle mode now becomes a serious opportunity for
a bug in full dynticks mode: if a tick interrupts a task executing
softirq inline, the tick reprogramming will be ignored and we may exit
to userspace after local_bh_enable() with an enqueued timer that will
never fire.

To fix this, simply keep reprogramming the tick if we are in a hardirq
interrupting softirq. We can still figure out a way later to restore
this optimization while excluding inline softirq processing.

Reported-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
---
 kernel/softirq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/softirq.c b/kernel/softirq.c
index 900dcfe..0980a81 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -386,7 +386,7 @@ static inline void tick_irq_exit(void)
 
 	/* Make sure that timer wheel updates are propagated */
 	if ((idle_cpu(cpu) && !need_resched()) || tick_nohz_full_cpu(cpu)) {
-		if (!in_interrupt())
+		if (!in_irq())
 			tick_nohz_irq_exit();
 	}
 #endif
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2018-08-30 14:29 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-31 22:52 [PATCH] nohz: Fix missing tick reprog while interrupting inline timer softirq Frederic Weisbecker
2018-08-01 12:03 ` Anna-Maria Gleixner
2018-08-01 17:46 ` Thomas Gleixner
2018-08-01 21:08   ` Frederic Weisbecker
2018-08-03 11:42     ` Thomas Gleixner
2018-08-23 22:57 ` Grygorii Strashko
2018-08-24  6:17   ` Greg KH
2018-08-24  7:01     ` Thomas Gleixner
2018-08-24 14:27       ` Frederic Weisbecker
2018-08-24 16:10       ` Grygorii Strashko
2018-08-24 18:41         ` Frederic Weisbecker
2018-08-28 17:56           ` Grygorii Strashko
2018-08-30 14:10             ` John Crispin
2018-08-30 14:29               ` Thomas Gleixner
2018-08-24 16:14     ` Grygorii Strashko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).