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().
Unified · Split
| @@ -896,7 +896,7 @@ static void tick_nohz_stop_tick(struct tick_sched *ts, int cpu) · 895 unmodified lines | |||
| 896 | struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev); | 896 | struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev); |
| 897 | unsigned long basejiff = ts->last_jiffies; | 897 | unsigned long basejiff = ts->last_jiffies; |
| 898 | u64 basemono = ts->timer_expires_base; | 898 | u64 basemono = ts->timer_expires_base; |
| 899 | bool timer_idle; | 899 | bool timer_idle = ts->tick_stopped; |
| 900 | u64 expires; | 900 | u64 expires; |
| 901 | 901 | ||
| 902 | /* Make sure we won't be trying to stop it twice in a row. */ | 902 | /* Make sure we won't be trying to stop it twice in a row. */ |
| @@ -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 bases | 2044 | * timer_base_try_to_set_idle() - Try to set the idle state of the timer bases |
| 2045 | * @basej: base time jiffies | 2045 | * @basej: base time jiffies |
| 2046 | * @basem: base time clock monotonic | 2046 | * @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 | ||
| 2048 | * | 2049 | * |
| 2049 | * Returns the tick aligned clock monotonic time of the next pending | 2050 | * 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 | */ |
| 2052 | u64 timer_base_try_to_set_idle(unsigned long basej, u64 basem, bool *idle) | 2054 | u64 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 | ||