1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef _LINUX_NODE_H_
16#define _LINUX_NODE_H_
17
18#include <linux/device.h>
19#include <linux/cpumask.h>
20#include <linux/list.h>
21#include <linux/workqueue.h>
22
23
24
25
26
27
28
29
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
38enum cache_indexing {
39 NODE_CACHE_DIRECT_MAP,
40 NODE_CACHE_INDEXED,
41 NODE_CACHE_OTHER,
42};
43
44enum cache_write_policy {
45 NODE_CACHE_WRITE_BACK,
46 NODE_CACHE_WRITE_THROUGH,
47 NODE_CACHE_WRITE_OTHER,
48};
49
50
51
52
53
54
55
56
57
58
59struct 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
67#ifdef CONFIG_HMEM_REPORTING
68void node_add_cache(unsigned int nid, struct node_cache_attrs *cache_attrs);
69void node_set_perf_attrs(unsigned int nid, struct node_hmem_attrs *hmem_attrs,
70 unsigned access);
71#else
72static inline void node_add_cache(unsigned int nid,
73 struct node_cache_attrs *cache_attrs)
74{
75}
76
77static inline void node_set_perf_attrs(unsigned int nid,
78 struct node_hmem_attrs *hmem_attrs,
79 unsigned access)
80{
81}
82#endif
83
84struct node {
85 struct device dev;
86 struct list_head access_list;
87
88#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS)
89 struct work_struct node_work;
90#endif
91#ifdef CONFIG_HMEM_REPORTING
92 struct list_head cache_attrs;
93 struct device *cache_dev;
94#endif
95};
96
97struct memory_block;
98extern struct node *node_devices[];
99typedef void (*node_registration_func_t)(struct node *);
100
101#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_NUMA)
102extern int link_mem_sections(int nid, unsigned long start_pfn,
103 unsigned long end_pfn);
104#else
105static inline int link_mem_sections(int nid, unsigned long start_pfn,
106 unsigned long end_pfn)
107{
108 return 0;
109}
110#endif
111
112extern void unregister_node(struct node *node);
113#ifdef CONFIG_NUMA
114
115extern int __register_one_node(int nid);
116
117
118static inline int register_one_node(int nid)
119{
120 int error = 0;
121
122 if (node_online(nid)) {
123 struct pglist_data *pgdat = NODE_DATA(nid);
124 unsigned long start_pfn = pgdat->node_start_pfn;
125 unsigned long end_pfn = start_pfn + pgdat->node_spanned_pages;
126
127 error = __register_one_node(nid);
128 if (error)
129 return error;
130
131 error = link_mem_sections(nid, start_pfn, end_pfn);
132 }
133
134 return error;
135}
136
137extern void unregister_one_node(int nid);
138extern int register_cpu_under_node(unsigned int cpu, unsigned int nid);
139extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid);
140extern void unregister_memory_block_under_nodes(struct memory_block *mem_blk);
141
142extern int register_memory_node_under_compute_node(unsigned int mem_nid,
143 unsigned int cpu_nid,
144 unsigned access);
145
146#ifdef CONFIG_HUGETLBFS
147extern void register_hugetlbfs_with_node(node_registration_func_t doregister,
148 node_registration_func_t unregister);
149#endif
150#else
151static inline int __register_one_node(int nid)
152{
153 return 0;
154}
155static inline int register_one_node(int nid)
156{
157 return 0;
158}
159static inline int unregister_one_node(int nid)
160{
161 return 0;
162}
163static inline int register_cpu_under_node(unsigned int cpu, unsigned int nid)
164{
165 return 0;
166}
167static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
168{
169 return 0;
170}
171static inline void unregister_memory_block_under_nodes(struct memory_block *mem_blk)
172{
173}
174
175static inline void register_hugetlbfs_with_node(node_registration_func_t reg,
176 node_registration_func_t unreg)
177{
178}
179#endif
180
181#define to_node(device) container_of(device, struct node, dev)
182
183#endif
184