Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / include / linux / node.h
blob4ece0fee0ffc9744286b22b2d6f1d41cba9f5418
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
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/
13 * directory.
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>
22 struct node {
23 struct device dev;
25 #if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS)
26 struct work_struct node_work;
27 #endif
30 struct memory_block;
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, unsigned long nr_pages);
36 #else
37 static inline int link_mem_sections(int nid, unsigned long start_pfn, unsigned long nr_pages)
39 return 0;
41 #endif
43 extern void unregister_node(struct node *node);
44 #ifdef CONFIG_NUMA
45 /* Core of the node registration - only memory hotplug should use this */
46 extern int __register_one_node(int nid);
48 /* Registers an online node */
49 static inline int register_one_node(int nid)
51 int error = 0;
53 if (node_online(nid)) {
54 struct pglist_data *pgdat = NODE_DATA(nid);
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);
63 return error;
66 extern void unregister_one_node(int nid);
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);
69 extern int register_mem_sect_under_node(struct memory_block *mem_blk,
70 int nid);
71 extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
72 unsigned long phys_index);
74 #ifdef CONFIG_HUGETLBFS
75 extern void register_hugetlbfs_with_node(node_registration_func_t doregister,
76 node_registration_func_t unregister);
77 #endif
78 #else
79 static inline int __register_one_node(int nid)
81 return 0;
83 static inline int register_one_node(int nid)
85 return 0;
87 static inline int unregister_one_node(int nid)
89 return 0;
91 static inline int register_cpu_under_node(unsigned int cpu, unsigned int nid)
93 return 0;
95 static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
97 return 0;
99 static inline int register_mem_sect_under_node(struct memory_block *mem_blk,
100 int nid)
102 return 0;
104 static inline int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
105 unsigned long phys_index)
107 return 0;
110 static inline void register_hugetlbfs_with_node(node_registration_func_t reg,
111 node_registration_func_t unreg)
114 #endif
116 #define to_node(device) container_of(device, struct node, dev)
118 #endif /* _LINUX_NODE_H_ */