Linux 6.16-rc6
[linux-2.6-block.git] / include / linux / numa.h
... / ...
CommitLineData
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _LINUX_NUMA_H
3#define _LINUX_NUMA_H
4#include <linux/init.h>
5#include <linux/types.h>
6#include <linux/nodemask.h>
7
8#define NUMA_NO_MEMBLK (-1)
9
10static inline bool numa_valid_node(int nid)
11{
12 return nid >= 0 && nid < MAX_NUMNODES;
13}
14
15/* optionally keep NUMA memory info available post init */
16#ifdef CONFIG_NUMA_KEEP_MEMINFO
17#define __initdata_or_meminfo
18#else
19#define __initdata_or_meminfo __initdata
20#endif
21
22#ifdef CONFIG_NUMA
23#include <asm/sparsemem.h>
24
25extern struct pglist_data *node_data[];
26#define NODE_DATA(nid) (node_data[nid])
27
28void __init alloc_node_data(int nid);
29void __init alloc_offline_node_data(int nid);
30
31/* Generic implementation available */
32int numa_nearest_node(int node, unsigned int state);
33
34int nearest_node_nodemask(int node, nodemask_t *mask);
35
36#ifndef memory_add_physaddr_to_nid
37int memory_add_physaddr_to_nid(u64 start);
38#endif
39
40#ifndef phys_to_target_node
41int phys_to_target_node(u64 start);
42#endif
43
44int numa_fill_memblks(u64 start, u64 end);
45
46#else /* !CONFIG_NUMA */
47static inline int numa_nearest_node(int node, unsigned int state)
48{
49 return NUMA_NO_NODE;
50}
51
52static inline int nearest_node_nodemask(int node, nodemask_t *mask)
53{
54 return NUMA_NO_NODE;
55}
56
57static inline int memory_add_physaddr_to_nid(u64 start)
58{
59 return 0;
60}
61static inline int phys_to_target_node(u64 start)
62{
63 return 0;
64}
65
66static inline void alloc_offline_node_data(int nid) {}
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
72extern const struct attribute_group arch_node_dev_group;
73#endif
74
75#endif /* _LINUX_NUMA_H */