1 /* SPDX-License-Identifier: GPL-2.0 */ 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 2 /* 3 * include/linux/node.h - generic node definit 3 * include/linux/node.h - generic node definition 4 * 4 * 5 * This is mainly for topological representati !! 5 * This is mainly for topological representation. We define the 6 * basic 'struct node' here, which can be embe !! 6 * basic 'struct node' here, which can be embedded in per-arch 7 * definitions of processors. 7 * definitions of processors. 8 * 8 * 9 * Basic handling of the devices is done in dr 9 * Basic handling of the devices is done in drivers/base/node.c 10 * and system devices are handled in drivers/b !! 10 * and system devices are handled in drivers/base/sys.c. 11 * 11 * 12 * Nodes are exported via driverfs in the clas 12 * Nodes are exported via driverfs in the class/node/devices/ 13 * directory. !! 13 * directory. 14 */ 14 */ 15 #ifndef _LINUX_NODE_H_ 15 #ifndef _LINUX_NODE_H_ 16 #define _LINUX_NODE_H_ 16 #define _LINUX_NODE_H_ 17 17 18 #include <linux/device.h> 18 #include <linux/device.h> >> 19 #include <linux/cpumask.h> 19 #include <linux/list.h> 20 #include <linux/list.h> >> 21 #include <linux/workqueue.h> 20 22 21 /** 23 /** 22 * struct access_coordinate - generic performa !! 24 * struct node_hmem_attrs - heterogeneous memory performance attributes 23 * 25 * 24 * @read_bandwidth: Read bandwidth in MB/s 26 * @read_bandwidth: Read bandwidth in MB/s 25 * @write_bandwidth: Write bandwidth in MB/ 27 * @write_bandwidth: Write bandwidth in MB/s 26 * @read_latency: Read latency in nanose 28 * @read_latency: Read latency in nanoseconds 27 * @write_latency: Write latency in nanos 29 * @write_latency: Write latency in nanoseconds 28 */ 30 */ 29 struct access_coordinate { !! 31 struct node_hmem_attrs { 30 unsigned int read_bandwidth; 32 unsigned int read_bandwidth; 31 unsigned int write_bandwidth; 33 unsigned int write_bandwidth; 32 unsigned int read_latency; 34 unsigned int read_latency; 33 unsigned int write_latency; 35 unsigned int write_latency; 34 }; 36 }; 35 37 36 /* << 37 * ACCESS_COORDINATE_LOCAL correlates to ACCES << 38 * - access_coordinate between target nod << 39 * ACCESS_COORDINATE_CPU correlates to ACCESS << 40 * - access_coordinate between target nod << 41 */ << 42 enum access_coordinate_class { << 43 ACCESS_COORDINATE_LOCAL, << 44 ACCESS_COORDINATE_CPU, << 45 ACCESS_COORDINATE_MAX << 46 }; << 47 << 48 enum cache_indexing { 38 enum cache_indexing { 49 NODE_CACHE_DIRECT_MAP, 39 NODE_CACHE_DIRECT_MAP, 50 NODE_CACHE_INDEXED, 40 NODE_CACHE_INDEXED, 51 NODE_CACHE_OTHER, 41 NODE_CACHE_OTHER, 52 }; 42 }; 53 43 54 enum cache_write_policy { 44 enum cache_write_policy { 55 NODE_CACHE_WRITE_BACK, 45 NODE_CACHE_WRITE_BACK, 56 NODE_CACHE_WRITE_THROUGH, 46 NODE_CACHE_WRITE_THROUGH, 57 NODE_CACHE_WRITE_OTHER, 47 NODE_CACHE_WRITE_OTHER, 58 }; 48 }; 59 49 60 /** 50 /** 61 * struct node_cache_attrs - system memory cac 51 * struct node_cache_attrs - system memory caching attributes 62 * 52 * 63 * @indexing: The ways memory blocks 53 * @indexing: The ways memory blocks may be placed in cache 64 * @write_policy: Write back or write th 54 * @write_policy: Write back or write through policy 65 * @size: Total size of cache in 55 * @size: Total size of cache in bytes 66 * @line_size: Number of bytes fetche 56 * @line_size: Number of bytes fetched on a cache miss 67 * @level: The cache hierarchy le 57 * @level: The cache hierarchy level 68 */ 58 */ 69 struct node_cache_attrs { 59 struct node_cache_attrs { 70 enum cache_indexing indexing; 60 enum cache_indexing indexing; 71 enum cache_write_policy write_policy; 61 enum cache_write_policy write_policy; 72 u64 size; 62 u64 size; 73 u16 line_size; 63 u16 line_size; 74 u8 level; 64 u8 level; 75 }; 65 }; 76 66 77 #ifdef CONFIG_HMEM_REPORTING 67 #ifdef CONFIG_HMEM_REPORTING 78 void node_add_cache(unsigned int nid, struct n 68 void node_add_cache(unsigned int nid, struct node_cache_attrs *cache_attrs); 79 void node_set_perf_attrs(unsigned int nid, str !! 69 void node_set_perf_attrs(unsigned int nid, struct node_hmem_attrs *hmem_attrs, 80 enum access_coordinat !! 70 unsigned access); 81 #else 71 #else 82 static inline void node_add_cache(unsigned int 72 static inline void node_add_cache(unsigned int nid, 83 struct node_ 73 struct node_cache_attrs *cache_attrs) 84 { 74 { 85 } 75 } 86 76 87 static inline void node_set_perf_attrs(unsigne 77 static inline void node_set_perf_attrs(unsigned int nid, 88 struct !! 78 struct node_hmem_attrs *hmem_attrs, 89 enum ac !! 79 unsigned access) 90 { 80 { 91 } 81 } 92 #endif 82 #endif 93 83 94 struct node { 84 struct node { 95 struct device dev; 85 struct device dev; 96 struct list_head access_list; 86 struct list_head access_list; >> 87 >> 88 #if defined(CONFIG_MEMORY_HOTPLUG) && defined(CONFIG_HUGETLBFS) >> 89 struct work_struct node_work; >> 90 #endif 97 #ifdef CONFIG_HMEM_REPORTING 91 #ifdef CONFIG_HMEM_REPORTING 98 struct list_head cache_attrs; 92 struct list_head cache_attrs; 99 struct device *cache_dev; 93 struct device *cache_dev; 100 #endif 94 #endif 101 }; 95 }; 102 96 103 struct memory_block; 97 struct memory_block; 104 extern struct node *node_devices[]; 98 extern struct node *node_devices[]; >> 99 typedef void (*node_registration_func_t)(struct node *); 105 100 106 #if defined(CONFIG_MEMORY_HOTPLUG) && defined( 101 #if defined(CONFIG_MEMORY_HOTPLUG) && defined(CONFIG_NUMA) 107 void register_memory_blocks_under_node(int nid 102 void register_memory_blocks_under_node(int nid, unsigned long start_pfn, 108 unsigne 103 unsigned long end_pfn, 109 enum me 104 enum meminit_context context); 110 #else 105 #else 111 static inline void register_memory_blocks_unde 106 static inline void register_memory_blocks_under_node(int nid, unsigned long start_pfn, 112 107 unsigned long end_pfn, 113 108 enum meminit_context context) 114 { 109 { 115 } 110 } 116 #endif 111 #endif 117 112 118 extern void unregister_node(struct node *node) 113 extern void unregister_node(struct node *node); 119 #ifdef CONFIG_NUMA 114 #ifdef CONFIG_NUMA 120 extern void node_dev_init(void); 115 extern void node_dev_init(void); 121 /* Core of the node registration - only memory 116 /* Core of the node registration - only memory hotplug should use this */ 122 extern int __register_one_node(int nid); 117 extern int __register_one_node(int nid); 123 118 124 /* Registers an online node */ 119 /* Registers an online node */ 125 static inline int register_one_node(int nid) 120 static inline int register_one_node(int nid) 126 { 121 { 127 int error = 0; 122 int error = 0; 128 123 129 if (node_online(nid)) { 124 if (node_online(nid)) { 130 struct pglist_data *pgdat = NO 125 struct pglist_data *pgdat = NODE_DATA(nid); 131 unsigned long start_pfn = pgda 126 unsigned long start_pfn = pgdat->node_start_pfn; 132 unsigned long end_pfn = start_ 127 unsigned long end_pfn = start_pfn + pgdat->node_spanned_pages; 133 128 134 error = __register_one_node(ni 129 error = __register_one_node(nid); 135 if (error) 130 if (error) 136 return error; 131 return error; 137 register_memory_blocks_under_n 132 register_memory_blocks_under_node(nid, start_pfn, end_pfn, 138 133 MEMINIT_EARLY); 139 } 134 } 140 135 141 return error; 136 return error; 142 } 137 } 143 138 144 extern void unregister_one_node(int nid); 139 extern void unregister_one_node(int nid); 145 extern int register_cpu_under_node(unsigned in 140 extern int register_cpu_under_node(unsigned int cpu, unsigned int nid); 146 extern int unregister_cpu_under_node(unsigned 141 extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid); 147 extern void unregister_memory_block_under_node 142 extern void unregister_memory_block_under_nodes(struct memory_block *mem_blk); 148 143 149 extern int register_memory_node_under_compute_ 144 extern int register_memory_node_under_compute_node(unsigned int mem_nid, 150 145 unsigned int cpu_nid, 151 !! 146 unsigned access); >> 147 >> 148 #ifdef CONFIG_HUGETLBFS >> 149 extern void register_hugetlbfs_with_node(node_registration_func_t doregister, >> 150 node_registration_func_t unregister); >> 151 #endif 152 #else 152 #else 153 static inline void node_dev_init(void) 153 static inline void node_dev_init(void) 154 { 154 { 155 } 155 } 156 static inline int __register_one_node(int nid) 156 static inline int __register_one_node(int nid) 157 { 157 { 158 return 0; 158 return 0; 159 } 159 } 160 static inline int register_one_node(int nid) 160 static inline int register_one_node(int nid) 161 { 161 { 162 return 0; 162 return 0; 163 } 163 } 164 static inline int unregister_one_node(int nid) 164 static inline int unregister_one_node(int nid) 165 { 165 { 166 return 0; 166 return 0; 167 } 167 } 168 static inline int register_cpu_under_node(unsi 168 static inline int register_cpu_under_node(unsigned int cpu, unsigned int nid) 169 { 169 { 170 return 0; 170 return 0; 171 } 171 } 172 static inline int unregister_cpu_under_node(un 172 static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid) 173 { 173 { 174 return 0; 174 return 0; 175 } 175 } 176 static inline void unregister_memory_block_und 176 static inline void unregister_memory_block_under_nodes(struct memory_block *mem_blk) 177 { 177 { 178 } 178 } >> 179 >> 180 static inline void register_hugetlbfs_with_node(node_registration_func_t reg, >> 181 node_registration_func_t unreg) >> 182 { >> 183 } 179 #endif 184 #endif 180 185 181 #define to_node(device) container_of(device, s 186 #define to_node(device) container_of(device, struct node, dev) >> 187 >> 188 static inline bool node_is_toptier(int node) >> 189 { >> 190 return node_state(node, N_CPU); >> 191 } 182 192 183 #endif /* _LINUX_NODE_H_ */ 193 #endif /* _LINUX_NODE_H_ */ 184 194
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.