timers: Only wake softirq if necessary
[cascardo/linux.git] / kernel / time / timer.c
index 9339d71..8d830f1 100644 (file)
@@ -1608,7 +1608,18 @@ static void run_timer_softirq(struct softirq_action *h)
  */
 void run_local_timers(void)
 {
+       struct timer_base *base = this_cpu_ptr(&timer_bases[BASE_STD]);
+
        hrtimer_run_queues();
+       /* Raise the softirq only if required. */
+       if (time_before(jiffies, base->clk)) {
+               if (!IS_ENABLED(CONFIG_NO_HZ_COMMON) || !base->nohz_active)
+                       return;
+               /* CPU is awake, so check the deferrable base. */
+               base++;
+               if (time_before(jiffies, base->clk))
+                       return;
+       }
        raise_softirq(TIMER_SOFTIRQ);
 }