1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | #ifndef _LINUX_NUMA_H |
3 | #define _LINUX_NUMA_H |
4 | #include <linux/types.h> |
5 | |
6 | #ifdef CONFIG_NODES_SHIFT |
7 | #define NODES_SHIFT CONFIG_NODES_SHIFT |
8 | #else |
9 | #define NODES_SHIFT 0 |
10 | #endif |
11 | |
12 | #define MAX_NUMNODES (1 << NODES_SHIFT) |
13 | |
14 | #define NUMA_NO_NODE (-1) |
15 | #define NUMA_NO_MEMBLK (-1) |
16 | |
17 | /* optionally keep NUMA memory info available post init */ |
18 | #ifdef CONFIG_NUMA_KEEP_MEMINFO |
19 | #define __initdata_or_meminfo |
20 | #else |
21 | #define __initdata_or_meminfo __initdata |
22 | #endif |
23 | |
24 | #ifdef CONFIG_NUMA |
25 | #include <linux/printk.h> |
26 | #include <asm/sparsemem.h> |
27 | |
28 | /* Generic implementation available */ |
29 | int numa_nearest_node(int node, unsigned int state); |
30 | |
31 | #ifndef memory_add_physaddr_to_nid |
32 | static inline int memory_add_physaddr_to_nid(u64 start) |
33 | { |
34 | pr_info_once("Unknown online node for memory at 0x%llx, assuming node 0\n" , |
35 | start); |
36 | return 0; |
37 | } |
38 | #endif |
39 | #ifndef phys_to_target_node |
40 | static inline int phys_to_target_node(u64 start) |
41 | { |
42 | pr_info_once("Unknown target node for memory at 0x%llx, assuming node 0\n" , |
43 | start); |
44 | return 0; |
45 | } |
46 | #endif |
47 | #ifndef numa_fill_memblks |
48 | static inline int __init numa_fill_memblks(u64 start, u64 end) |
49 | { |
50 | return NUMA_NO_MEMBLK; |
51 | } |
52 | #endif |
53 | #else /* !CONFIG_NUMA */ |
54 | static inline int numa_nearest_node(int node, unsigned int state) |
55 | { |
56 | return NUMA_NO_NODE; |
57 | } |
58 | |
59 | static inline int memory_add_physaddr_to_nid(u64 start) |
60 | { |
61 | return 0; |
62 | } |
63 | static inline int phys_to_target_node(u64 start) |
64 | { |
65 | return 0; |
66 | } |
67 | #endif |
68 | |
69 | #define numa_map_to_online_node(node) numa_nearest_node(node, N_ONLINE) |
70 | |
71 | #ifdef CONFIG_HAVE_ARCH_NODE_DEV_GROUP |
72 | extern const struct attribute_group arch_node_dev_group; |
73 | #endif |
74 | |
75 | #endif /* _LINUX_NUMA_H */ |
76 | |