]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - include/linux/node.h
node: Add heterogenous memory access attributes
[mirror_ubuntu-jammy-kernel.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>
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 */
31struct 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
38#ifdef CONFIG_HMEM_REPORTING
39void node_set_perf_attrs(unsigned int nid, struct node_hmem_attrs *hmem_attrs,
40 unsigned access);
41#else
42static inline void node_set_perf_attrs(unsigned int nid,
43 struct node_hmem_attrs *hmem_attrs,
44 unsigned access)
45{
46}
47#endif
48
1da177e4 49struct node {
10fbcf4c 50 struct device dev;
08d9dbe7 51 struct list_head access_list;
39da08cb
LS
52
53#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS)
54 struct work_struct node_work;
55#endif
1da177e4
LT
56};
57
c04fc586 58struct memory_block;
8732794b 59extern struct node *node_devices[];
9a305230 60typedef void (*node_registration_func_t)(struct node *);
0fc44159 61
9037a993 62#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_NUMA)
a2155861 63extern int link_mem_sections(int nid, unsigned long start_pfn,
4fbce633 64 unsigned long end_pfn);
9037a993 65#else
a2155861 66static inline int link_mem_sections(int nid, unsigned long start_pfn,
4fbce633 67 unsigned long end_pfn)
9037a993
MH
68{
69 return 0;
70}
71#endif
72
4b45099b 73extern void unregister_node(struct node *node);
36920e06 74#ifdef CONFIG_NUMA
9037a993
MH
75/* Core of the node registration - only memory hotplug should use this */
76extern int __register_one_node(int nid);
77
78/* Registers an online node */
79static inline int register_one_node(int nid)
80{
81 int error = 0;
82
83 if (node_online(nid)) {
84 struct pglist_data *pgdat = NODE_DATA(nid);
4fbce633
OS
85 unsigned long start_pfn = pgdat->node_start_pfn;
86 unsigned long end_pfn = start_pfn + pgdat->node_spanned_pages;
9037a993
MH
87
88 error = __register_one_node(nid);
89 if (error)
90 return error;
91 /* link memory sections under this node */
4fbce633 92 error = link_mem_sections(nid, start_pfn, end_pfn);
9037a993
MH
93 }
94
95 return error;
96}
97
0fc44159 98extern void unregister_one_node(int nid);
76b67ed9
KH
99extern int register_cpu_under_node(unsigned int cpu, unsigned int nid);
100extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid);
c04fc586 101extern int register_mem_sect_under_node(struct memory_block *mem_blk,
4fbce633 102 void *arg);
d3360164
NF
103extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
104 unsigned long phys_index);
9a305230 105
08d9dbe7
KB
106extern int register_memory_node_under_compute_node(unsigned int mem_nid,
107 unsigned int cpu_nid,
108 unsigned access);
109
9a305230
LS
110#ifdef CONFIG_HUGETLBFS
111extern void register_hugetlbfs_with_node(node_registration_func_t doregister,
112 node_registration_func_t unregister);
113#endif
76b67ed9 114#else
9037a993
MH
115static inline int __register_one_node(int nid)
116{
117 return 0;
118}
36920e06
KH
119static inline int register_one_node(int nid)
120{
121 return 0;
122}
123static inline int unregister_one_node(int nid)
124{
125 return 0;
126}
76b67ed9
KH
127static inline int register_cpu_under_node(unsigned int cpu, unsigned int nid)
128{
129 return 0;
130}
131static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
132{
133 return 0;
134}
c04fc586 135static inline int register_mem_sect_under_node(struct memory_block *mem_blk,
4fbce633 136 void *arg)
c04fc586
GH
137{
138 return 0;
139}
d3360164
NF
140static inline int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
141 unsigned long phys_index)
c04fc586
GH
142{
143 return 0;
144}
9a305230
LS
145
146static inline void register_hugetlbfs_with_node(node_registration_func_t reg,
147 node_registration_func_t unreg)
148{
149}
76b67ed9 150#endif
1da177e4 151
10fbcf4c 152#define to_node(device) container_of(device, struct node, dev)
1da177e4
LT
153
154#endif /* _LINUX_NODE_H_ */