xref: /openbmc/linux/arch/x86/include/asm/numa.h (revision 0f32b0b2)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_NUMA_H
3 #define _ASM_X86_NUMA_H
4 
5 #include <linux/nodemask.h>
6 #include <linux/errno.h>
7 
8 #include <asm/topology.h>
9 #include <asm/apicdef.h>
10 
11 #ifdef CONFIG_NUMA
12 
13 #define NR_NODE_MEMBLKS		(MAX_NUMNODES*2)
14 
15 extern int numa_off;
16 
17 /*
18  * __apicid_to_node[] stores the raw mapping between physical apicid and
19  * node and is used to initialize cpu_to_node mapping.
20  *
21  * The mapping may be overridden by apic->numa_cpu_node() on 32bit and thus
22  * should be accessed by the accessors - set_apicid_to_node() and
23  * numa_cpu_node().
24  */
25 extern s16 __apicid_to_node[MAX_LOCAL_APIC];
26 extern nodemask_t numa_nodes_parsed __initdata;
27 
28 extern int __init numa_add_memblk(int nodeid, u64 start, u64 end);
29 extern void __init numa_set_distance(int from, int to, int distance);
30 
set_apicid_to_node(int apicid,s16 node)31 static inline void set_apicid_to_node(int apicid, s16 node)
32 {
33 	__apicid_to_node[apicid] = node;
34 }
35 
36 extern int numa_cpu_node(int cpu);
37 
38 #else	/* CONFIG_NUMA */
set_apicid_to_node(int apicid,s16 node)39 static inline void set_apicid_to_node(int apicid, s16 node)
40 {
41 }
42 
numa_cpu_node(int cpu)43 static inline int numa_cpu_node(int cpu)
44 {
45 	return NUMA_NO_NODE;
46 }
47 #endif	/* CONFIG_NUMA */
48 
49 #ifdef CONFIG_X86_32
50 # include <asm/numa_32.h>
51 #endif
52 
53 #ifdef CONFIG_NUMA
54 extern void numa_set_node(int cpu, int node);
55 extern void numa_clear_node(int cpu);
56 extern void __init init_cpu_to_node(void);
57 extern void numa_add_cpu(int cpu);
58 extern void numa_remove_cpu(int cpu);
59 extern void init_gi_nodes(void);
60 #else	/* CONFIG_NUMA */
numa_set_node(int cpu,int node)61 static inline void numa_set_node(int cpu, int node)	{ }
numa_clear_node(int cpu)62 static inline void numa_clear_node(int cpu)		{ }
init_cpu_to_node(void)63 static inline void init_cpu_to_node(void)		{ }
numa_add_cpu(int cpu)64 static inline void numa_add_cpu(int cpu)		{ }
numa_remove_cpu(int cpu)65 static inline void numa_remove_cpu(int cpu)		{ }
init_gi_nodes(void)66 static inline void init_gi_nodes(void)			{ }
67 #endif	/* CONFIG_NUMA */
68 
69 #ifdef CONFIG_DEBUG_PER_CPU_MAPS
70 void debug_cpumask_set_cpu(int cpu, int node, bool enable);
71 #endif
72 
73 #ifdef CONFIG_NUMA_EMU
74 #define FAKE_NODE_MIN_SIZE	((u64)32 << 20)
75 #define FAKE_NODE_MIN_HASH_MASK	(~(FAKE_NODE_MIN_SIZE - 1UL))
76 int numa_emu_cmdline(char *str);
77 #else /* CONFIG_NUMA_EMU */
numa_emu_cmdline(char * str)78 static inline int numa_emu_cmdline(char *str)
79 {
80 	return -EINVAL;
81 }
82 #endif /* CONFIG_NUMA_EMU */
83 
84 #endif	/* _ASM_X86_NUMA_H */
85