1 /* SPDX-License-Identifier: GPL-2.0 */
3 * include/linux/node.h - generic node definition
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.
9 * Basic handling of the devices is done in drivers/base/node.c
10 * and system devices are handled in drivers/base/sys.c.
12 * Nodes are exported via driverfs in the class/node/devices/
15 #ifndef _LINUX_NODE_H_
16 #define _LINUX_NODE_H_
18 #include <linux/device.h>
19 #include <linux/cpumask.h>
20 #include <linux/workqueue.h>
25 #if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS)
26 struct work_struct node_work;
31 extern struct node *node_devices[];
32 typedef void (*node_registration_func_t)(struct node *);
34 #if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_NUMA)
35 extern int link_mem_sections(int nid, unsigned long start_pfn,
36 unsigned long nr_pages, bool check_nid);
38 static inline int link_mem_sections(int nid, unsigned long start_pfn,
39 unsigned long nr_pages, bool check_nid)
45 extern void unregister_node(struct node *node);
47 /* Core of the node registration - only memory hotplug should use this */
48 extern int __register_one_node(int nid);
50 /* Registers an online node */
51 static inline int register_one_node(int nid)
55 if (node_online(nid)) {
56 struct pglist_data *pgdat = NODE_DATA(nid);
58 error = __register_one_node(nid);
61 /* link memory sections under this node */
62 error = link_mem_sections(nid, pgdat->node_start_pfn, pgdat->node_spanned_pages, true);
68 extern void unregister_one_node(int nid);
69 extern int register_cpu_under_node(unsigned int cpu, unsigned int nid);
70 extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid);
71 extern int register_mem_sect_under_node(struct memory_block *mem_blk,
72 int nid, bool check_nid);
73 extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
74 unsigned long phys_index);
76 #ifdef CONFIG_HUGETLBFS
77 extern void register_hugetlbfs_with_node(node_registration_func_t doregister,
78 node_registration_func_t unregister);
81 static inline int __register_one_node(int nid)
85 static inline int register_one_node(int nid)
89 static inline int unregister_one_node(int nid)
93 static inline int register_cpu_under_node(unsigned int cpu, unsigned int nid)
97 static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
101 static inline int register_mem_sect_under_node(struct memory_block *mem_blk,
102 int nid, bool check_nid)
106 static inline int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
107 unsigned long phys_index)
112 static inline void register_hugetlbfs_with_node(node_registration_func_t reg,
113 node_registration_func_t unreg)
118 #define to_node(device) container_of(device, struct node, dev)
120 #endif /* _LINUX_NODE_H_ */