x86/of: Map NUMA node to CPUs as per DeviceTree
authorSaurabh Sengar <ssengar@linux.microsoft.com>
Tue, 2 Apr 2024 14:40:29 +0000 (07:40 -0700)
committerIngo Molnar <mingo@kernel.org>
Wed, 3 Apr 2024 06:49:15 +0000 (08:49 +0200)
Currently for DeviceTree bootup, x86 code does the default mapping of
CPUs to NUMA, which is wrong. This can cause incorrect mapping and WARNs
on SMT enabled systems:

  CPU #1's smt-sibling CPU #0 is not on the same node! [node: 1 != 0]. Ignoring dependency.
  WARNING: CPU: 1 PID: 0 at topology_sane.isra.0+0x5c/0x6d
  match_smt+0xf6/0xfc
  set_cpu_sibling_map.cold+0x24f/0x512
  start_secondary+0x5c/0x110

Call the set_apicid_to_node() function in dtb_cpu_setup() for setting
the NUMA to CPU mapping for DeviceTree platforms.

Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/1712068830-4513-4-git-send-email-ssengar@linux.microsoft.com
arch/x86/kernel/devicetree.c

index 0d3a50e8395ddc9a1d043224adcb1f39d0f4550b..b93ce8a39ff7bfa4a59a304d652edfd0a225f9a3 100644 (file)
@@ -24,6 +24,7 @@
 #include <asm/pci_x86.h>
 #include <asm/setup.h>
 #include <asm/i8259.h>
+#include <asm/numa.h>
 #include <asm/prom.h>
 
 __initdata u64 initial_dtb;
@@ -137,6 +138,7 @@ static void __init dtb_cpu_setup(void)
                        continue;
                }
                topology_register_apic(apic_id, CPU_ACPIID_INVALID, true);
+               set_apicid_to_node(apic_id, of_node_to_nid(dn));
        }
 }