@@ -286,14 +286,26 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
unsigned int predicted_us;
unsigned long nr_iowaiters;
ktime_t delta_next;
+ ktime_t now = ktime_get();
+ ktime_t next_hrtimer = tick_nohz_get_next_hrtimer();
+ ktime_t next_timer = tick_nohz_get_next_timer();
if (data->needs_update) {
menu_update(drv, dev);
data->needs_update = 0;
}
- /* determine the expected residency time, round up */
- data->next_timer_us = ktime_to_us(tick_nohz_get_sleep_length(&delta_next));
+ /*
+ * Compute the duration before the next timer, whatever the origin
+ */
+ delta_next = ktime_sub(next_timer, now);
+ data->next_timer_us = ktime_to_us(delta_next);
+
+ /*
+ * Compute the duration before next hrtimer which is the tick
+ * or an earliest hrtimer
+ */
+ delta_next = ktime_sub(next_hrtimer, now);
nr_iowaiters = nr_iowait_cpu(dev->cpu);
data->bucket = which_bucket(data->next_timer_us, nr_iowaiters);