1 /* SPDX-License-Identifier: GPL-2.0 */
4 #include <linux/types.h>
6 #ifdef CONFIG_NODES_SHIFT
7 #define NODES_SHIFT CONFIG_NODES_SHIFT
12 #define MAX_NUMNODES (1 << NODES_SHIFT)
14 #define NUMA_NO_NODE (-1)
15 #define NUMA_NO_MEMBLK (-1)
17 /* optionally keep NUMA memory info available post init */
18 #ifdef CONFIG_NUMA_KEEP_MEMINFO
19 #define __initdata_or_meminfo
21 #define __initdata_or_meminfo __initdata
25 #include <linux/printk.h>
26 #include <asm/sparsemem.h>
28 /* Generic implementation available */
29 int numa_nearest_node(int node, unsigned int state);
31 #ifndef memory_add_physaddr_to_nid
32 static inline int memory_add_physaddr_to_nid(u64 start)
34 pr_info_once("Unknown online node for memory at 0x%llx, assuming node 0\n",
39 #ifndef phys_to_target_node
40 static inline int phys_to_target_node(u64 start)
42 pr_info_once("Unknown target node for memory at 0x%llx, assuming node 0\n",
47 #ifndef numa_fill_memblks
48 static inline int __init numa_fill_memblks(u64 start, u64 end)
50 return NUMA_NO_MEMBLK;
53 #else /* !CONFIG_NUMA */
54 static inline int numa_nearest_node(int node, unsigned int state)
59 static inline int memory_add_physaddr_to_nid(u64 start)
63 static inline int phys_to_target_node(u64 start)
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 */