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