diff mbox

[V5,2/4] Optimize calculation for max/min_perf_adj

Message ID 1457249646-23072-3-git-send-email-philippe.longepe@linux.intel.com (mailing list archive)
State Accepted, archived
Delegated to: Rafael Wysocki
Headers show

Commit Message

plongepe March 6, 2016, 7:34 a.m. UTC
mul_fp(int_tofp(A), B) expands to:
((A << FRAC_BITS) * B) >> FRAC_BITS, so the same result can be obtained
via simple multiplication A * B.  Apply this observation to
max_perf * limits->max_perf and max_perf * limits->min_perf in
intel_pstate_get_min_max()."

Signed-off-by: Philippe Longepe <philippe.longepe@linux.intel.com>
---
 drivers/cpufreq/intel_pstate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

srinivas pandruvada March 7, 2016, 9:35 p.m. UTC | #1
On Sun, 2016-03-06 at 08:34 +0100, Philippe Longepe wrote:
> mul_fp(int_tofp(A), B) expands to:
> ((A << FRAC_BITS) * B) >> FRAC_BITS, so the same result can be
> obtained
> via simple multiplication A * B.  Apply this observation to
> max_perf * limits->max_perf and max_perf * limits->min_perf in
> intel_pstate_get_min_max()."
> 
> Signed-off-by: Philippe Longepe <philippe.longepe@linux.intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

> ---
>  drivers/cpufreq/intel_pstate.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cpufreq/intel_pstate.c
> b/drivers/cpufreq/intel_pstate.c
> index 114e4e0..c46d23a 100644
> --- a/drivers/cpufreq/intel_pstate.c
> +++ b/drivers/cpufreq/intel_pstate.c
> @@ -828,11 +828,11 @@ static void intel_pstate_get_min_max(struct
> cpudata *cpu, int *min, int *max)
>  	 * policy, or by cpu specific default values determined
> through
>  	 * experimentation.
>  	 */
> -	max_perf_adj = fp_toint(mul_fp(int_tofp(max_perf), limits-
> >max_perf));
> +	max_perf_adj = fp_toint(max_perf * limits->max_perf);
>  	*max = clamp_t(int, max_perf_adj,
>  			cpu->pstate.min_pstate, cpu-
> >pstate.turbo_pstate);
>  
> -	min_perf = fp_toint(mul_fp(int_tofp(max_perf), limits-
> >min_perf));
> +	min_perf = fp_toint(max_perf * limits->min_perf);
>  	*min = clamp_t(int, min_perf, cpu->pstate.min_pstate,
> max_perf);
>  }
>  
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 114e4e0..c46d23a 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -828,11 +828,11 @@  static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max)
 	 * policy, or by cpu specific default values determined through
 	 * experimentation.
 	 */
-	max_perf_adj = fp_toint(mul_fp(int_tofp(max_perf), limits->max_perf));
+	max_perf_adj = fp_toint(max_perf * limits->max_perf);
 	*max = clamp_t(int, max_perf_adj,
 			cpu->pstate.min_pstate, cpu->pstate.turbo_pstate);
 
-	min_perf = fp_toint(mul_fp(int_tofp(max_perf), limits->min_perf));
+	min_perf = fp_toint(max_perf * limits->min_perf);
 	*min = clamp_t(int, min_perf, cpu->pstate.min_pstate, max_perf);
 }