[PATCH v1 3/3] cpufreq: intel_pstate: Adjust frequency percentage computations

Rafael J. Wysocki posted 1 patch 4 days, 11 hours ago
drivers/cpufreq/intel_pstate.c |    8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
[PATCH v1 3/3] cpufreq: intel_pstate: Adjust frequency percentage computations
Posted by Rafael J. Wysocki 4 days, 11 hours ago
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Adjust frequency percentage computations in update_cpu_qos_request() to
avoid going above the exact numerical percentage in the FREQ_QOS_MAX
case.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/cpufreq/intel_pstate.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -1696,8 +1696,8 @@ unlock_driver:
 static void update_cpu_qos_request(int cpunum, enum freq_qos_req_type type)
 {
 	struct cpudata *cpu = all_cpu_data[cpunum];
+	unsigned int freq = cpu->pstate.turbo_freq;
 	struct freq_qos_request *req;
-	unsigned int freq, perf_pct;
 
 	struct cpufreq_policy *policy __free(put_cpufreq_policy) = cpufreq_cpu_get(cpunum);
 	if (!policy)
@@ -1711,14 +1711,12 @@ static void update_cpu_qos_request(int c
 		intel_pstate_get_hwp_cap(cpu);
 
 	if (type == FREQ_QOS_MIN) {
-		perf_pct = global.min_perf_pct;
+		freq = DIV_ROUND_UP(freq * global.min_perf_pct, 100);
 	} else {
 		req++;
-		perf_pct = global.max_perf_pct;
+		freq = (freq * global.max_perf_pct) / 100;
 	}
 
-	freq = DIV_ROUND_UP(cpu->pstate.turbo_freq * perf_pct, 100);
-
 	if (freq_qos_update_request(req, freq) < 0)
 		pr_warn("Failed to update freq constraint: CPU%d\n", cpunum);
 }
Re: [PATCH v1 3/3] cpufreq: intel_pstate: Adjust frequency percentage
Posted by Zihuan Zhang 2 days ago
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>  drivers/cpufreq/intel_pstate.c |    8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> --- a/drivers/cpufreq/intel_pstate.c
> +++ b/drivers/cpufreq/intel_pstate.c
> @@ -1696,8 +1696,8 @@ unlock_driver:
>  static void update_cpu_qos_request(int cpunum, enum freq_qos_req_type type)
>  {
>  	struct cpudata *cpu = all_cpu_data[cpunum];
> +	unsigned int freq = cpu->pstate.turbo_freq;
>  	struct freq_qos_request *req;
> -	unsigned int freq, perf_pct;
>  
>  	struct cpufreq_policy *policy __free(put_cpufreq_policy) = cpufreq_cpu_get(cpunum);
>  	if (!policy)
> @@ -1711,14 +1711,12 @@ static void update_cpu_qos_request(int c
>  		intel_pstate_get_hwp_cap(cpu);
>  
>  	if (type == FREQ_QOS_MIN) {
> -		perf_pct = global.min_perf_pct;
> +		freq = DIV_ROUND_UP(freq * global.min_perf_pct, 100);
>  	} else {
>  		req++;
> -		perf_pct = global.max_perf_pct;
> +		freq = (freq * global.max_perf_pct) / 100;
>  	}
>  
> -	freq = DIV_ROUND_UP(cpu->pstate.turbo_freq * perf_pct, 100);
> -
>  	if (freq_qos_update_request(req, freq) < 0)
>  		pr_warn("Failed to update freq constraint: CPU%d\n", cpunum);
>  }

Acked-by: Zihuan Zhang <zhangzihuan@kylinos.cn>