CPPC/amd-pstate: Fixes to limit actions to online CPUs
Subsystems (5)
v2 cover CPPC/amd-pstate: Fixes to limit actions to online CPUs
Hello,
This is the v2 of the patchset to restrict certain actions to only online CPUs instead of present CPUs.
The v1 of this patchset can be found here:
https://lore.kernel.org/lkml/[email protected]/
Changes between v1 --> v2:
* Picked up the Reviewed-by tags from Mario for the first four patches
* Picked up the Tested-by tags from Chris for the first two patches
* Added a fifth patch to fix calling of cppc_set_auto_sel() for only online CPUs in the amd-pstate driver code (Mario)
Gautham R. Shenoy (5):
ACPI: CPPC: Detect preferred core availability on online CPUs
ACPI: CPPC: Check _CPC validity for only the online CPUs
ACPI: CPPC: Perform fast check switch only for online CPUs
ACPI: CPPC: Limit perf ctrs in PCC check only to online CPUs cpufreq/amd-pstate: Call cppc_set_auto_sel() only for online CPUs
arch/x86/kernel/acpi/cppc.c | 2 +- drivers/acpi/cppc_acpi.c | 6 +++--- drivers/cpufreq/amd-pstate.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/5 ACPI: CPPC: Detect preferred core availability on online CPUs
Commit 279f838a61f9 ("x86/amd: Detect preferred cores in amd_get_boost_ratio_numerator()") introduced the ability to detect the preferred core on AMD platforms by checking if there at least two distinct highest_perf values.
However, it uses for_each_present_cpu() to iterate through all the CPUs in the platform, which is problematic when the kernel is booted with "nosmt=force" commandline option.
Hence limit the search to only the online CPUs.
--- arch/x86/kernel/acpi/cppc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/acpi/cppc.c +1 -1
@@ -196,7 +196,7 @@ int amd_detect_prefcore(bool *detected)break ; } -for_each_present_cpu (cpu) { +for_each_online_cpu (cpu) {u32 tmp;int ret;
Signature · 1 line
2.34.1
PATCH v2 2/5 ACPI: CPPC: Check _CPC validity for only the online CPUs
In reply to Gautham R. Shenoyper_cpu(cpc_desc_ptr, cpu) object is initialized for only the online CPUs via acpi_soft_cpu_online() --> __acpi_processor_start() --> acpi_cppc_processor_probe().
However the function acpi_cpc_valid() checks for the validity of the _CPC object for all the present CPUs. This breaks when the kernel is booted with "nosmt=force".
Hence check the validity of the _CPC objects of only the online CPUs.
--- drivers/acpi/cppc_acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/cppc_acpi.c +1 -1
@@ -460,7 +460,7 @@ bool acpi_cpc_valid(void)if (acpi_disabled)return false; -for_each_present_cpu (cpu) { +for_each_online_cpu (cpu) { cpc_ptr =per_cpu (cpc_desc_ptr, cpu);if (!cpc_ptr)return false;
Signature · 1 line
2.34.1
PATCH v2 3/5 ACPI: CPPC: Perform fast check switch only for online CPUs
In reply to Gautham R. Shenoyper_cpu(cpc_desc_ptr, cpu) object is initialized for only the online CPUs via acpi_soft_cpu_online() --> __acpi_processor_start() --> acpi_cppc_processor_probe().
However the function cppc_allow_fast_switch() checks for the validity of the _CPC object for all the present CPUs. This breaks when the kernel is booted with "nosmt=force".
Check fast_switch capability only on online CPUs
--- drivers/acpi/cppc_acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/cppc_acpi.c +1 -1
@@ -476,7 +476,7 @@ bool cppc_allow_fast_switch(void)struct cpc_desc *cpc_ptr;int cpu; -for_each_present_cpu (cpu) { +for_each_online_cpu (cpu) { cpc_ptr =per_cpu (cpc_desc_ptr, cpu); desired_reg = &cpc_ptr->cpc_regs[DESIRED_PERF ]; if (!CPC_IN_SYSTEM_MEMORY(desired_reg) &&
Signature · 1 line
2.34.1
PATCH v2 4/5 ACPI: CPPC: Limit perf ctrs in PCC check only to online CPUs
In reply to Gautham R. Shenoyper_cpu(cpc_desc_ptr, cpu) object is initialized for only the online CPU via acpi_soft_cpu_online() --> __acpi_processor_start() --> acpi_cppc_processor_probe().
However the function cppc_perf_ctrs_in_pcc() checks if the CPPC perf-ctrs are in a PCC region for all the present CPUs, which breaks when the kernel is booted with "nosmt=force".
Hence, limit the check only to the online CPUs.
--- drivers/acpi/cppc_acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/cppc_acpi.c +1 -1
@@ -1435,7 +1435,7 @@ bool cppc_perf_ctrs_in_pcc(void) {int cpu; -for_each_present_cpu (cpu) { +for_each_online_cpu (cpu) {struct cpc_register_resource *ref_perf_reg;struct cpc_desc *cpc_desc;
Signature · 1 line
2.34.1
PATCH v2 5/5 cpufreq/amd-pstate: Call cppc_set_auto_sel() only for online CPUs
In reply to Gautham R. Shenoyamd_pstate_change_mode_without_dvr_change() calls cppc_set_auto_sel() for all the present CPUs.
However, this callpath eventually calls cppc_set_reg_val() which accesses the per-cpu cpc_desc_ptr object. This object is initialized only for online CPUs via acpi_soft_cpu_online() --> __acpi_processor_start() --> acpi_cppc_processor_probe().
Hence, restrict calling cppc_set_auto_sel() to only the online CPUs.
--- drivers/cpufreq/amd-pstate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/amd-pstate.c +1 -1
@@ -1282,7 +1282,7 @@ static int amd_pstate_change_mode_without_dvr_change(int mode)if (cpu_feature_enabled (X86_FEATURE_CPPC ) || cppc_state ==AMD_PSTATE_ACTIVE )return 0 ; -for_each_present_cpu (cpu) { +for_each_online_cpu (cpu) {cppc_set_auto_sel (cpu, (cppc_state ==AMD_PSTATE_PASSIVE ) ?0 :1 ); }
Signature · 1 line
2.34.1
Rafael J. Wysocki
maintainerHi,
Quoted 20 lines · Gautham R. Shenoy
Hello,
This is the v2 of the patchset to restrict certain actions to only online CPUs instead of present CPUs.
The v1 of this patchset can be found here:
https://lore.kernel.org/lkml/[email protected]/Changes between v1 --> v2:
* Picked up the Reviewed-by tags from Mario for the first four patches
* Picked up the Tested-by tags from Chris for the first two patches
* Added a fifth patch to fix calling of
cppc_set_auto_sel()for only online CPUs in the amd-pstate driver code (Mario)
Quoted 5 lines
Gautham R. Shenoy (5):
ACPI: CPPC: Detect preferred core availability on online CPUs
ACPI: CPPC: Check_CPCvalidity for only the online CPUs
ACPI: CPPC: Perform fast check switch only for online CPUs
ACPI: CPPC: Limit perf ctrs in PCC check only to online CPUs
The above 4 patches applied as 6.18-rc material.
Quoted 1 line
cpufreq/amd-pstate: Call
cppc_set_auto_sel()only for online CPUs
And I'm leaving this one to Mario.
Thanks!
Hi, I've tested all five v2 patches and have observed no issues in the use case the bug report was based upon. I continue to successfully receive the desired amd-pstate scaling driver when 'nosmt=force' and 'amd_pstate=passive' are set. I've not tested other cases/scenarios for which the additional hardening/patches may have been intended.
Thank you again for the rapid efforts that went into this solution.
Chris Harris
Quoted 37 lines · Rafael J. Wysocki
Hi,
Quoted 20 lines · Gautham R. Shenoy
Hello,
This is the v2 of the patchset to restrict certain actions to only online CPUs instead of present CPUs.
The v1 of this patchset can be found here:
https://lore.kernel.org/lkml/[email protected]/Changes between v1 --> v2:
* Picked up the Reviewed-by tags from Mario for the first four patches
* Picked up the Tested-by tags from Chris for the first two patches
* Added a fifth patch to fix calling of
cppc_set_auto_sel()for only online CPUs in the amd-pstate driver code (Mario)Quoted 5 lines
Gautham R. Shenoy (5):
ACPI: CPPC: Detect preferred core availability on online CPUs
ACPI: CPPC: Check_CPCvalidity for only the online CPUs
ACPI: CPPC: Perform fast check switch only for online CPUs
ACPI: CPPC: Limit perf ctrs in PCC check only to online CPUsThe above 4 patches applied as 6.18-rc material.
Quoted 1 line
cpufreq/amd-pstate: Call
cppc_set_auto_sel()only for online CPUsAnd I'm leaving this one to Mario.
Thanks!