* [PATCH v2 0/5] CPPC/amd-pstate: Fixes to limit actions to online CPUs
@ 2025-11-07 7:41 Gautham R. Shenoy
2025-11-07 7:41 ` [PATCH v2 1/5] ACPI: CPPC: Detect preferred core availability on " Gautham R. Shenoy
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: Gautham R. Shenoy @ 2025-11-07 7:41 UTC (permalink / raw)
To: Rafael J . Wysocki, Len Brown, Mario Limonciello, Yunhui Cui,
Jeremy Linton, Viresh Kumar, Ionela Voinescu
Cc: linux-acpi, linux-kernel, Christopher Harris, linux-pm,
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/20251105143851.4251-1-gautham.shenoy@amd.com/
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(-)
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/5] ACPI: CPPC: Detect preferred core availability on online CPUs
2025-11-07 7:41 [PATCH v2 0/5] CPPC/amd-pstate: Fixes to limit actions to online CPUs Gautham R. Shenoy
@ 2025-11-07 7:41 ` Gautham R. Shenoy
2025-11-07 7:41 ` [PATCH v2 2/5] ACPI: CPPC: Check _CPC validity for only the " Gautham R. Shenoy
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Gautham R. Shenoy @ 2025-11-07 7:41 UTC (permalink / raw)
To: Rafael J . Wysocki, Len Brown, Mario Limonciello, Yunhui Cui,
Jeremy Linton, Viresh Kumar, Ionela Voinescu
Cc: linux-acpi, linux-kernel, Christopher Harris, linux-pm,
Gautham R. Shenoy, Mario Limonciello (AMD) (kernel.org)
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.
Fixes: 279f838a61f9 ("x86/amd: Detect preferred cores in amd_get_boost_ratio_numerator()")
Reported-by: Christopher Harris <chris.harris79@gmail.com>
Closes: https://lore.kernel.org/lkml/CAM+eXpdDT7KjLV0AxEwOLkSJ2QtrsvGvjA2cCHvt1d0k2_C4Cw@mail.gmail.com/
Reviewed-by: "Mario Limonciello (AMD) (kernel.org)" <superm1@kernel.org>
Tested-by: Chrisopher Harris <chris.harris79@gmail.com>
Signed-off-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
---
arch/x86/kernel/acpi/cppc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kernel/acpi/cppc.c b/arch/x86/kernel/acpi/cppc.c
index 7047124490f6..d7c8ef1e354d 100644
--- a/arch/x86/kernel/acpi/cppc.c
+++ b/arch/x86/kernel/acpi/cppc.c
@@ -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;
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/5] ACPI: CPPC: Check _CPC validity for only the online CPUs
2025-11-07 7:41 [PATCH v2 0/5] CPPC/amd-pstate: Fixes to limit actions to online CPUs Gautham R. Shenoy
2025-11-07 7:41 ` [PATCH v2 1/5] ACPI: CPPC: Detect preferred core availability on " Gautham R. Shenoy
@ 2025-11-07 7:41 ` Gautham R. Shenoy
2025-11-07 7:41 ` [PATCH v2 3/5] ACPI: CPPC: Perform fast check switch only for " Gautham R. Shenoy
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Gautham R. Shenoy @ 2025-11-07 7:41 UTC (permalink / raw)
To: Rafael J . Wysocki, Len Brown, Mario Limonciello, Yunhui Cui,
Jeremy Linton, Viresh Kumar, Ionela Voinescu
Cc: linux-acpi, linux-kernel, Christopher Harris, linux-pm,
Gautham R. Shenoy, Mario Limonciello (AMD) (kernel.org)
per_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.
Fixes: 2aeca6bd0277 ("ACPI: CPPC: Check present CPUs for determining _CPC is valid")
Reported-by: Christopher Harris <chris.harris79@gmail.com>
Closes: https://lore.kernel.org/lkml/CAM+eXpdDT7KjLV0AxEwOLkSJ2QtrsvGvjA2cCHvt1d0k2_C4Cw@mail.gmail.com/
Suggested-by: Mario Limonciello <mario.limonciello@amd.com>
Reviewed-by: "Mario Limonciello (AMD) (kernel.org)" <superm1@kernel.org>
Tested-by: Chrisopher Harris <chris.harris79@gmail.com>
Signed-off-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
---
drivers/acpi/cppc_acpi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index ab4651205e8a..50e6348b511f 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -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;
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 3/5] ACPI: CPPC: Perform fast check switch only for online CPUs
2025-11-07 7:41 [PATCH v2 0/5] CPPC/amd-pstate: Fixes to limit actions to online CPUs Gautham R. Shenoy
2025-11-07 7:41 ` [PATCH v2 1/5] ACPI: CPPC: Detect preferred core availability on " Gautham R. Shenoy
2025-11-07 7:41 ` [PATCH v2 2/5] ACPI: CPPC: Check _CPC validity for only the " Gautham R. Shenoy
@ 2025-11-07 7:41 ` Gautham R. Shenoy
2025-11-07 7:41 ` [PATCH v2 4/5] ACPI: CPPC: Limit perf ctrs in PCC check only to " Gautham R. Shenoy
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Gautham R. Shenoy @ 2025-11-07 7:41 UTC (permalink / raw)
To: Rafael J . Wysocki, Len Brown, Mario Limonciello, Yunhui Cui,
Jeremy Linton, Viresh Kumar, Ionela Voinescu
Cc: linux-acpi, linux-kernel, Christopher Harris, linux-pm,
Gautham R. Shenoy, Mario Limonciello (AMD) (kernel.org)
per_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
Fixes: 15eece6c5b05 ("ACPI: CPPC: Fix NULL pointer dereference when nosmp is used")
Reviewed-by: "Mario Limonciello (AMD) (kernel.org)" <superm1@kernel.org>
Signed-off-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
---
drivers/acpi/cppc_acpi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index 50e6348b511f..fb7696b27d82 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -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) &&
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 4/5] ACPI: CPPC: Limit perf ctrs in PCC check only to online CPUs
2025-11-07 7:41 [PATCH v2 0/5] CPPC/amd-pstate: Fixes to limit actions to online CPUs Gautham R. Shenoy
` (2 preceding siblings ...)
2025-11-07 7:41 ` [PATCH v2 3/5] ACPI: CPPC: Perform fast check switch only for " Gautham R. Shenoy
@ 2025-11-07 7:41 ` Gautham R. Shenoy
2025-11-07 7:41 ` [PATCH v2 5/5] cpufreq/amd-pstate: Call cppc_set_auto_sel() only for " Gautham R. Shenoy
2025-11-07 17:41 ` [PATCH v2 0/5] CPPC/amd-pstate: Fixes to limit actions to " Rafael J. Wysocki
5 siblings, 0 replies; 8+ messages in thread
From: Gautham R. Shenoy @ 2025-11-07 7:41 UTC (permalink / raw)
To: Rafael J . Wysocki, Len Brown, Mario Limonciello, Yunhui Cui,
Jeremy Linton, Viresh Kumar, Ionela Voinescu
Cc: linux-acpi, linux-kernel, Christopher Harris, linux-pm,
Gautham R. Shenoy, Mario Limonciello (AMD) (kernel.org)
per_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.
Fixes: ae2df912d1a5 ("ACPI: CPPC: Disable FIE if registers in PCC regions")
Reviewed-by: "Mario Limonciello (AMD) (kernel.org)" <superm1@kernel.org>
Signed-off-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
---
drivers/acpi/cppc_acpi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index fb7696b27d82..f49c72d3a78b 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -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;
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 5/5] cpufreq/amd-pstate: Call cppc_set_auto_sel() only for online CPUs
2025-11-07 7:41 [PATCH v2 0/5] CPPC/amd-pstate: Fixes to limit actions to online CPUs Gautham R. Shenoy
` (3 preceding siblings ...)
2025-11-07 7:41 ` [PATCH v2 4/5] ACPI: CPPC: Limit perf ctrs in PCC check only to " Gautham R. Shenoy
@ 2025-11-07 7:41 ` Gautham R. Shenoy
2025-11-07 17:41 ` [PATCH v2 0/5] CPPC/amd-pstate: Fixes to limit actions to " Rafael J. Wysocki
5 siblings, 0 replies; 8+ messages in thread
From: Gautham R. Shenoy @ 2025-11-07 7:41 UTC (permalink / raw)
To: Rafael J . Wysocki, Len Brown, Mario Limonciello, Yunhui Cui,
Jeremy Linton, Viresh Kumar, Ionela Voinescu
Cc: linux-acpi, linux-kernel, Christopher Harris, linux-pm,
Gautham R. Shenoy, Mario Limonciello (AMD) (kernel.org)
amd_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.
Fixes: 3ca7bc818d8c ("cpufreq: amd-pstate: Add guided mode control support via sysfs")
Suggested-by: "Mario Limonciello (AMD) (kernel.org)" <superm1@kernel.org>
Signed-off-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
---
drivers/cpufreq/amd-pstate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index b44f0f7a5ba1..602e4fa81d6c 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -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);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/5] CPPC/amd-pstate: Fixes to limit actions to online CPUs
2025-11-07 7:41 [PATCH v2 0/5] CPPC/amd-pstate: Fixes to limit actions to online CPUs Gautham R. Shenoy
` (4 preceding siblings ...)
2025-11-07 7:41 ` [PATCH v2 5/5] cpufreq/amd-pstate: Call cppc_set_auto_sel() only for " Gautham R. Shenoy
@ 2025-11-07 17:41 ` Rafael J. Wysocki
2025-11-09 4:04 ` Chris Harris
5 siblings, 1 reply; 8+ messages in thread
From: Rafael J. Wysocki @ 2025-11-07 17:41 UTC (permalink / raw)
To: Gautham R. Shenoy
Cc: Rafael J . Wysocki, Len Brown, Mario Limonciello, Yunhui Cui,
Jeremy Linton, Viresh Kumar, Ionela Voinescu, linux-acpi,
linux-kernel, Christopher Harris, linux-pm
Hi,
On Fri, Nov 7, 2025 at 8:42 AM Gautham R. Shenoy <gautham.shenoy@amd.com> wrote:
>
> 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/20251105143851.4251-1-gautham.shenoy@amd.com/
>
> 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
The above 4 patches applied as 6.18-rc material.
> cpufreq/amd-pstate: Call cppc_set_auto_sel() only for online CPUs
And I'm leaving this one to Mario.
Thanks!
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/5] CPPC/amd-pstate: Fixes to limit actions to online CPUs
2025-11-07 17:41 ` [PATCH v2 0/5] CPPC/amd-pstate: Fixes to limit actions to " Rafael J. Wysocki
@ 2025-11-09 4:04 ` Chris Harris
0 siblings, 0 replies; 8+ messages in thread
From: Chris Harris @ 2025-11-09 4:04 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Gautham R. Shenoy, Len Brown, Mario Limonciello, Yunhui Cui,
Jeremy Linton, Viresh Kumar, Ionela Voinescu, linux-acpi,
linux-kernel, linux-pm
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
On Fri, Nov 7, 2025 at 9:41 AM Rafael J. Wysocki <rafael@kernel.org> wrote:
>
> Hi,
>
> On Fri, Nov 7, 2025 at 8:42 AM Gautham R. Shenoy <gautham.shenoy@amd.com> wrote:
> >
> > 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/20251105143851.4251-1-gautham.shenoy@amd.com/
> >
> > 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
>
> The above 4 patches applied as 6.18-rc material.
>
> > cpufreq/amd-pstate: Call cppc_set_auto_sel() only for online CPUs
>
> And I'm leaving this one to Mario.
>
> Thanks!
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-11-09 4:04 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-07 7:41 [PATCH v2 0/5] CPPC/amd-pstate: Fixes to limit actions to online CPUs Gautham R. Shenoy
2025-11-07 7:41 ` [PATCH v2 1/5] ACPI: CPPC: Detect preferred core availability on " Gautham R. Shenoy
2025-11-07 7:41 ` [PATCH v2 2/5] ACPI: CPPC: Check _CPC validity for only the " Gautham R. Shenoy
2025-11-07 7:41 ` [PATCH v2 3/5] ACPI: CPPC: Perform fast check switch only for " Gautham R. Shenoy
2025-11-07 7:41 ` [PATCH v2 4/5] ACPI: CPPC: Limit perf ctrs in PCC check only to " Gautham R. Shenoy
2025-11-07 7:41 ` [PATCH v2 5/5] cpufreq/amd-pstate: Call cppc_set_auto_sel() only for " Gautham R. Shenoy
2025-11-07 17:41 ` [PATCH v2 0/5] CPPC/amd-pstate: Fixes to limit actions to " Rafael J. Wysocki
2025-11-09 4:04 ` Chris Harris
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).