Skip to content

Commit a6c6ead

Browse files
committed
cpufreq: intel_pstate: Set P-state upfront in performance mode
After commit a4675fb (cpufreq: intel_pstate: Replace timers with utilization update callbacks) the cpufreq governor callbacks may not be invoked on NOHZ_FULL CPUs and, in particular, switching to the "performance" policy via sysfs may not have any effect on them. That is a problem, because it usually is desirable to squeeze the last bit of performance out of those CPUs, so work around it by setting the maximum P-state (within the limits) in intel_pstate_set_policy() upfront when the policy is CPUFREQ_POLICY_PERFORMANCE. Fixes: a4675fb (cpufreq: intel_pstate: Replace timers with utilization update callbacks) Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
1 parent c6fe46a commit a6c6ead

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

drivers/cpufreq/intel_pstate.c

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,10 +1142,8 @@ static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max)
11421142
*min = clamp_t(int, min_perf, cpu->pstate.min_pstate, max_perf);
11431143
}
11441144

1145-
static void intel_pstate_set_min_pstate(struct cpudata *cpu)
1145+
static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate)
11461146
{
1147-
int pstate = cpu->pstate.min_pstate;
1148-
11491147
trace_cpu_frequency(pstate * cpu->pstate.scaling, cpu->cpu);
11501148
cpu->pstate.current_pstate = pstate;
11511149
/*
@@ -1157,6 +1155,20 @@ static void intel_pstate_set_min_pstate(struct cpudata *cpu)
11571155
pstate_funcs.get_val(cpu, pstate));
11581156
}
11591157

1158+
static void intel_pstate_set_min_pstate(struct cpudata *cpu)
1159+
{
1160+
intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate);
1161+
}
1162+
1163+
static void intel_pstate_max_within_limits(struct cpudata *cpu)
1164+
{
1165+
int min_pstate, max_pstate;
1166+
1167+
update_turbo_state();
1168+
intel_pstate_get_min_max(cpu, &min_pstate, &max_pstate);
1169+
intel_pstate_set_pstate(cpu, max_pstate);
1170+
}
1171+
11601172
static void intel_pstate_get_cpu_pstates(struct cpudata *cpu)
11611173
{
11621174
cpu->pstate.min_pstate = pstate_funcs.get_min();
@@ -1491,7 +1503,7 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
14911503
pr_debug("set_policy cpuinfo.max %u policy->max %u\n",
14921504
policy->cpuinfo.max_freq, policy->max);
14931505

1494-
cpu = all_cpu_data[0];
1506+
cpu = all_cpu_data[policy->cpu];
14951507
if (cpu->pstate.max_pstate_physical > cpu->pstate.max_pstate &&
14961508
policy->max < policy->cpuinfo.max_freq &&
14971509
policy->max > cpu->pstate.max_pstate * cpu->pstate.scaling) {
@@ -1535,6 +1547,15 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
15351547
limits->max_perf = round_up(limits->max_perf, FRAC_BITS);
15361548

15371549
out:
1550+
if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) {
1551+
/*
1552+
* NOHZ_FULL CPUs need this as the governor callback may not
1553+
* be invoked on them.
1554+
*/
1555+
intel_pstate_clear_update_util_hook(policy->cpu);
1556+
intel_pstate_max_within_limits(cpu);
1557+
}
1558+
15381559
intel_pstate_set_update_util_hook(policy->cpu);
15391560

15401561
intel_pstate_hwp_set_policy(policy);

0 commit comments

Comments
 (0)