Skip to content

Commit fbd9280

Browse files
committed
riscv: topology: fix default topology reporting
RISC-V has no sane defaults to fall back on where there is no cpu-map in the devicetree. Without sane defaults, the package, core and thread IDs are all set to -1. This causes user-visible inaccuracies for tools like hwloc/lstopo which rely on the sysfs cpu topology files to detect a system's topology. On a PolarFire SoC, which should have 4 harts with a thread each, lstopo currently reports: Machine (793MB total) Package L#0 NUMANode L#0 (P#0 793MB) Core L#0 L1d L#0 (32KB) + L1i L#0 (32KB) + PU L#0 (P#0) L1d L#1 (32KB) + L1i L#1 (32KB) + PU L#1 (P#1) L1d L#2 (32KB) + L1i L#2 (32KB) + PU L#2 (P#2) L1d L#3 (32KB) + L1i L#3 (32KB) + PU L#3 (P#3) Adding calls to store_cpu_topology() in {boot,smp} hart bringup code results in the correct topolgy being reported: Machine (793MB total) Package L#0 NUMANode L#0 (P#0 793MB) L1d L#0 (32KB) + L1i L#0 (32KB) + Core L#0 + PU L#0 (P#0) L1d L#1 (32KB) + L1i L#1 (32KB) + Core L#1 + PU L#1 (P#1) L1d L#2 (32KB) + L1i L#2 (32KB) + Core L#2 + PU L#2 (P#2) L1d L#3 (32KB) + L1i L#3 (32KB) + Core L#3 + PU L#3 (P#3) CC: stable@vger.kernel.org # 456797d: arm64: topology: move store_cpu_topology() to shared code Fixes: 03f11f0 ("RISC-V: Parse cpu topology during boot.") Reported-by: Brice Goglin <Brice.Goglin@inria.fr> Link: open-mpi/hwloc#536 Reviewed-by: Sudeep Holla <sudeep.holla@arm.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
1 parent 456797d commit fbd9280

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

arch/riscv/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ config RISCV
5252
select COMMON_CLK
5353
select CPU_PM if CPU_IDLE
5454
select EDAC_SUPPORT
55-
select GENERIC_ARCH_TOPOLOGY if SMP
55+
select GENERIC_ARCH_TOPOLOGY
5656
select GENERIC_ATOMIC64 if !64BIT
5757
select GENERIC_CLOCKEVENTS_BROADCAST if SMP
5858
select GENERIC_EARLY_IOREMAP

arch/riscv/kernel/smpboot.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
4949
unsigned int curr_cpuid;
5050

5151
curr_cpuid = smp_processor_id();
52+
store_cpu_topology(curr_cpuid);
5253
numa_store_cpu_info(curr_cpuid);
5354
numa_add_cpu(curr_cpuid);
5455

@@ -162,9 +163,9 @@ asmlinkage __visible void smp_callin(void)
162163
mmgrab(mm);
163164
current->active_mm = mm;
164165

166+
store_cpu_topology(curr_cpuid);
165167
notify_cpu_starting(curr_cpuid);
166168
numa_add_cpu(curr_cpuid);
167-
update_siblings_masks(curr_cpuid);
168169
set_cpu_online(curr_cpuid, 1);
169170

170171
/*

0 commit comments

Comments
 (0)