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

Showing the changes to kernel/time/timer.c (1 of 2 files). Show all

Unified · Split

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