2022-07-20 13:13:37

by Sudeep Holla

[permalink] [raw]
Subject: [PATCH v3 0/3] arch_topology/cacheinfo: Fixes for v5.20

These are fixes for the cacheinfo/arch_topology updates containing [0]
queued currently in the -next via [3].

Signed-off-by: Sudeep Holla <[email protected]>

---
Changes in v3 from v2[2]:
- Dropped mapping and unmapping of PPTT at runtime using
acpi_{get,put}_table() to avoid "BUG: sleeping function
called from invalid context"
- Added tested-by from Geert

Changes in v2[2] from v1[1]:
- Changed the cacheinfo per-cpu allocation to be atomic
to fix possible "BUG: sleeping function called from invalid context"
- Added all the received tags

[0] https://lore.kernel.org/all/[email protected]
[1] https://lore.kernel.org/all/[email protected]
[2] https://lore.kernel.org/all/[email protected]
[3] https://lore.kernel.org/all/[email protected]

---
Sudeep Holla (3):
cacheinfo: Use atomic allocation for percpu cache attributes
ACPI: PPTT: Leave the table mapped for the runtime usage
arch_topology: Fix cache attributes detection in the CPU hotplug path

drivers/acpi/pptt.c | 102 ++++++++++++++++++++-----------------------
drivers/base/arch_topology.c | 16 +++----
drivers/base/cacheinfo.c | 2 +-
3 files changed, 54 insertions(+), 66 deletions(-)
---
base-commit: 7128af87c7f1c30cd6cebe0b012cc25872c689e2
change-id: 20220720-arch_topo_fixes-d91d43827aeb

Best regards,
--
Regards,
Sudeep


2022-07-20 13:30:50

by Sudeep Holla

[permalink] [raw]
Subject: [PATCH v3 3/3] arch_topology: Fix cache attributes detection in the CPU hotplug path

init_cpu_topology() is called only once at the boot and all the cache
attributes are detected early for all the possible CPUs. However when
the CPUs are hotplugged out, the cacheinfo gets removed. While the
attributes are added back when the CPUs are hotplugged back in as part
of CPU hotplug state machine, it ends up called quite late after the
update_siblings_masks() are called in the secondary_start_kernel()
resulting in wrong llc_sibling_masks.

Move the call to detect_cache_attributes() inside update_siblings_masks()
to ensure the cacheinfo is updated before the LLC sibling masks are
updated. This will fix the incorrect LLC sibling masks generated when
the CPUs are hotplugged out and hotplugged back in again.

Reported-by: Ionela Voinescu <[email protected]>
Reviewed-by: Conor Dooley <[email protected]>
Reviewed-by: Ionela Voinescu <[email protected]>
Tested-by: Geert Uytterhoeven <[email protected]>
Tested-by: Ionela Voinescu <[email protected]>
Signed-off-by: Sudeep Holla <[email protected]>

diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
index 441e14ac33a4..0424b59b695e 100644
--- a/drivers/base/arch_topology.c
+++ b/drivers/base/arch_topology.c
@@ -732,7 +732,11 @@ const struct cpumask *cpu_clustergroup_mask(int cpu)
void update_siblings_masks(unsigned int cpuid)
{
struct cpu_topology *cpu_topo, *cpuid_topo = &cpu_topology[cpuid];
- int cpu;
+ int cpu, ret;
+
+ ret = detect_cache_attributes(cpuid);
+ if (ret)
+ pr_info("Early cacheinfo failed, ret = %d\n", ret);

/* update core and thread sibling masks */
for_each_online_cpu(cpu) {
@@ -821,7 +825,7 @@ __weak int __init parse_acpi_topology(void)
#if defined(CONFIG_ARM64) || defined(CONFIG_RISCV)
void __init init_cpu_topology(void)
{
- int ret, cpu;
+ int ret;

reset_cpu_topology();
ret = parse_acpi_topology();
@@ -836,13 +840,5 @@ void __init init_cpu_topology(void)
reset_cpu_topology();
return;
}
-
- for_each_possible_cpu(cpu) {
- ret = detect_cache_attributes(cpu);
- if (ret) {
- pr_info("Early cacheinfo failed, ret = %d\n", ret);
- break;
- }
- }
}
#endif

--
b4 0.10.0-dev-54fef