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
2044 * timer_base_try_to_set_idle() - Try to set the idle state of the timer bases2044 * timer_base_try_to_set_idle() - Try to set the idle state of the timer bases
2045 * @basej: base time jiffies2045 * @basej: base time jiffies
2046 * @basem: base time clock monotonic2046 * @basem: base time clock monotonic
2047 * @idle: pointer to store the value of timer_base->is_idle2047 * @idle: pointer to store the value of timer_base->is_idle on return;
2048 * *idle contains the information whether tick was already stopped
2048 *2049 *
2049 * Returns the tick aligned clock monotonic time of the next pending2050 * Returns the tick aligned clock monotonic time of the next pending timer or
2050 * timer or KTIME_MAX if no timer is pending.2051 * KTIME_MAX if no timer is pending. When tick was already stopped KTIME_MAX is
2052 * returned as well.
2051 */2053 */
2052u64 timer_base_try_to_set_idle(unsigned long basej, u64 basem, bool *idle)2054u64 timer_base_try_to_set_idle(unsigned long basej, u64 basem, bool *idle)
2053{2055{
2056 if (*idle)
2057 return KTIME_MAX;
2058
2054 return __get_next_timer_interrupt(basej, basem, idle);2059 return __get_next_timer_interrupt(basej, basem, idle);
2055}2060}
2056 2061