]>
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> |
08d9dbe7 | 20 | #include <linux/list.h> |
39da08cb | 21 | #include <linux/workqueue.h> |
1da177e4 | 22 | |
e1cf33aa KB |
23 | /** |
24 | * struct node_hmem_attrs - heterogeneous memory performance attributes | |
25 | * | |
26 | * @read_bandwidth: Read bandwidth in MB/s | |
27 | * @write_bandwidth: Write bandwidth in MB/s | |
28 | * @read_latency: Read latency in nanoseconds | |
29 | * @write_latency: Write latency in nanoseconds | |
30 | */ | |
31 | struct node_hmem_attrs { | |
32 | unsigned int read_bandwidth; | |
33 | unsigned int write_bandwidth; | |
34 | unsigned int read_latency; | |
35 | unsigned int write_latency; | |
36 | }; | |
37 | ||
acc02a10 KB |
38 | enum cache_indexing { |
39 | NODE_CACHE_DIRECT_MAP, | |
40 | NODE_CACHE_INDEXED, | |
41 | NODE_CACHE_OTHER, | |
42 | }; | |
43 | ||
44 | enum cache_write_policy { | |
45 | NODE_CACHE_WRITE_BACK, | |
46 | NODE_CACHE_WRITE_THROUGH, | |
47 | NODE_CACHE_WRITE_OTHER, | |
48 | }; | |
49 | ||
50 | /** | |
51 | * struct node_cache_attrs - system memory caching attributes | |
52 | * | |
53 | * @indexing: The ways memory blocks may be placed in cache | |
54 | * @write_policy: Write back or write through policy | |
55 | * @size: Total size of cache in bytes | |
56 | * @line_size: Number of bytes fetched on a cache miss | |
57 | * @level: The cache hierarchy level | |
58 | */ | |
59 | struct node_cache_attrs { | |
60 | enum cache_indexing indexing; | |
61 | enum cache_write_policy write_policy; | |
62 | u64 size; | |
63 | u16 line_size; | |
64 | u8 level; | |
65 | }; | |
66 | ||
e1cf33aa | 67 | #ifdef CONFIG_HMEM_REPORTING |
acc02a10 | 68 | void node_add_cache(unsigned int nid, struct node_cache_attrs *cache_attrs); |
e1cf33aa KB |
69 | void node_set_perf_attrs(unsigned int nid, struct node_hmem_attrs *hmem_attrs, |
70 | unsigned access); | |
71 | #else | |
acc02a10 KB |
72 | static inline void node_add_cache(unsigned int nid, |
73 | struct node_cache_attrs *cache_attrs) | |
74 | { | |
75 | } | |
76 | ||
e1cf33aa KB |
77 | static inline void node_set_perf_attrs(unsigned int nid, |
78 | struct node_hmem_attrs *hmem_attrs, | |
79 | unsigned access) | |
80 | { | |
81 | } | |
82 | #endif | |
83 | ||
1da177e4 | 84 | struct node { |
10fbcf4c | 85 | struct device dev; |
08d9dbe7 | 86 | struct list_head access_list; |
39da08cb | 87 | |
50f9481e | 88 | #if defined(CONFIG_MEMORY_HOTPLUG) && defined(CONFIG_HUGETLBFS) |
39da08cb LS |
89 | struct work_struct node_work; |
90 | #endif | |
acc02a10 KB |
91 | #ifdef CONFIG_HMEM_REPORTING |
92 | struct list_head cache_attrs; | |
93 | struct device *cache_dev; | |
94 | #endif | |
1da177e4 LT |
95 | }; |
96 | ||
c04fc586 | 97 | struct memory_block; |
8732794b | 98 | extern struct node *node_devices[]; |
9a305230 | 99 | typedef void (*node_registration_func_t)(struct node *); |
0fc44159 | 100 | |
50f9481e | 101 | #if defined(CONFIG_MEMORY_HOTPLUG) && defined(CONFIG_NUMA) |
90c7eaeb LD |
102 | void link_mem_sections(int nid, unsigned long start_pfn, |
103 | unsigned long end_pfn, | |
104 | enum meminit_context context); | |
9037a993 | 105 | #else |
90c7eaeb LD |
106 | static inline void link_mem_sections(int nid, unsigned long start_pfn, |
107 | unsigned long end_pfn, | |
108 | enum meminit_context context) | |
9037a993 | 109 | { |
9037a993 MH |
110 | } |
111 | #endif | |
112 | ||
4b45099b | 113 | extern void unregister_node(struct node *node); |
36920e06 | 114 | #ifdef CONFIG_NUMA |
9037a993 MH |
115 | /* Core of the node registration - only memory hotplug should use this */ |
116 | extern int __register_one_node(int nid); | |
117 | ||
118 | /* Registers an online node */ | |
119 | static inline int register_one_node(int nid) | |
120 | { | |
121 | int error = 0; | |
122 | ||
123 | if (node_online(nid)) { | |
124 | struct pglist_data *pgdat = NODE_DATA(nid); | |
4fbce633 OS |
125 | unsigned long start_pfn = pgdat->node_start_pfn; |
126 | unsigned long end_pfn = start_pfn + pgdat->node_spanned_pages; | |
9037a993 MH |
127 | |
128 | error = __register_one_node(nid); | |
129 | if (error) | |
130 | return error; | |
131 | /* link memory sections under this node */ | |
90c7eaeb | 132 | link_mem_sections(nid, start_pfn, end_pfn, MEMINIT_EARLY); |
9037a993 MH |
133 | } |
134 | ||
135 | return error; | |
136 | } | |
137 | ||
0fc44159 | 138 | extern void unregister_one_node(int nid); |
76b67ed9 KH |
139 | extern int register_cpu_under_node(unsigned int cpu, unsigned int nid); |
140 | extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid); | |
a31b264c | 141 | extern void unregister_memory_block_under_nodes(struct memory_block *mem_blk); |
9a305230 | 142 | |
08d9dbe7 KB |
143 | extern int register_memory_node_under_compute_node(unsigned int mem_nid, |
144 | unsigned int cpu_nid, | |
145 | unsigned access); | |
146 | ||
9a305230 LS |
147 | #ifdef CONFIG_HUGETLBFS |
148 | extern void register_hugetlbfs_with_node(node_registration_func_t doregister, | |
149 | node_registration_func_t unregister); | |
150 | #endif | |
76b67ed9 | 151 | #else |
9037a993 MH |
152 | static inline int __register_one_node(int nid) |
153 | { | |
154 | return 0; | |
155 | } | |
36920e06 KH |
156 | static inline int register_one_node(int nid) |
157 | { | |
158 | return 0; | |
159 | } | |
160 | static inline int unregister_one_node(int nid) | |
161 | { | |
162 | return 0; | |
163 | } | |
76b67ed9 KH |
164 | static inline int register_cpu_under_node(unsigned int cpu, unsigned int nid) |
165 | { | |
166 | return 0; | |
167 | } | |
168 | static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid) | |
169 | { | |
170 | return 0; | |
171 | } | |
a31b264c | 172 | static inline void unregister_memory_block_under_nodes(struct memory_block *mem_blk) |
c04fc586 | 173 | { |
c04fc586 | 174 | } |
9a305230 LS |
175 | |
176 | static inline void register_hugetlbfs_with_node(node_registration_func_t reg, | |
177 | node_registration_func_t unreg) | |
178 | { | |
179 | } | |
76b67ed9 | 180 | #endif |
1da177e4 | 181 | |
10fbcf4c | 182 | #define to_node(device) container_of(device, struct node, dev) |
1da177e4 LT |
183 | |
184 | #endif /* _LINUX_NODE_H_ */ |