[RFC][PATCH 1/6] x86/topo: Store extra copy of SRAT table
From: Peter Zijlstra
Date: Thu Feb 26 2026 - 05:58:54 EST
Because numa_emulate() will wreck the __apicid_to_node[] table, keep
an extra copy.
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
arch/x86/include/asm/numa.h | 5 +++++
arch/x86/mm/numa.c | 4 ++++
2 files changed, 9 insertions(+)
--- a/arch/x86/include/asm/numa.h
+++ b/arch/x86/include/asm/numa.h
@@ -19,13 +19,18 @@ extern int numa_off;
* The mapping may be overridden by apic->numa_cpu_node() on 32bit and thus
* should be accessed by the accessors - set_apicid_to_node() and
* numa_cpu_node().
+ *
+ * __apicid_to_node[] is affected by numa_emulation(), while
+ * __apicid_to_phys_node[] is not.
*/
extern s16 __apicid_to_node[MAX_LOCAL_APIC];
+extern s16 __apicid_to_phys_node[MAX_LOCAL_APIC];
extern nodemask_t numa_nodes_parsed __initdata;
static inline void set_apicid_to_node(int apicid, s16 node)
{
__apicid_to_node[apicid] = node;
+ __apicid_to_phys_node[apicid] = node;
}
extern int numa_cpu_node(int cpu);
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -48,6 +48,10 @@ s16 __apicid_to_node[MAX_LOCAL_APIC] = {
[0 ... MAX_LOCAL_APIC-1] = NUMA_NO_NODE
};
+s16 __apicid_to_phys_node[MAX_LOCAL_APIC] = {
+ [0 ... MAX_LOCAL_APIC-1] = NUMA_NO_NODE
+};
+
int numa_cpu_node(int cpu)
{
u32 apicid = early_per_cpu(x86_cpu_to_apicid, cpu);