Merge tag 'mm-hotfixes-stable-2025-07-11-16-16' of git://git.kernel.org/pub/scm/linux...
[linux-2.6-block.git] / include / linux / numa.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
1da177e4
LT
2#ifndef _LINUX_NUMA_H
3#define _LINUX_NUMA_H
d7a73e3f 4#include <linux/init.h>
5d30f92e 5#include <linux/types.h>
14a8262f 6#include <linux/nodemask.h>
1da177e4 7
8f012db2 8#define NUMA_NO_MEMBLK (-1)
4e25b257 9
8043832e
MRI
10static inline bool numa_valid_node(int nid)
11{
12 return nid >= 0 && nid < MAX_NUMNODES;
13}
14
1e5d8e1e
DW
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
b2ca916c 22#ifdef CONFIG_NUMA
a927bd6b
DW
23#include <asm/sparsemem.h>
24
46bcce50
MRM
25extern struct pglist_data *node_data[];
26#define NODE_DATA(nid) (node_data[nid])
27
3515863d 28void __init alloc_node_data(int nid);
ec164cf1
MRM
29void __init alloc_offline_node_data(int nid);
30
5d30f92e 31/* Generic implementation available */
b1f099b1 32int numa_nearest_node(int node, unsigned int state);
a927bd6b 33
16d79f2a
AR
34int nearest_node_nodemask(int node, nodemask_t *mask);
35
a927bd6b 36#ifndef memory_add_physaddr_to_nid
d7a73e3f 37int memory_add_physaddr_to_nid(u64 start);
a927bd6b 38#endif
d7a73e3f 39
a927bd6b 40#ifndef phys_to_target_node
d7a73e3f 41int phys_to_target_node(u64 start);
a927bd6b 42#endif
d7a73e3f 43
f9f67e5a 44int numa_fill_memblks(u64 start, u64 end);
d7a73e3f 45
a927bd6b 46#else /* !CONFIG_NUMA */
b1f099b1 47static inline int numa_nearest_node(int node, unsigned int state)
b2ca916c
DW
48{
49 return NUMA_NO_NODE;
50}
b1f099b1 51
16d79f2a
AR
52static inline int nearest_node_nodemask(int node, nodemask_t *mask)
53{
54 return NUMA_NO_NODE;
55}
56
a927bd6b
DW
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}
ec164cf1
MRM
65
66static inline void alloc_offline_node_data(int nid) {}
b2ca916c
DW
67#endif
68
b1f099b1
YN
69#define numa_map_to_online_node(node) numa_nearest_node(node, N_ONLINE)
70
50468e43
JS
71#ifdef CONFIG_HAVE_ARCH_NODE_DEV_GROUP
72extern const struct attribute_group arch_node_dev_group;
73#endif
74
1da177e4 75#endif /* _LINUX_NUMA_H */