Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | /* |
3 | * include/linux/node.h - generic node definition | |
4 | * | |
5 | * This is mainly for topological representation. We define the | |
6 | * basic 'struct node' here, which can be embedded in per-arch | |
7 | * definitions of processors. | |
8 | * | |
9 | * Basic handling of the devices is done in drivers/base/node.c | |
10 | * and system devices are handled in drivers/base/sys.c. | |
11 | * | |
12 | * Nodes are exported via driverfs in the class/node/devices/ | |
13 | * directory. | |
1da177e4 LT |
14 | */ |
15 | #ifndef _LINUX_NODE_H_ | |
16 | #define _LINUX_NODE_H_ | |
17 | ||
10fbcf4c | 18 | #include <linux/device.h> |
1da177e4 | 19 | #include <linux/cpumask.h> |
39da08cb | 20 | #include <linux/workqueue.h> |
1da177e4 LT |
21 | |
22 | struct node { | |
10fbcf4c | 23 | struct device dev; |
39da08cb LS |
24 | |
25 | #if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS) | |
26 | struct work_struct node_work; | |
27 | #endif | |
1da177e4 LT |
28 | }; |
29 | ||
c04fc586 | 30 | struct memory_block; |
8732794b | 31 | extern struct node *node_devices[]; |
9a305230 | 32 | typedef void (*node_registration_func_t)(struct node *); |
0fc44159 | 33 | |
9037a993 MH |
34 | #if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_NUMA) |
35 | extern int link_mem_sections(int nid, unsigned long start_pfn, unsigned long nr_pages); | |
36 | #else | |
37 | static inline int link_mem_sections(int nid, unsigned long start_pfn, unsigned long nr_pages) | |
38 | { | |
39 | return 0; | |
40 | } | |
41 | #endif | |
42 | ||
4b45099b | 43 | extern void unregister_node(struct node *node); |
36920e06 | 44 | #ifdef CONFIG_NUMA |
9037a993 MH |
45 | /* Core of the node registration - only memory hotplug should use this */ |
46 | extern int __register_one_node(int nid); | |
47 | ||
48 | /* Registers an online node */ | |
49 | static inline int register_one_node(int nid) | |
50 | { | |
51 | int error = 0; | |
52 | ||
53 | if (node_online(nid)) { | |
54 | struct pglist_data *pgdat = NODE_DATA(nid); | |
55 | ||
56 | error = __register_one_node(nid); | |
57 | if (error) | |
58 | return error; | |
59 | /* link memory sections under this node */ | |
60 | error = link_mem_sections(nid, pgdat->node_start_pfn, pgdat->node_spanned_pages); | |
61 | } | |
62 | ||
63 | return error; | |
64 | } | |
65 | ||
0fc44159 | 66 | extern void unregister_one_node(int nid); |
76b67ed9 KH |
67 | extern int register_cpu_under_node(unsigned int cpu, unsigned int nid); |
68 | extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid); | |
c04fc586 | 69 | extern int register_mem_sect_under_node(struct memory_block *mem_blk, |
fc44f7f9 | 70 | int nid, bool check_nid); |
d3360164 NF |
71 | extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk, |
72 | unsigned long phys_index); | |
9a305230 LS |
73 | |
74 | #ifdef CONFIG_HUGETLBFS | |
75 | extern void register_hugetlbfs_with_node(node_registration_func_t doregister, | |
76 | node_registration_func_t unregister); | |
77 | #endif | |
76b67ed9 | 78 | #else |
9037a993 MH |
79 | static inline int __register_one_node(int nid) |
80 | { | |
81 | return 0; | |
82 | } | |
36920e06 KH |
83 | static inline int register_one_node(int nid) |
84 | { | |
85 | return 0; | |
86 | } | |
87 | static inline int unregister_one_node(int nid) | |
88 | { | |
89 | return 0; | |
90 | } | |
76b67ed9 KH |
91 | static inline int register_cpu_under_node(unsigned int cpu, unsigned int nid) |
92 | { | |
93 | return 0; | |
94 | } | |
95 | static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid) | |
96 | { | |
97 | return 0; | |
98 | } | |
c04fc586 | 99 | static inline int register_mem_sect_under_node(struct memory_block *mem_blk, |
fc44f7f9 | 100 | int nid, bool check_nid) |
c04fc586 GH |
101 | { |
102 | return 0; | |
103 | } | |
d3360164 NF |
104 | static inline int unregister_mem_sect_under_nodes(struct memory_block *mem_blk, |
105 | unsigned long phys_index) | |
c04fc586 GH |
106 | { |
107 | return 0; | |
108 | } | |
9a305230 LS |
109 | |
110 | static inline void register_hugetlbfs_with_node(node_registration_func_t reg, | |
111 | node_registration_func_t unreg) | |
112 | { | |
113 | } | |
76b67ed9 | 114 | #endif |
1da177e4 | 115 | |
10fbcf4c | 116 | #define to_node(device) container_of(device, struct node, dev) |
1da177e4 LT |
117 | |
118 | #endif /* _LINUX_NODE_H_ */ |