All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cpufreq: intel_pstate: Fix ratio setting for min_perf_pct
@ 2017-07-10 23:23 Srinivas Pandruvada
  2017-07-12 21:32 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Srinivas Pandruvada @ 2017-07-10 23:23 UTC (permalink / raw)
  To: rjw; +Cc: lenb, linux-pm, Srinivas Pandruvada

When the minimum performance limit percentage is set to power-up default,
it is possible that minimum performance ratio is set to one more than the
desired.

During set_policy() callback the minimum ratio is calculated by applying
global.min_perf_pct to the turbo_ratio and rounding up. But the power-up
default global.min_perf_pct is already rounded up to next percent in the
function min_perf_pct_min(). So this will result in two round up
operations. So for the default min_perf_pct, one of the rounding up is
not required.

It is better to remove rounding up in min_perf_pct_min() as this matches
the displayed min_perf_pct prior to the
commit c5a2ee7dde89 ("cpufreq: intel_pstate: Active mode P-state limits
rework") in the kernel version 4,12. For example on a platform with
max turbo ratio of 37 and minimum ratio of 10, the min_perf_pct resulted
in 28 with the above commit. Before this commit it was 27 and same after
this change.

Fixes: 1a4fe38add8b ("cpufreq: intel_pstate: Remove max/min fractions to
limit performance")
Reported-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 drivers/cpufreq/intel_pstate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 48a98f11a84e..2a65bd313938 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -572,7 +572,7 @@ static int min_perf_pct_min(void)
 	int turbo_pstate = cpu->pstate.turbo_pstate;
 
 	return turbo_pstate ?
-		DIV_ROUND_UP(cpu->pstate.min_pstate * 100, turbo_pstate) : 0;
+		(cpu->pstate.min_pstate * 100 / turbo_pstate) : 0;
 }
 
 static s16 intel_pstate_get_epb(struct cpudata *cpu_data)
-- 
2.11.0

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

* Re: [PATCH] cpufreq: intel_pstate: Fix ratio setting for min_perf_pct
  2017-07-10 23:23 [PATCH] cpufreq: intel_pstate: Fix ratio setting for min_perf_pct Srinivas Pandruvada
@ 2017-07-12 21:32 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2017-07-12 21:32 UTC (permalink / raw)
  To: Srinivas Pandruvada; +Cc: lenb, linux-pm

On Monday, July 10, 2017 04:23:52 PM Srinivas Pandruvada wrote:
> When the minimum performance limit percentage is set to power-up default,
> it is possible that minimum performance ratio is set to one more than the
> desired.
> 
> During set_policy() callback the minimum ratio is calculated by applying
> global.min_perf_pct to the turbo_ratio and rounding up. But the power-up
> default global.min_perf_pct is already rounded up to next percent in the
> function min_perf_pct_min(). So this will result in two round up
> operations. So for the default min_perf_pct, one of the rounding up is
> not required.
> 
> It is better to remove rounding up in min_perf_pct_min() as this matches
> the displayed min_perf_pct prior to the
> commit c5a2ee7dde89 ("cpufreq: intel_pstate: Active mode P-state limits
> rework") in the kernel version 4,12. For example on a platform with
> max turbo ratio of 37 and minimum ratio of 10, the min_perf_pct resulted
> in 28 with the above commit. Before this commit it was 27 and same after
> this change.
> 
> Fixes: 1a4fe38add8b ("cpufreq: intel_pstate: Remove max/min fractions to
> limit performance")
> Reported-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

Applied, thanks!

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

end of thread, other threads:[~2017-07-12 21:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-10 23:23 [PATCH] cpufreq: intel_pstate: Fix ratio setting for min_perf_pct Srinivas Pandruvada
2017-07-12 21:32 ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.