1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_NUMA_H
3 #define _ASM_X86_NUMA_H
5 #include <linux/nodemask.h>
6 #include <linux/errno.h>
8 #include <asm/topology.h>
9 #include <asm/apicdef.h>
13 #define NR_NODE_MEMBLKS (MAX_NUMNODES*2)
16 * Too small node sizes may confuse the VM badly. Usually they
17 * result from BIOS bugs. So dont recognize nodes as standalone
18 * NUMA entities that have less than this amount of RAM listed:
20 #define NODE_MIN_SIZE (4*1024*1024)
25 * __apicid_to_node[] stores the raw mapping between physical apicid and
26 * node and is used to initialize cpu_to_node mapping.
28 * The mapping may be overridden by apic->numa_cpu_node() on 32bit and thus
29 * should be accessed by the accessors - set_apicid_to_node() and
32 extern s16 __apicid_to_node[MAX_LOCAL_APIC];
33 extern nodemask_t numa_nodes_parsed __initdata;
35 extern int __init numa_add_memblk(int nodeid, u64 start, u64 end);
36 extern void __init numa_set_distance(int from, int to, int distance);
38 static inline void set_apicid_to_node(int apicid, s16 node)
40 __apicid_to_node[apicid] = node;
43 extern int numa_cpu_node(int cpu);
45 #else /* CONFIG_NUMA */
46 static inline void set_apicid_to_node(int apicid, s16 node)
50 static inline int numa_cpu_node(int cpu)
54 #endif /* CONFIG_NUMA */
57 # include <asm/numa_32.h>
61 extern void numa_set_node(int cpu, int node);
62 extern void numa_clear_node(int cpu);
63 extern void __init init_cpu_to_node(void);
64 extern void numa_add_cpu(int cpu);
65 extern void numa_remove_cpu(int cpu);
66 extern void init_gi_nodes(void);
67 #else /* CONFIG_NUMA */
68 static inline void numa_set_node(int cpu, int node) { }
69 static inline void numa_clear_node(int cpu) { }
70 static inline void init_cpu_to_node(void) { }
71 static inline void numa_add_cpu(int cpu) { }
72 static inline void numa_remove_cpu(int cpu) { }
73 static inline void init_gi_nodes(void) { }
74 #endif /* CONFIG_NUMA */
76 #ifdef CONFIG_DEBUG_PER_CPU_MAPS
77 void debug_cpumask_set_cpu(int cpu, int node, bool enable);
80 #ifdef CONFIG_NUMA_EMU
81 #define FAKE_NODE_MIN_SIZE ((u64)32 << 20)
82 #define FAKE_NODE_MIN_HASH_MASK (~(FAKE_NODE_MIN_SIZE - 1UL))
83 int numa_emu_cmdline(char *str);
84 #else /* CONFIG_NUMA_EMU */
85 static inline int numa_emu_cmdline(char *str)
89 #endif /* CONFIG_NUMA_EMU */
91 #endif /* _ASM_X86_NUMA_H */