1 /* SPDX-License-Identifier: GPL-2.0 */
4 #include <linux/init.h>
5 #include <linux/types.h>
6 #include <linux/nodemask.h>
8 #define NUMA_NO_MEMBLK (-1)
10 static inline bool numa_valid_node(int nid)
12 return nid >= 0 && nid < MAX_NUMNODES;
15 /* optionally keep NUMA memory info available post init */
16 #ifdef CONFIG_NUMA_KEEP_MEMINFO
17 #define __initdata_or_meminfo
19 #define __initdata_or_meminfo __initdata
23 #include <asm/sparsemem.h>
25 extern struct pglist_data *node_data[];
26 #define NODE_DATA(nid) (node_data[nid])
28 void __init alloc_node_data(int nid);
29 void __init alloc_offline_node_data(int nid);
31 /* Generic implementation available */
32 int numa_nearest_node(int node, unsigned int state);
34 int nearest_node_nodemask(int node, nodemask_t *mask);
36 #ifndef memory_add_physaddr_to_nid
37 int memory_add_physaddr_to_nid(u64 start);
40 #ifndef phys_to_target_node
41 int phys_to_target_node(u64 start);
44 int numa_fill_memblks(u64 start, u64 end);
46 #else /* !CONFIG_NUMA */
47 static inline int numa_nearest_node(int node, unsigned int state)
52 static inline int nearest_node_nodemask(int node, nodemask_t *mask)
57 static inline int memory_add_physaddr_to_nid(u64 start)
61 static inline int phys_to_target_node(u64 start)
66 static inline void alloc_offline_node_data(int nid) {}
69 #define numa_map_to_online_node(node) numa_nearest_node(node, N_ONLINE)
71 #ifdef CONFIG_HAVE_ARCH_NODE_DEV_GROUP
72 extern const struct attribute_group arch_node_dev_group;
75 #endif /* _LINUX_NUMA_H */