From: Giovanni Gherdovich <ggherdovich@suse.cz>
Date: Mon, 27 Sep 2021 11:53:55 +0200
Subject: cpufreq: intel_pstate: Revert upstream default governor selection for no-HWP, use "powersave"
Patch-mainline: Never, upstream is promoting schedutil but there is a notable performance regression
References: bsc#1190923

Commit 33aa46f252c7 ("cpufreq: intel_pstate: Use passive mode by default
without HWP"), merged in v5.8, makes Intel CPUs default to the cpufreq driver
intel_cpufreq (and to the schedutil governor) if they don't support the HWP
feature.

The driver/governor combination intel_cpufreq/schedutil lags behind
intel_pstate/powersave on the tbench benchmark. Averaging the data over the
entire benchmark space (all client configurations), the magnitude of the
regression is 15-20%. The detailed results table shows the performance loss to
be larger at low client count (>50%). This happens with both the SLES variant
of "powersave" and the upstream "powersave" version used as baseline.

For this reason in SLE-15-SP4 we keep intel_pstate/powersave as the default
driver/governor for Intel CPUs.

Benchmark results follow.

machine: hardy2
- - - - - - - -
cpu microarchitecture: broadwell
num. of cores/num. of threads: 40/80 (2 sockets, NUMA)
memory: 512G

benchmark: tbench
benchmark metric: throughput
unit: MB/sec (higher is better)

			   SLE-15-SP4             SLE-15-SP4
	   # clients intel_pstate/powersave intel_cpufreq/schedutil
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Hmean     1        454.34 (   0.00%)      198.13  * -56.39%*
    Hmean     2        835.67 (   0.00%)      721.53  * -13.66%*
    Hmean     4       1504.73 (   0.00%)     1484.73  *  -1.33%*
    Hmean     8       3020.01 (   0.00%)     2831.87  *  -6.23%*
    Hmean     16      5593.74 (   0.00%)     5197.86  *  -7.08%*
    Hmean     32      9268.30 (   0.00%)     9193.41  *  -0.81%*
    Hmean     64     10225.84 (   0.00%)     8622.36  * -15.68%*
    Hmean     128    19136.90 (   0.00%)    18854.68  *  -1.47%*
    Hmean     256    17807.42 (   0.00%)    18261.05  *   2.55%*
    Hmean     320    17815.25 (   0.00%)    17764.12  *  -0.29%*
    CoeffVar  1          0.77 (   0.00%)       25.94 (-3258.04%)
    CoeffVar  2          0.52 (   0.00%)       13.69 (-2522.87%)
    CoeffVar  4          0.22 (   0.00%)        1.69 ( -680.97%)
    CoeffVar  8          0.07 (   0.00%)        3.45 (-4994.48%)
    CoeffVar  16         0.11 (   0.00%)        0.28 ( -157.89%)
    CoeffVar  32         0.15 (   0.00%)        0.11 (   30.35%)
    CoeffVar  64         0.10 (   0.00%)        6.08 (-5994.02%)
    CoeffVar  128        0.40 (   0.00%)        0.28 (   29.56%)
    CoeffVar  256        0.44 (   0.00%)        0.44 (   -0.53%)
    CoeffVar  320        0.20 (   0.00%)        0.17 (   15.27%)

machine: marvin2
- - - - - - - -
cpu microarchitecture: haswell
num. of cores/num. of threads: 24/48 (2 sockets, NUMA)
memory: 64G

benchmark: tbench
benchmark metric: throughput
unit: MB/sec (higher is better)

			   SLE-15-SP4             SLE-15-SP4
	   # clients intel_pstate/powersave intel_cpufreq/schedutil
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Hmean     1        433.09 (   0.00%)      166.95 * -61.45%*
    Hmean     2        783.82 (   0.00%)      527.04 * -32.76%*
    Hmean     4       1525.04 (   0.00%)     1044.83 * -31.49%*
    Hmean     8       2952.05 (   0.00%)     2582.26 * -12.53%*
    Hmean     16      4775.06 (   0.00%)     4540.16 *  -4.92%*
    Hmean     32      5653.20 (   0.00%)     5617.98 *  -0.62%*
    Hmean     64     10315.77 (   0.00%)    10097.58 *  -2.12%*
    Hmean     128     9675.56 (   0.00%)     9414.71 *  -2.70%*
    Hmean     192     9542.68 (   0.00%)     9371.17 *  -1.80%*
    CoeffVar  1          0.92 (   0.00%)        0.29 (  68.98%)
    CoeffVar  2          0.86 (   0.00%)        5.59 (-546.44%)
    CoeffVar  4          0.89 (   0.00%)        3.10 (-248.03%)
    CoeffVar  8          0.22 (   0.00%)        0.30 ( -36.99%)
    CoeffVar  16         0.21 (   0.00%)        0.56 (-162.63%)
    CoeffVar  32         0.13 (   0.00%)        0.31 (-147.55%)
    CoeffVar  64         0.04 (   0.00%)        0.05 ( -24.01%)
    CoeffVar  128        0.14 (   0.00%)        0.17 ( -24.02%)
    CoeffVar  192        0.12 (   0.00%)        0.15 ( -23.28%)

Acked-by: Giovanni Gherdovich <ggherdovich@suse.cz>
---
 drivers/cpufreq/intel_pstate.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -3329,7 +3329,7 @@ static int __init intel_pstate_init(void
 	}
 	/* Without HWP start in the passive mode. */
 	if (!default_driver)
-		default_driver = &intel_cpufreq;
+		default_driver = &intel_pstate;
 
 hwp_cpu_matched:
 	/*
