]>
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 | 34 | #if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_NUMA) |
a2155861 | 35 | extern int link_mem_sections(int nid, unsigned long start_pfn, |
4fbce633 | 36 | unsigned long end_pfn); |
9037a993 | 37 | #else |
a2155861 | 38 | static inline int link_mem_sections(int nid, unsigned long start_pfn, |
4fbce633 | 39 | unsigned long end_pfn) |
9037a993 MH |
40 | { |
41 | return 0; | |
42 | } | |
43 | #endif | |
44 | ||
4b45099b | 45 | extern void unregister_node(struct node *node); |
36920e06 | 46 | #ifdef CONFIG_NUMA |
9037a993 MH |
47 | /* Core of the node registration - only memory hotplug should use this */ |
48 | extern int __register_one_node(int nid); | |
49 | ||
50 | /* Registers an online node */ | |
51 | static inline int register_one_node(int nid) | |
52 | { | |
53 | int error = 0; | |
54 | ||
55 | if (node_online(nid)) { | |
56 | struct pglist_data *pgdat = NODE_DATA(nid); | |
4fbce633 OS |
57 | unsigned long start_pfn = pgdat->node_start_pfn; |
58 | unsigned long end_pfn = start_pfn + pgdat->node_spanned_pages; | |
9037a993 MH |
59 | |
60 | error = __register_one_node(nid); | |
61 | if (error) | |
62 | return error; | |
63 | /* link memory sections under this node */ | |
4fbce633 | 64 | error = link_mem_sections(nid, start_pfn, end_pfn); |
9037a993 MH |
65 | } |
66 | ||
67 | return error; | |
68 | } | |
69 | ||
0fc44159 | 70 | extern void unregister_one_node(int nid); |
76b67ed9 KH |
71 | extern int register_cpu_under_node(unsigned int cpu, unsigned int nid); |
72 | extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid); | |
c04fc586 | 73 | extern int register_mem_sect_under_node(struct memory_block *mem_blk, |
4fbce633 | 74 | void *arg); |
d3360164 NF |
75 | extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk, |
76 | unsigned long phys_index); | |
9a305230 LS |
77 | |
78 | #ifdef CONFIG_HUGETLBFS | |
79 | extern void register_hugetlbfs_with_node(node_registration_func_t doregister, | |
80 | node_registration_func_t unregister); | |
81 | #endif | |
76b67ed9 | 82 | #else |
9037a993 MH |
83 | static inline int __register_one_node(int nid) |
84 | { | |
85 | return 0; | |
86 | } | |
36920e06 KH |
87 | static inline int register_one_node(int nid) |
88 | { | |
89 | return 0; | |
90 | } | |
91 | static inline int unregister_one_node(int nid) | |
92 | { | |
93 | return 0; | |
94 | } | |
76b67ed9 KH |
95 | static inline int register_cpu_under_node(unsigned int cpu, unsigned int nid) |
96 | { | |
97 | return 0; | |
98 | } | |
99 | static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid) | |
100 | { | |
101 | return 0; | |
102 | } | |
c04fc586 | 103 | static inline int register_mem_sect_under_node(struct memory_block *mem_blk, |
4fbce633 | 104 | void *arg) |
c04fc586 GH |
105 | { |
106 | return 0; | |
107 | } | |
d3360164 NF |
108 | static inline int unregister_mem_sect_under_nodes(struct memory_block *mem_blk, |
109 | unsigned long phys_index) | |
c04fc586 GH |
110 | { |
111 | return 0; | |
112 | } | |
9a305230 LS |
113 | |
114 | static inline void register_hugetlbfs_with_node(node_registration_func_t reg, | |
115 | node_registration_func_t unreg) | |
116 | { | |
117 | } | |
76b67ed9 | 118 | #endif |
1da177e4 | 119 | |
10fbcf4c | 120 | #define to_node(device) container_of(device, struct node, dev) |
1da177e4 LT |
121 | |
122 | #endif /* _LINUX_NODE_H_ */ |