From: Giovanni Gherdovich <ggherdovich@suse.cz>
Date: Tue, 17 Dec 2019 10:23:09 +0100
Subject: cpufreq: intel_pstate: Revert upstream changes to iowait boosting
Patch-mainline: Never, upstream favours power consumption over performance
References: bsc#1131437
Revert the following two upstream changes:
b8bd1581aa6110eb234c0d424eccd3f32d7317e6 ("cpufreq: intel_pstate: Rework
iowait boosting to be less aggressive")
8e3b403954507eb74ad241dc3750443ccc9ee40a ("cpufreq: intel_pstate: Fix up
iowait_boost computation")
as they negatively affect benchmarks that depend on iowait boosting such as
dbench (table below). This regression was found with the Impera automated
bisection tool.
dbench results on hardy2:
initial first
good-v5.0 bad-b8bd1581
Amean 1 22.27 ( 0.00%) 36.94 ( -65.82%)
Amean 2 24.67 ( 0.00%) 39.91 ( -61.79%)
Amean 4 38.13 ( 0.00%) 47.25 ( -23.92%)
Amean 8 60.89 ( 0.00%) 64.44 ( -5.82%)
Amean 16 106.21 ( 0.00%) 109.80 ( -3.38%)
Amean 32 200.53 ( 0.00%) 215.62 ( -7.53%)
Amean 64 433.18 ( 0.00%) 452.34 ( -4.42%)
Amean 128 1103.80 ( 0.00%) 1206.91 ( -9.34%)
Stddev 1 3.69 ( 0.00%) 2.11 ( 42.98%)
Stddev 2 3.71 ( 0.00%) 3.83 ( -3.15%)
Stddev 4 6.95 ( 0.00%) 6.38 ( 8.20%)
Stddev 8 12.13 ( 0.00%) 12.33 ( -1.69%)
Stddev 16 20.71 ( 0.00%) 21.35 ( -3.08%)
Stddev 32 40.66 ( 0.00%) 44.32 ( -8.99%)
Stddev 64 80.36 ( 0.00%) 77.75 ( 3.25%)
Stddev 128 199.79 ( 0.00%) 210.81 ( -5.52%)
Signed-off-by: Giovanni Gherdovich <ggherdovich@suse.cz>
---
drivers/cpufreq/intel_pstate.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -46,8 +46,6 @@
#define int_tofp(X) ((int64_t)(X) << FRAC_BITS)
#define fp_toint(X) ((X) >> FRAC_BITS)
-#define ONE_EIGHTH_FP ((int64_t)1 << (FRAC_BITS - 3))
-
#define EXT_BITS 6
#define EXT_FRAC_BITS (EXT_BITS + FRAC_BITS)
#define fp_ext_toint(X) ((X) >> EXT_FRAC_BITS)
@@ -1709,14 +1707,17 @@ static inline int32_t get_avg_pstate(str
static inline int32_t get_target_pstate(struct cpudata *cpu)
{
struct sample *sample = &cpu->sample;
- int32_t busy_frac;
+ int32_t busy_frac, boost;
int target, avg_pstate;
busy_frac = div_fp(sample->mperf << cpu->aperf_mperf_shift,
sample->tsc);
- if (busy_frac < cpu->iowait_boost)
- busy_frac = cpu->iowait_boost;
+ boost = cpu->iowait_boost;
+ cpu->iowait_boost >>= 1;
+
+ if (busy_frac < boost)
+ busy_frac = boost;
sample->busy_scaled = busy_frac * 100;
@@ -1793,30 +1794,29 @@ static void intel_pstate_update_util(str
if (smp_processor_id() != cpu->cpu)
return;
- delta_ns = time - cpu->last_update;
if (flags & SCHED_CPUFREQ_IOWAIT) {
- /* Start over if the CPU may have been idle. */
- if (delta_ns > TICK_NSEC) {
- cpu->iowait_boost = ONE_EIGHTH_FP;
- } else if (cpu->iowait_boost >= ONE_EIGHTH_FP) {
- cpu->iowait_boost <<= 1;
- if (cpu->iowait_boost > int_tofp(1))
- cpu->iowait_boost = int_tofp(1);
- } else {
- cpu->iowait_boost = ONE_EIGHTH_FP;
- }
+ cpu->iowait_boost = int_tofp(1);
+ cpu->last_update = time;
+ /*
+ * The last time the busy was 100% so P-state was max anyway
+ * so avoid overhead of computation.
+ */
+ if (fp_toint(cpu->sample.busy_scaled) == 100)
+ return;
+
+ goto set_pstate;
} else if (cpu->iowait_boost) {
/* Clear iowait_boost if the CPU may have been idle. */
+ delta_ns = time - cpu->last_update;
if (delta_ns > TICK_NSEC)
cpu->iowait_boost = 0;
- else
- cpu->iowait_boost >>= 1;
}
cpu->last_update = time;
delta_ns = time - cpu->sample.time;
if ((s64)delta_ns < INTEL_PSTATE_SAMPLING_INTERVAL)
return;
+set_pstate:
if (intel_pstate_sample(cpu, time))
intel_pstate_adjust_pstate(cpu);
}