Merge tag 'staging-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh...
[linux-2.6-block.git] / include / linux / node.h
CommitLineData
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
22struct 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 30struct memory_block;
8732794b 31extern struct node *node_devices[];
9a305230 32typedef void (*node_registration_func_t)(struct node *);
0fc44159 33
9037a993 34#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_NUMA)
a2155861
JC
35extern int link_mem_sections(int nid, unsigned long start_pfn,
36 unsigned long nr_pages, bool check_nid);
9037a993 37#else
a2155861
JC
38static inline int link_mem_sections(int nid, unsigned long start_pfn,
39 unsigned long nr_pages, bool check_nid)
9037a993
MH
40{
41 return 0;
42}
43#endif
44
4b45099b 45extern 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 */
48extern int __register_one_node(int nid);
49
50/* Registers an online node */
51static 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);
57
58 error = __register_one_node(nid);
59 if (error)
60 return error;
61 /* link memory sections under this node */
a2155861 62 error = link_mem_sections(nid, pgdat->node_start_pfn, pgdat->node_spanned_pages, true);
9037a993
MH
63 }
64
65 return error;
66}
67
0fc44159 68extern void unregister_one_node(int nid);
76b67ed9
KH
69extern int register_cpu_under_node(unsigned int cpu, unsigned int nid);
70extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid);
c04fc586 71extern int register_mem_sect_under_node(struct memory_block *mem_blk,
fc44f7f9 72 int nid, bool check_nid);
d3360164
NF
73extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
74 unsigned long phys_index);
9a305230
LS
75
76#ifdef CONFIG_HUGETLBFS
77extern void register_hugetlbfs_with_node(node_registration_func_t doregister,
78 node_registration_func_t unregister);
79#endif
76b67ed9 80#else
9037a993
MH
81static inline int __register_one_node(int nid)
82{
83 return 0;
84}
36920e06
KH
85static inline int register_one_node(int nid)
86{
87 return 0;
88}
89static inline int unregister_one_node(int nid)
90{
91 return 0;
92}
76b67ed9
KH
93static inline int register_cpu_under_node(unsigned int cpu, unsigned int nid)
94{
95 return 0;
96}
97static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
98{
99 return 0;
100}
c04fc586 101static inline int register_mem_sect_under_node(struct memory_block *mem_blk,
fc44f7f9 102 int nid, bool check_nid)
c04fc586
GH
103{
104 return 0;
105}
d3360164
NF
106static inline int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
107 unsigned long phys_index)
c04fc586
GH
108{
109 return 0;
110}
9a305230
LS
111
112static inline void register_hugetlbfs_with_node(node_registration_func_t reg,
113 node_registration_func_t unreg)
114{
115}
76b67ed9 116#endif
1da177e4 117
10fbcf4c 118#define to_node(device) container_of(device, struct node, dev)
1da177e4
LT
119
120#endif /* _LINUX_NODE_H_ */