• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /*
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:
19  */
20 #define NODE_MIN_SIZE (4*1024*1024)
21 
22 extern int numa_off;
23 
24 /*
25  * __apicid_to_node[] stores the raw mapping between physical apicid and
26  * node and is used to initialize cpu_to_node mapping.
27  *
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
30  * numa_cpu_node().
31  */
32 extern s16 __apicid_to_node[MAX_LOCAL_APIC];
33 extern nodemask_t numa_nodes_parsed __initdata;
34 
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);
37 
set_apicid_to_node(int apicid,s16 node)38 static inline void set_apicid_to_node(int apicid, s16 node)
39 {
40 	__apicid_to_node[apicid] = node;
41 }
42 
43 extern int numa_cpu_node(int cpu);
44 
45 #else	/* CONFIG_NUMA */
set_apicid_to_node(int apicid,s16 node)46 static inline void set_apicid_to_node(int apicid, s16 node)
47 {
48 }
49 
numa_cpu_node(int cpu)50 static inline int numa_cpu_node(int cpu)
51 {
52 	return NUMA_NO_NODE;
53 }
54 #endif	/* CONFIG_NUMA */
55 
56 #ifdef CONFIG_X86_32
57 # include <asm/numa_32.h>
58 #endif
59 
60 #ifdef CONFIG_NUMA
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 */
numa_set_node(int cpu,int node)68 static inline void numa_set_node(int cpu, int node)	{ }
numa_clear_node(int cpu)69 static inline void numa_clear_node(int cpu)		{ }
init_cpu_to_node(void)70 static inline void init_cpu_to_node(void)		{ }
numa_add_cpu(int cpu)71 static inline void numa_add_cpu(int cpu)		{ }
numa_remove_cpu(int cpu)72 static inline void numa_remove_cpu(int cpu)		{ }
init_gi_nodes(void)73 static inline void init_gi_nodes(void)			{ }
74 #endif	/* CONFIG_NUMA */
75 
76 #ifdef CONFIG_DEBUG_PER_CPU_MAPS
77 void debug_cpumask_set_cpu(int cpu, int node, bool enable);
78 #endif
79 
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 */
numa_emu_cmdline(char * str)85 static inline int numa_emu_cmdline(char *str)
86 {
87 	return -EINVAL;
88 }
89 #endif /* CONFIG_NUMA_EMU */
90 
91 #endif	/* _ASM_X86_NUMA_H */
92