Fix RISC-V's topology reporting
The goal here is the fix the incorrectly reported arch topology on RISC-V which seems to have been broken since it was added. cpu, package and thread IDs are all currently reported as -1, so tools like lstopo think systems have multiple threads on the same core when this is not true: https://github.com/open-mpi/hwloc/issues/536 arm64's topology code basically applies to RISC-V too, so it has been made generic along with the removal of MPIDR related code, which appears to be redudant code since '3102bc0e6ac7 ("arm64: topology: Stop using MPIDR for topology information")' replaced the code that actually interacted with MPIDR with default values. -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCYvq5lAAKCRB4tDGHoIJi 0s6GAQC9GFom3cRkmxcNZeLErhXSfBpzjPH9B76HU1HzZaKzqAEAhVSenCqLyyv7 RgR7icTAw0+7tpR5TTAHQajOVnlnZwA= =8RGe -----END PGP SIGNATURE----- gpgsig -----BEGIN PGP SIGNATURE----- iQJHBAABCAAxFiEEKzw3R0RoQ7JKlDp6LhMZ81+7GIkFAmL+o/cTHHBhbG1lckBk YWJiZWx0LmNvbQAKCRAuExnzX7sYiVeDEACVFPbs2nzkE/caDrl3iwKLmjBTRt81 /sHGEiTB6L1dIm7juK7BrRI0BcrQLlcTkDR0kbU+LjSpgjKYdtEfjQpvAAEYYT39 eO2ZmfpuMEeoTkg5Ewtwml6bVPHzpZJsHDGhzC/7hD3X6JeWirFxN3TMxQIW3eP8 1IHuUiPu6p7mtJ0g795DtUpH/VUT6LrE4HX9dvbzL+Q8T7pZSn+t/1ShAl0zLNVg m+aKwLYGOY8il5njq8FihltDqK5DOYJCIkwXA2LTxSgNJS0cgqCNgvz2A3bxsFD8 VH8j6UvNvGgnEmzMBQKuuNI1bBOFJT60d0O2MlpNptLVpluujOXbxRNPAPSBX9sM czWKtHYsGLk5uJcqIsTWD3ZewmKFE+hrQrDQ+J2BSvMZWTAlLXVeipqYOphAaM8a qJIEzb/74tot+bb1XITG5EI6OpVEu5BOLb/xl/+BWOwO55xvlZv7qPUrMt8RYMXf JGlnuPxZWHQSYhhgvgC+bNi9u20i/FpWcY2rC7ngZKLD0Mr1NzovUY2gvfTwME8G 2Z1xxlN5cr+JFUYnVFdnojX7OMjnjxIM2pUpPk4jij4PYx7MCzACzEy/y7291o5P Zvj1coJiI6KJ4pS8PCELJufQnd88ywOu/2IKfh9lxPRd17kwUSIO71cymGLsDGWS F5aV6Y+xEjiVUA== =vPGY -----END PGP SIGNATURE----- Merge tag 'riscv-topo-on-6.0-rc1' of https://git.kernel.org/pub/scm/linux/kernel/git/conor/linux.git/ into for-next Fix RISC-V's topology reporting The goal here is the fix the incorrectly reported arch topology on RISC-V which seems to have been broken since it was added. cpu, package and thread IDs are all currently reported as -1, so tools like lstopo think systems have multiple threads on the same core when this is not true: https://github.com/open-mpi/hwloc/issues/536 arm64's topology code basically applies to RISC-V too, so it has been made generic along with the removal of MPIDR related code, which appears to be redudant code since '3102bc0e6ac7 ("arm64: topology: Stop using MPIDR for topology information")' replaced the code that actually interacted with MPIDR with default values. * tag 'riscv-topo-on-6.0-rc1' of https://git.kernel.org/pub/scm/linux/kernel/git/conor/linux.git/: riscv: topology: fix default topology reporting arm64: topology: move store_cpu_topology() to shared code
This commit is contained in:
commit
789f3fa9dc
|
@ -22,46 +22,6 @@
|
||||||
#include <asm/cputype.h>
|
#include <asm/cputype.h>
|
||||||
#include <asm/topology.h>
|
#include <asm/topology.h>
|
||||||
|
|
||||||
void store_cpu_topology(unsigned int cpuid)
|
|
||||||
{
|
|
||||||
struct cpu_topology *cpuid_topo = &cpu_topology[cpuid];
|
|
||||||
u64 mpidr;
|
|
||||||
|
|
||||||
if (cpuid_topo->package_id != -1)
|
|
||||||
goto topology_populated;
|
|
||||||
|
|
||||||
mpidr = read_cpuid_mpidr();
|
|
||||||
|
|
||||||
/* Uniprocessor systems can rely on default topology values */
|
|
||||||
if (mpidr & MPIDR_UP_BITMASK)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This would be the place to create cpu topology based on MPIDR.
|
|
||||||
*
|
|
||||||
* However, it cannot be trusted to depict the actual topology; some
|
|
||||||
* pieces of the architecture enforce an artificial cap on Aff0 values
|
|
||||||
* (e.g. GICv3's ICC_SGI1R_EL1 limits it to 15), leading to an
|
|
||||||
* artificial cycling of Aff1, Aff2 and Aff3 values. IOW, these end up
|
|
||||||
* having absolutely no relationship to the actual underlying system
|
|
||||||
* topology, and cannot be reasonably used as core / package ID.
|
|
||||||
*
|
|
||||||
* If the MT bit is set, Aff0 *could* be used to define a thread ID, but
|
|
||||||
* we still wouldn't be able to obtain a sane core ID. This means we
|
|
||||||
* need to entirely ignore MPIDR for any topology deduction.
|
|
||||||
*/
|
|
||||||
cpuid_topo->thread_id = -1;
|
|
||||||
cpuid_topo->core_id = cpuid;
|
|
||||||
cpuid_topo->package_id = cpu_to_node(cpuid);
|
|
||||||
|
|
||||||
pr_debug("CPU%u: cluster %d core %d thread %d mpidr %#016llx\n",
|
|
||||||
cpuid, cpuid_topo->package_id, cpuid_topo->core_id,
|
|
||||||
cpuid_topo->thread_id, mpidr);
|
|
||||||
|
|
||||||
topology_populated:
|
|
||||||
update_siblings_masks(cpuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_ACPI
|
#ifdef CONFIG_ACPI
|
||||||
static bool __init acpi_cpu_is_threaded(int cpu)
|
static bool __init acpi_cpu_is_threaded(int cpu)
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,7 +52,7 @@ config RISCV
|
||||||
select COMMON_CLK
|
select COMMON_CLK
|
||||||
select CPU_PM if CPU_IDLE
|
select CPU_PM if CPU_IDLE
|
||||||
select EDAC_SUPPORT
|
select EDAC_SUPPORT
|
||||||
select GENERIC_ARCH_TOPOLOGY if SMP
|
select GENERIC_ARCH_TOPOLOGY
|
||||||
select GENERIC_ATOMIC64 if !64BIT
|
select GENERIC_ATOMIC64 if !64BIT
|
||||||
select GENERIC_CLOCKEVENTS_BROADCAST if SMP
|
select GENERIC_CLOCKEVENTS_BROADCAST if SMP
|
||||||
select GENERIC_EARLY_IOREMAP
|
select GENERIC_EARLY_IOREMAP
|
||||||
|
|
|
@ -49,6 +49,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
|
||||||
unsigned int curr_cpuid;
|
unsigned int curr_cpuid;
|
||||||
|
|
||||||
curr_cpuid = smp_processor_id();
|
curr_cpuid = smp_processor_id();
|
||||||
|
store_cpu_topology(curr_cpuid);
|
||||||
numa_store_cpu_info(curr_cpuid);
|
numa_store_cpu_info(curr_cpuid);
|
||||||
numa_add_cpu(curr_cpuid);
|
numa_add_cpu(curr_cpuid);
|
||||||
|
|
||||||
|
@ -162,9 +163,9 @@ asmlinkage __visible void smp_callin(void)
|
||||||
mmgrab(mm);
|
mmgrab(mm);
|
||||||
current->active_mm = mm;
|
current->active_mm = mm;
|
||||||
|
|
||||||
|
store_cpu_topology(curr_cpuid);
|
||||||
notify_cpu_starting(curr_cpuid);
|
notify_cpu_starting(curr_cpuid);
|
||||||
numa_add_cpu(curr_cpuid);
|
numa_add_cpu(curr_cpuid);
|
||||||
update_siblings_masks(curr_cpuid);
|
|
||||||
set_cpu_online(curr_cpuid, 1);
|
set_cpu_online(curr_cpuid, 1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -841,4 +841,23 @@ void __init init_cpu_topology(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void store_cpu_topology(unsigned int cpuid)
|
||||||
|
{
|
||||||
|
struct cpu_topology *cpuid_topo = &cpu_topology[cpuid];
|
||||||
|
|
||||||
|
if (cpuid_topo->package_id != -1)
|
||||||
|
goto topology_populated;
|
||||||
|
|
||||||
|
cpuid_topo->thread_id = -1;
|
||||||
|
cpuid_topo->core_id = cpuid;
|
||||||
|
cpuid_topo->package_id = cpu_to_node(cpuid);
|
||||||
|
|
||||||
|
pr_debug("CPU%u: package %d core %d thread %d\n",
|
||||||
|
cpuid, cpuid_topo->package_id, cpuid_topo->core_id,
|
||||||
|
cpuid_topo->thread_id);
|
||||||
|
|
||||||
|
topology_populated:
|
||||||
|
update_siblings_masks(cpuid);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue