Skip to content

Commit fa3fa55

Browse files
committed
cpuidle: governors: menu: Avoid using invalid recent intervals data
Marc has reported that commit 85975da ("cpuidle: menu: Avoid discarding useful information") caused the number of wakeup interrupts to increase on an idle system [1], which was not expected to happen after merely allowing shallower idle states to be selected by the governor in some cases. However, on the system in question, all of the idle states deeper than WFI are rejected by the driver due to a firmware issue [2]. This causes the governor to only consider the recent interval duriation data corresponding to attempts to enter WFI that are successful and the recent invervals table is filled with values lower than the scheduler tick period. Consequently, the governor predicts an idle duration below the scheduler tick period length and avoids stopping the tick more often which leads to the observed symptom. Address it by modifying the governor to update the recent intervals table also when entering the previously selected idle state fails, so it knows that the short idle intervals might have been the minority had the selected idle states been actually entered every time. Fixes: 85975da ("cpuidle: menu: Avoid discarding useful information") Link: https://lore.kernel.org/linux-pm/[email protected]/ [1] Link: https://lore.kernel.org/linux-pm/[email protected]/ [2] Signed-off-by: Rafael J. Wysocki <[email protected]> Tested-by: Christian Loehle <[email protected]> Tested-by: Marc Zyngier <[email protected]> Reviewed-by: Christian Loehle <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent e91a158 commit fa3fa55

File tree

1 file changed

+17
-4
lines changed
  • drivers/cpuidle/governors

1 file changed

+17
-4
lines changed

drivers/cpuidle/governors/menu.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ static inline int which_bucket(u64 duration_ns)
9797

9898
static DEFINE_PER_CPU(struct menu_device, menu_devices);
9999

100+
static void menu_update_intervals(struct menu_device *data, unsigned int interval_us)
101+
{
102+
/* Update the repeating-pattern data. */
103+
data->intervals[data->interval_ptr++] = interval_us;
104+
if (data->interval_ptr >= INTERVALS)
105+
data->interval_ptr = 0;
106+
}
107+
100108
static void menu_update(struct cpuidle_driver *drv, struct cpuidle_device *dev);
101109

102110
/*
@@ -222,6 +230,14 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
222230
if (data->needs_update) {
223231
menu_update(drv, dev);
224232
data->needs_update = 0;
233+
} else if (!dev->last_residency_ns) {
234+
/*
235+
* This happens when the driver rejects the previously selected
236+
* idle state and returns an error, so update the recent
237+
* intervals table to prevent invalid information from being
238+
* used going forward.
239+
*/
240+
menu_update_intervals(data, UINT_MAX);
225241
}
226242

227243
/* Find the shortest expected idle interval. */
@@ -482,10 +498,7 @@ static void menu_update(struct cpuidle_driver *drv, struct cpuidle_device *dev)
482498

483499
data->correction_factor[data->bucket] = new_factor;
484500

485-
/* update the repeating-pattern data */
486-
data->intervals[data->interval_ptr++] = ktime_to_us(measured_ns);
487-
if (data->interval_ptr >= INTERVALS)
488-
data->interval_ptr = 0;
501+
menu_update_intervals(data, ktime_to_us(measured_ns));
489502
}
490503

491504
/**

0 commit comments

Comments
 (0)