* [PATCH v2] cpufreq: intel_pstate: fix inconsistency in setting policy limits
@ 2016-04-04 2:42 Srinivas Pandruvada
2016-04-06 23:35 ` Rafael J. Wysocki
0 siblings, 1 reply; 2+ messages in thread
From: Srinivas Pandruvada @ 2016-04-04 2:42 UTC (permalink / raw)
To: rjw; +Cc: linux-pm, Srinivas Pandruvada
When user sets performance policy using cpufreq interface, it is possible
that because of policy->max limits, the actual performance is still
limited. But the current implementation will silently switch the
policy to powersave and start using powersave limits. If user modifies
any limits using intel_pstate sysfs, this is actually changing powersave
limits.
The current implementation tracks limits under powersave and performance
policy using two different variables. When policy->max is less than
policy->cpuinfo.max_freq, only powersave limit variable is used.
This fix involves uses performance limits variable always when policy
is performance.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
v2:
Rebased on top of
https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git
branch: linux-next
drivers/cpufreq/intel_pstate.c | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index a382195..4674804 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -1140,6 +1140,20 @@ static void intel_pstate_clear_update_util_hook(unsigned int cpu)
synchronize_sched();
}
+static void intel_pstate_set_performance_limits(struct perf_limits *limits)
+{
+ limits->no_turbo = 0;
+ limits->turbo_disabled = 0;
+ limits->max_perf_pct = 100;
+ limits->max_perf = int_tofp(1);
+ limits->min_perf_pct = 100;
+ limits->min_perf = int_tofp(1);
+ limits->max_policy_pct = 100;
+ limits->max_sysfs_pct = 100;
+ limits->min_policy_pct = 0;
+ limits->min_sysfs_pct = 0;
+}
+
static int intel_pstate_set_policy(struct cpufreq_policy *policy)
{
if (!policy->cpuinfo.max_freq)
@@ -1147,15 +1161,18 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
intel_pstate_clear_update_util_hook(policy->cpu);
- if (policy->policy == CPUFREQ_POLICY_PERFORMANCE &&
- policy->max >= policy->cpuinfo.max_freq) {
- pr_debug("intel_pstate: set performance\n");
+ if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) {
limits = &performance_limits;
- goto out;
+ if (policy->max >= policy->cpuinfo.max_freq) {
+ pr_debug("intel_pstate: set performance\n");
+ intel_pstate_set_performance_limits(limits);
+ goto out;
+ }
+ } else {
+ pr_debug("intel_pstate: set powersave\n");
+ limits = &powersave_limits;
}
- pr_debug("intel_pstate: set powersave\n");
- limits = &powersave_limits;
limits->min_policy_pct = (policy->min * 100) / policy->cpuinfo.max_freq;
limits->min_policy_pct = clamp_t(int, limits->min_policy_pct, 0 , 100);
limits->max_policy_pct = DIV_ROUND_UP(policy->max * 100,
--
2.5.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] cpufreq: intel_pstate: fix inconsistency in setting policy limits
2016-04-04 2:42 [PATCH v2] cpufreq: intel_pstate: fix inconsistency in setting policy limits Srinivas Pandruvada
@ 2016-04-06 23:35 ` Rafael J. Wysocki
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2016-04-06 23:35 UTC (permalink / raw)
To: Srinivas Pandruvada; +Cc: linux-pm
On Sunday, April 03, 2016 07:42:11 PM Srinivas Pandruvada wrote:
> When user sets performance policy using cpufreq interface, it is possible
> that because of policy->max limits, the actual performance is still
> limited. But the current implementation will silently switch the
> policy to powersave and start using powersave limits. If user modifies
> any limits using intel_pstate sysfs, this is actually changing powersave
> limits.
>
> The current implementation tracks limits under powersave and performance
> policy using two different variables. When policy->max is less than
> policy->cpuinfo.max_freq, only powersave limit variable is used.
>
> This fix involves uses performance limits variable always when policy
> is performance.
>
> 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:[~2016-04-06 23:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-04 2:42 [PATCH v2] cpufreq: intel_pstate: fix inconsistency in setting policy limits Srinivas Pandruvada
2016-04-06 23:35 ` 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).