Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpufreq: intel_pstate: Adjust _PSS[0] freqeuency if needed

The maximum turbo P-State used by the intel_pstate driver may be
limited by ACPI _PSS table entry 0. After commit 9522a2ff9cde
(cpufreq: intel_pstate: Enforce _PPC limits), the maximum performance
on servers will be capped by the _PSS table entry 0 by default.

Even though that is formally correct, it may lead to preformance
regressions in some cases. Namely, if the _PSS table entry 0 is
not the maximum turbo P-State, performance measured after commit
9522a2ff9cde will not match the performance measured before that
commit on the same system.

For this reason, modify the code to always use the maximum turbo
frequency as the one that corresponds to _PSS table entry 0 if turbo
is enabled in the BIOS. This way, the performance levels from
before commit 9522a2ff9cde will be restored on the affected systems.

Fixes: 9522a2ff9cde (cpufreq: intel_pstate: Enforce _PPC limits)
Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
[ rjw : Changelog ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Srinivas Pandruvada and committed by
Rafael J. Wysocki
b00345d1 5edb5649

+2 -20
+2 -20
drivers/cpufreq/intel_pstate.c
··· 372 372 return acpi_ppc; 373 373 } 374 374 375 - /* 376 - * The max target pstate ratio is a 8 bit value in both PLATFORM_INFO MSR and 377 - * in TURBO_RATIO_LIMIT MSR, which pstate driver stores in max_pstate and 378 - * max_turbo_pstate fields. The PERF_CTL MSR contains 16 bit value for P state 379 - * ratio, out of it only high 8 bits are used. For example 0x1700 is setting 380 - * target ratio 0x17. The _PSS control value stores in a format which can be 381 - * directly written to PERF_CTL MSR. But in intel_pstate driver this shift 382 - * occurs during write to PERF_CTL (E.g. for cores core_set_pstate()). 383 - * This function converts the _PSS control value to intel pstate driver format 384 - * for comparison and assignment. 385 - */ 386 - static int convert_to_native_pstate_format(struct cpudata *cpu, int index) 387 - { 388 - return cpu->acpi_perf_data.states[index].control >> 8; 389 - } 390 - 391 375 static void intel_pstate_init_acpi_perf_limits(struct cpufreq_policy *policy) 392 376 { 393 377 struct cpudata *cpu; 394 - int turbo_pss_ctl; 395 378 int ret; 396 379 int i; 397 380 ··· 424 441 * max frequency, which will cause a reduced performance as 425 442 * this driver uses real max turbo frequency as the max 426 443 * frequency. So correct this frequency in _PSS table to 427 - * correct max turbo frequency based on the turbo ratio. 444 + * correct max turbo frequency based on the turbo state. 428 445 * Also need to convert to MHz as _PSS freq is in MHz. 429 446 */ 430 - turbo_pss_ctl = convert_to_native_pstate_format(cpu, 0); 431 - if (turbo_pss_ctl > cpu->pstate.max_pstate) 447 + if (!limits->turbo_disabled) 432 448 cpu->acpi_perf_data.states[0].core_frequency = 433 449 policy->cpuinfo.max_freq / 1000; 434 450 cpu->valid_pss_table = true;