* [PATCH v2 1/2] arch_topology: Reset SMT state when socket parsing fails
@ 2026-11-06 16:44 Sudeep Holla
2026-11-06 16:44 ` [PATCH v2 2/2] arch_topology: Free ACPI SMT entries on lookup failure Sudeep Holla
0 siblings, 1 reply; 2+ messages in thread
From: Sudeep Holla @ 2026-11-06 16:44 UTC (permalink / raw)
To: driver-core; +Cc: Sudeep Holla, Greg Kroah-Hartman, Sashiko
If a later socket's cluster fails device tree parsing, parse_socket()
returns immediately. Cores parsed earlier can have raised
max_smt_thread_num, but this return skips the reset to 1 and the
cpu_smt_set_num_threads() notification. The framework is left with an
inconsistent SMT state after topology parsing fails.
Break out of the socket loop on parse_cluster() failure so the existing
error handling resets the thread count and notifies the SMT framework
before returning the error.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-73adead8-21f3-470d-938c-b1f07a269a72
Fixes: 5deb9c789ae4 ("arch_topology: Support SMT control for OF based system")
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
---
drivers/base/arch_topology.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
v1->v2:
- No change(just posting together with 2/2 which was result of sashiko review)
- v1: https://lore.kernel.org/all/20261103093421.1283949-1-sudeep.holla@kernel.org
diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
index 8c5e47c28d9a..1569ab3335f5 100644
--- a/drivers/base/arch_topology.c
+++ b/drivers/base/arch_topology.c
@@ -633,7 +633,7 @@ static int __init parse_socket(struct device_node *socket)
has_socket = true;
ret = parse_cluster(c, package_id, -1, 0);
if (ret != 0)
- return ret;
+ break;
package_id++;
} while (1);
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH v2 2/2] arch_topology: Free ACPI SMT entries on lookup failure
2026-11-06 16:44 [PATCH v2 1/2] arch_topology: Reset SMT state when socket parsing fails Sudeep Holla
@ 2026-11-06 16:44 ` Sudeep Holla
0 siblings, 0 replies; 2+ messages in thread
From: Sudeep Holla @ 2026-11-06 16:44 UTC (permalink / raw)
To: driver-core; +Cc: Sudeep Holla, Greg Kroah-Hartman, Sashiko
A later CPU can fail find_acpi_cpu_topology() after earlier threaded
CPUs have populated hetero_cpu. Returning immediately leaks the stored
cpu_smt_info objects and the XArray nodes.
Send the error through the existing cleanup and retain its return code.
Only update the SMT thread count after a successful parse.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-f41acdf3-9470-4de9-b497-d5de16c8e7e8
Fixes: e6b18ebfaf63 ("arm64: topology: Support SMT control on ACPI based system")
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
---
drivers/base/arch_topology.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
v1->v2:
- Reset max_smt_thread_num to 1 on failure similar to parse_socket()
- v1: https://lore.kernel.org/all/20261104153413.2786066-1-sudeep.holla@kernel.org
diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
index 1569ab3335f5..9033a9b642e3 100644
--- a/drivers/base/arch_topology.c
+++ b/drivers/base/arch_topology.c
@@ -860,7 +860,7 @@ __weak int __init parse_acpi_topology(void)
struct cpu_smt_info *entry;
struct xarray hetero_cpu;
unsigned long hetero_id;
- int cpu, topology_id;
+ int cpu, topology_id, ret = 0;
if (acpi_disabled)
return 0;
@@ -869,8 +869,10 @@ __weak int __init parse_acpi_topology(void)
for_each_possible_cpu(cpu) {
topology_id = find_acpi_cpu_topology(cpu, 0);
- if (topology_id < 0)
- return topology_id;
+ if (topology_id < 0) {
+ ret = topology_id;
+ goto out;
+ }
if (acpi_cpu_is_threaded(cpu)) {
cpu_topology[cpu].thread_id = topology_id;
@@ -914,6 +916,7 @@ __weak int __init parse_acpi_topology(void)
cpu_topology[cpu].package_id = topology_id;
}
+out:
/*
* This is a short loop since the number of XArray elements is the
* number of heterogeneous CPU clusters. On a homogeneous system
@@ -925,9 +928,13 @@ __weak int __init parse_acpi_topology(void)
kfree(entry);
}
+ /* Reset max_smt_thread_num to 1 on failure like in parse_socket() */
+ if (ret)
+ max_smt_thread_num = 1;
+
cpu_smt_set_num_threads(max_smt_thread_num, max_smt_thread_num);
xa_destroy(&hetero_cpu);
- return 0;
+ return ret;
}
void __init init_cpu_topology(void)
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-06 16:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-06 16:44 [PATCH v2 1/2] arch_topology: Reset SMT state when socket parsing fails Sudeep Holla
2026-11-06 16:44 ` [PATCH v2 2/2] arch_topology: Free ACPI SMT entries on lookup failure Sudeep Holla
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox