timers: Do not IPI for deferrable timers
authorAnna-Maria Behnsen <anna-maria@linutronix.de>
Fri, 1 Dec 2023 09:26:28 +0000 (10:26 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 20 Dec 2023 15:49:38 +0000 (16:49 +0100)
Deferrable timers do not prevent CPU from going idle and are not taken into
account on idle path. Sending an IPI to a remote CPU when a new first
deferrable timer was enqueued will wake up the remote CPU but nothing will
be done regarding the deferrable timers.

Drop IPI completely when a new first deferrable timer was enqueued.

Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://lore.kernel.org/r/20231201092654.34614-7-anna-maria@linutronix.de
kernel/time/timer.c

index ed8d6063d9efe2dbbd74ca3aed4d6aa3fde855d8..91882059bf3d04790d875acd9b2f7872aabc3082 100644 (file)
@@ -571,18 +571,15 @@ static int calc_wheel_index(unsigned long expires, unsigned long clk,
 static void
 trigger_dyntick_cpu(struct timer_base *base, struct timer_list *timer)
 {
-       if (!is_timers_nohz_active())
-               return;
-
        /*
-        * TODO: This wants some optimizing similar to the code below, but we
-        * will do that when we switch from push to pull for deferrable timers.
+        * Deferrable timers do not prevent the CPU from entering dynticks and
+        * are not taken into account on the idle/nohz_full path. An IPI when a
+        * new deferrable timer is enqueued will wake up the remote CPU but
+        * nothing will be done with the deferrable timer base. Therefore skip
+        * the remote IPI for deferrable timers completely.
         */
-       if (timer->flags & TIMER_DEFERRABLE) {
-               if (tick_nohz_full_cpu(base->cpu))
-                       wake_up_nohz_cpu(base->cpu);
+       if (!is_timers_nohz_active() || timer->flags & TIMER_DEFERRABLE)
                return;
-       }
 
        /*
         * We might have to IPI the remote CPU if the base is idle and the