History

timers: Optimization for timer_base_try_to_set_idle()

When tick is stopped also the timer base is_idle flag is set. When reentering timer_base_try_to_set_idle() with the tick stopped, there is no need to check whether the timer base needs to be set idle again. When a timer was enqueued in the meantime, this is already handled by the tick_nohz_next_event() call which was executed before tick_nohz_stop_tick().

Anna-Maria Behnsen committed 2 years ago

Commit 73129cf1 parent e2e1d722 files · +9 −4Browse files

Unified · Split

2 files
  1. kernel/time/tick-sched.c +1 −1
  2. kernel/time/timer.c +8 −3
kernel/time/tick-sched.c+1−1
@@ -896,7 +896,7 @@ static void tick_nohz_stop_tick(struct tick_sched *ts, int cpu) · 895 unmodified lines
896896 struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev);
897897 unsigned long basejiff = ts->last_jiffies;
898898 u64 basemono = ts->timer_expires_base;
899− bool timer_idle;
899+ bool timer_idle = ts->tick_stopped;
900900 u64 expires;
901901
902902 /* Make sure we won't be trying to stop it twice in a row. */
kernel/time/timer.c+8−3
@@ -2044,13 +2044,18 @@ u64 get_next_timer_interrupt(unsigned long basej, u64 basem) · 2043 unmodified lines
20442044 * timer_base_try_to_set_idle() - Try to set the idle state of the timer bases
20452045 * @basej: base time jiffies
20462046 * @basem: base time clock monotonic
2047− * @idle: pointer to store the value of timer_base->is_idle
2047+ * @idle: pointer to store the value of timer_base->is_idle on return;
2048+ * *idle contains the information whether tick was already stopped
20482049 *
2049− * Returns the tick aligned clock monotonic time of the next pending
2050− * timer or KTIME_MAX if no timer is pending.
2050+ * Returns the tick aligned clock monotonic time of the next pending timer or
2051+ * KTIME_MAX if no timer is pending. When tick was already stopped KTIME_MAX is
2052+ * returned as well.
20512053 */
20522054 u64 timer_base_try_to_set_idle(unsigned long basej, u64 basem, bool *idle)
20532055 {
2056+ if (*idle)
2057+ return KTIME_MAX;
2058+
20542059 return __get_next_timer_interrupt(basej, basem, idle);
20552060 }
20562061