Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpuidle: Add decaying history logic to menu idle predictor

Add decaying history of predicted idle time, instead of using the last early
wakeup. This logic helps menu governor do better job of predicting idle time.

With this change, we also measured noticable (~8%) power savings on
a DP server system with CPUs supporting deep C states, when system
was lightly loaded. There was no change to power or perf on other load
conditions.

Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>

authored by

Pallipadi, Venkatesh and committed by
Len Brown
816bb611 4a6908a3

+9 -1
+9 -1
drivers/cpuidle/governors/menu.c
··· 15 15 #include <linux/tick.h> 16 16 17 17 #define BREAK_FUZZ 4 /* 4 us */ 18 + #define PRED_HISTORY_PCT 50 18 19 19 20 struct menu_device { 20 21 int last_state_idx; 21 22 22 23 unsigned int expected_us; 23 24 unsigned int predicted_us; 25 + unsigned int current_predicted_us; 24 26 unsigned int last_measured_us; 25 27 unsigned int elapsed_us; 26 28 }; ··· 48 46 /* determine the expected residency time */ 49 47 data->expected_us = 50 48 (u32) ktime_to_ns(tick_nohz_get_sleep_length()) / 1000; 49 + 50 + /* Recalculate predicted_us based on prediction_history_pct */ 51 + data->predicted_us *= PRED_HISTORY_PCT; 52 + data->predicted_us += (100 - PRED_HISTORY_PCT) * 53 + data->current_predicted_us; 54 + data->predicted_us /= 100; 51 55 52 56 /* find the deepest idle state that satisfies our constraints */ 53 57 for (i = CPUIDLE_DRIVER_STATE_START + 1; i < dev->state_count; i++) { ··· 105 97 measured_us = -1; 106 98 107 99 /* Predict time until next break event */ 108 - data->predicted_us = max(measured_us, data->last_measured_us); 100 + data->current_predicted_us = max(measured_us, data->last_measured_us); 109 101 110 102 if (last_idle_us + BREAK_FUZZ < 111 103 data->expected_us - target->exit_latency) {