Skip to content

Commit 48084cc

Browse files
author
Peter Zijlstra
committed
x86/numa: Store extra copy of numa_nodes_parsed
The topology setup code needs to know the total number of physical nodes enumerated in SRAT; however NUMA_EMU can cause the existing numa_nodes_parsed bitmap to be fictitious. Therefore, keep a copy of the bitmap specifically to retain the physical node count. Suggested-by: K Prateek Nayak <kprateek.nayak@amd.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Ingo Molnar <mingo@kernel.org> Tested-by: K Prateek Nayak <kprateek.nayak@amd.com> Tested-by: Zhang Rui <rui.zhang@intel.com> Tested-by: Chen Yu <yu.c.chen@intel.com> Tested-by: Kyle Meyer <kyle.meyer@hpe.com> Link: https://patch.msgid.link/20260303110059.889884023@infradead.org
1 parent 3d1973a commit 48084cc

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

arch/x86/include/asm/numa.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ extern int numa_off;
2222
*/
2323
extern s16 __apicid_to_node[MAX_LOCAL_APIC];
2424
extern nodemask_t numa_nodes_parsed __initdata;
25+
extern nodemask_t numa_phys_nodes_parsed __initdata;
2526

2627
static inline void set_apicid_to_node(int apicid, s16 node)
2728
{
@@ -48,13 +49,18 @@ extern void __init init_cpu_to_node(void);
4849
extern void numa_add_cpu(unsigned int cpu);
4950
extern void numa_remove_cpu(unsigned int cpu);
5051
extern void init_gi_nodes(void);
52+
extern int num_phys_nodes(void);
5153
#else /* CONFIG_NUMA */
5254
static inline void numa_set_node(int cpu, int node) { }
5355
static inline void numa_clear_node(int cpu) { }
5456
static inline void init_cpu_to_node(void) { }
5557
static inline void numa_add_cpu(unsigned int cpu) { }
5658
static inline void numa_remove_cpu(unsigned int cpu) { }
5759
static inline void init_gi_nodes(void) { }
60+
static inline int num_phys_nodes(void)
61+
{
62+
return 1;
63+
}
5864
#endif /* CONFIG_NUMA */
5965

6066
#ifdef CONFIG_DEBUG_PER_CPU_MAPS

arch/x86/mm/numa.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ s16 __apicid_to_node[MAX_LOCAL_APIC] = {
4848
[0 ... MAX_LOCAL_APIC-1] = NUMA_NO_NODE
4949
};
5050

51+
nodemask_t numa_phys_nodes_parsed __initdata;
52+
5153
int numa_cpu_node(int cpu)
5254
{
5355
u32 apicid = early_per_cpu(x86_cpu_to_apicid, cpu);
@@ -57,6 +59,11 @@ int numa_cpu_node(int cpu)
5759
return NUMA_NO_NODE;
5860
}
5961

62+
int __init num_phys_nodes(void)
63+
{
64+
return bitmap_weight(numa_phys_nodes_parsed.bits, MAX_NUMNODES);
65+
}
66+
6067
cpumask_var_t node_to_cpumask_map[MAX_NUMNODES];
6168
EXPORT_SYMBOL(node_to_cpumask_map);
6269

@@ -210,6 +217,7 @@ static int __init dummy_numa_init(void)
210217
0LLU, PFN_PHYS(max_pfn) - 1);
211218

212219
node_set(0, numa_nodes_parsed);
220+
node_set(0, numa_phys_nodes_parsed);
213221
numa_add_memblk(0, 0, PFN_PHYS(max_pfn));
214222

215223
return 0;

arch/x86/mm/srat.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa)
5757
}
5858
set_apicid_to_node(apic_id, node);
5959
node_set(node, numa_nodes_parsed);
60+
node_set(node, numa_phys_nodes_parsed);
6061
pr_debug("SRAT: PXM %u -> APIC 0x%04x -> Node %u\n", pxm, apic_id, node);
6162
}
6263

@@ -97,6 +98,7 @@ acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa)
9798

9899
set_apicid_to_node(apic_id, node);
99100
node_set(node, numa_nodes_parsed);
101+
node_set(node, numa_phys_nodes_parsed);
100102
pr_debug("SRAT: PXM %u -> APIC 0x%02x -> Node %u\n", pxm, apic_id, node);
101103
}
102104

0 commit comments

Comments
 (0)