@@ -922,6 +922,17 @@ void tick_nohz_idle_exit(void)
ts->inidle = 0;
+ /*
+ * ts->idle_active drives the idle time which typically elapses in the
+ * idle loop but breaks on IRQs interrupting idle loop.
+ *
+ * Hence ts->idle_active can be 1 here if we exit the idle loop without
+ * the help of an IRQ. OTOH it can be 0 on idle exit if a wake up IPI
+ * pulled the CPU out of the idle loop. Since we know that we'll be
+ * exiting the idle task after the wake up IPI, all the pending idle
+ * sleep time is flushed on irq entry and no more is accounted further
+ * thanks to the need_resched() check on irq_exit().
+ */
if (ts->idle_active || ts->tick_stopped)
now = ktime_get();