linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] cpufreq: intel_pstate: Force HWP min perf before offline
@ 2018-11-16 22:24 Srinivas Pandruvada
  2018-11-16 22:24 ` [PATCH 2/2] Documentation: intel_pstate: Clarify coordination of P-State limits Srinivas Pandruvada
  2018-12-11 10:46 ` [PATCH 1/2] cpufreq: intel_pstate: Force HWP min perf before offline Rafael J. Wysocki
  0 siblings, 2 replies; 3+ messages in thread
From: Srinivas Pandruvada @ 2018-11-16 22:24 UTC (permalink / raw)
  To: lenb, rjw, viresh.kumar, corbet
  Cc: linux-doc, linux-kernel, linux-pm, yu.c.chen, Srinivas Pandruvada

Force HWP Request MAX = HWP Request MIN = HWP Capability MIN and EPP to
0xFF. In this way the performance limits on the offlined CPU will not
influence performance limits on its sibling CPU, which is still online.

If the sibling CPU is calling for higher performance, it will impact the
max core performance. Here core performance will follow higher of the
performance requests from each sibling.

Reported-and-tested-by: Chen Yu <yu.c.chen@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 drivers/cpufreq/intel_pstate.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 14f551a3d36e..501ab9f4489a 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -830,6 +830,28 @@ static void intel_pstate_hwp_set(unsigned int cpu)
 	wrmsrl_on_cpu(cpu, MSR_HWP_REQUEST, value);
 }
 
+static void intel_pstate_hwp_force_min_perf(int cpu)
+{
+	u64 value;
+	int min_perf;
+
+	value = all_cpu_data[cpu]->hwp_req_cached;
+	value &= ~GENMASK_ULL(31, 0);
+	min_perf = HWP_LOWEST_PERF(all_cpu_data[cpu]->hwp_cap_cached);
+
+	/* Set hwp_max = hwp_min */
+	value |= HWP_MAX_PERF(min_perf);
+	value |= HWP_MIN_PERF(min_perf);
+
+	/* Set EPP/EPB to min */
+	if (static_cpu_has(X86_FEATURE_HWP_EPP))
+		value |= HWP_ENERGY_PERF_PREFERENCE(HWP_EPP_POWERSAVE);
+	else
+		intel_pstate_set_epb(cpu, HWP_EPP_BALANCE_POWERSAVE);
+
+	wrmsrl_on_cpu(cpu, MSR_HWP_REQUEST, value);
+}
+
 static int intel_pstate_hwp_save_state(struct cpufreq_policy *policy)
 {
 	struct cpudata *cpu_data = all_cpu_data[policy->cpu];
@@ -2093,10 +2115,12 @@ static void intel_pstate_stop_cpu(struct cpufreq_policy *policy)
 	pr_debug("CPU %d exiting\n", policy->cpu);
 
 	intel_pstate_clear_update_util_hook(policy->cpu);
-	if (hwp_active)
+	if (hwp_active) {
 		intel_pstate_hwp_save_state(policy);
-	else
+		intel_pstate_hwp_force_min_perf(policy->cpu);
+	} else {
 		intel_cpufreq_stop_cpu(policy);
+	}
 }
 
 static int intel_pstate_cpu_exit(struct cpufreq_policy *policy)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] Documentation: intel_pstate: Clarify coordination of P-State limits
  2018-11-16 22:24 [PATCH 1/2] cpufreq: intel_pstate: Force HWP min perf before offline Srinivas Pandruvada
@ 2018-11-16 22:24 ` Srinivas Pandruvada
  2018-12-11 10:46 ` [PATCH 1/2] cpufreq: intel_pstate: Force HWP min perf before offline Rafael J. Wysocki
  1 sibling, 0 replies; 3+ messages in thread
From: Srinivas Pandruvada @ 2018-11-16 22:24 UTC (permalink / raw)
  To: lenb, rjw, viresh.kumar, corbet
  Cc: linux-doc, linux-kernel, linux-pm, yu.c.chen, Srinivas Pandruvada

Explain influence of per-core P-states and hyper threading on the
effective performance.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 Documentation/admin-guide/pm/intel_pstate.rst | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/Documentation/admin-guide/pm/intel_pstate.rst b/Documentation/admin-guide/pm/intel_pstate.rst
index ac6f5c597a56..ec0f7c111f65 100644
--- a/Documentation/admin-guide/pm/intel_pstate.rst
+++ b/Documentation/admin-guide/pm/intel_pstate.rst
@@ -495,7 +495,15 @@ on the following rules, regardless of the current operation mode of the driver:
 
  2. Each individual CPU is affected by its own per-policy limits (that is, it
     cannot be requested to run faster than its own per-policy maximum and it
-    cannot be requested to run slower than its own per-policy minimum).
+    cannot be requested to run slower than its own per-policy minimum). The
+    effective performance depends on whether the platform supports per core
+    P-states, hyper-threading is enabled and on current performance requests
+    from other CPUs. When platform doesn't support per core P-states, the
+    effective performance can be more than the policy limits set on a CPU, if
+    other CPUs are requesting higher performance at that moment. Even with per
+    core P-states support, when hyper-threading is enabled, if the sibling CPU
+    is requesting higher performance, the other siblings will get higher
+    performance than their policy limits.
 
  3. The global and per-policy limits can be set independently.
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] cpufreq: intel_pstate: Force HWP min perf before offline
  2018-11-16 22:24 [PATCH 1/2] cpufreq: intel_pstate: Force HWP min perf before offline Srinivas Pandruvada
  2018-11-16 22:24 ` [PATCH 2/2] Documentation: intel_pstate: Clarify coordination of P-State limits Srinivas Pandruvada
@ 2018-12-11 10:46 ` Rafael J. Wysocki
  1 sibling, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2018-12-11 10:46 UTC (permalink / raw)
  To: Srinivas Pandruvada
  Cc: lenb, viresh.kumar, corbet, linux-doc, linux-kernel, linux-pm, yu.c.chen

On Friday, November 16, 2018 11:24:19 PM CET Srinivas Pandruvada wrote:
> Force HWP Request MAX = HWP Request MIN = HWP Capability MIN and EPP to
> 0xFF. In this way the performance limits on the offlined CPU will not
> influence performance limits on its sibling CPU, which is still online.
> 
> If the sibling CPU is calling for higher performance, it will impact the
> max core performance. Here core performance will follow higher of the
> performance requests from each sibling.
> 
> Reported-and-tested-by: Chen Yu <yu.c.chen@intel.com>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
>  drivers/cpufreq/intel_pstate.c | 28 ++++++++++++++++++++++++++--
>  1 file changed, 26 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
> index 14f551a3d36e..501ab9f4489a 100644
> --- a/drivers/cpufreq/intel_pstate.c
> +++ b/drivers/cpufreq/intel_pstate.c
> @@ -830,6 +830,28 @@ static void intel_pstate_hwp_set(unsigned int cpu)
>  	wrmsrl_on_cpu(cpu, MSR_HWP_REQUEST, value);
>  }
>  
> +static void intel_pstate_hwp_force_min_perf(int cpu)
> +{
> +	u64 value;
> +	int min_perf;
> +
> +	value = all_cpu_data[cpu]->hwp_req_cached;
> +	value &= ~GENMASK_ULL(31, 0);
> +	min_perf = HWP_LOWEST_PERF(all_cpu_data[cpu]->hwp_cap_cached);
> +
> +	/* Set hwp_max = hwp_min */
> +	value |= HWP_MAX_PERF(min_perf);
> +	value |= HWP_MIN_PERF(min_perf);
> +
> +	/* Set EPP/EPB to min */
> +	if (static_cpu_has(X86_FEATURE_HWP_EPP))
> +		value |= HWP_ENERGY_PERF_PREFERENCE(HWP_EPP_POWERSAVE);
> +	else
> +		intel_pstate_set_epb(cpu, HWP_EPP_BALANCE_POWERSAVE);
> +
> +	wrmsrl_on_cpu(cpu, MSR_HWP_REQUEST, value);
> +}
> +
>  static int intel_pstate_hwp_save_state(struct cpufreq_policy *policy)
>  {
>  	struct cpudata *cpu_data = all_cpu_data[policy->cpu];
> @@ -2093,10 +2115,12 @@ static void intel_pstate_stop_cpu(struct cpufreq_policy *policy)
>  	pr_debug("CPU %d exiting\n", policy->cpu);
>  
>  	intel_pstate_clear_update_util_hook(policy->cpu);
> -	if (hwp_active)
> +	if (hwp_active) {
>  		intel_pstate_hwp_save_state(policy);
> -	else
> +		intel_pstate_hwp_force_min_perf(policy->cpu);
> +	} else {
>  		intel_cpufreq_stop_cpu(policy);
> +	}
>  }
>  
>  static int intel_pstate_cpu_exit(struct cpufreq_policy *policy)
> 

Both this one and the [2/2] applied, thanks!


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-12-11 10:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-16 22:24 [PATCH 1/2] cpufreq: intel_pstate: Force HWP min perf before offline Srinivas Pandruvada
2018-11-16 22:24 ` [PATCH 2/2] Documentation: intel_pstate: Clarify coordination of P-State limits Srinivas Pandruvada
2018-12-11 10:46 ` [PATCH 1/2] cpufreq: intel_pstate: Force HWP min perf before offline Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).