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/list.h> !! 19 #include <linux/cpumask.h> 20 !! 20 #include <linux/workqueue.h> 21 /** << 22 * struct access_coordinate - generic performa << 23 * << 24 * @read_bandwidth: Read bandwidth in MB/s << 25 * @write_bandwidth: Write bandwidth in MB/ << 26 * @read_latency: Read latency in nanose << 27 * @write_latency: Write latency in nanos << 28 */ << 29 struct access_coordinate { << 30 unsigned int read_bandwidth; << 31 unsigned int write_bandwidth; << 32 unsigned int read_latency; << 33 unsigned int write_latency; << 34 }; << 35 << 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 { << 49 NODE_CACHE_DIRECT_MAP, << 50 NODE_CACHE_INDEXED, << 51 NODE_CACHE_OTHER, << 52 }; << 53 << 54 enum cache_write_policy { << 55 NODE_CACHE_WRITE_BACK, << 56 NODE_CACHE_WRITE_THROUGH, << 57 NODE_CACHE_WRITE_OTHER, << 58 }; << 59 << 60 /** << 61 * struct node_cache_attrs - system memory cac << 62 * << 63 * @indexing: The ways memory blocks << 64 * @write_policy: Write back or write th << 65 * @size: Total size of cache in << 66 * @line_size: Number of bytes fetche << 67 * @level: The cache hierarchy le << 68 */ << 69 struct node_cache_attrs { << 70 enum cache_indexing indexing; << 71 enum cache_write_policy write_policy; << 72 u64 size; << 73 u16 line_size; << 74 u8 level; << 75 }; << 76 << 77 #ifdef CONFIG_HMEM_REPORTING << 78 void node_add_cache(unsigned int nid, struct n << 79 void node_set_perf_attrs(unsigned int nid, str << 80 enum access_coordinat << 81 #else << 82 static inline void node_add_cache(unsigned int << 83 struct node_ << 84 { << 85 } << 86 << 87 static inline void node_set_perf_attrs(unsigne << 88 struct << 89 enum ac << 90 { << 91 } << 92 #endif << 93 21 94 struct node { 22 struct node { 95 struct device dev; 23 struct device dev; 96 struct list_head access_list; !! 24 97 #ifdef CONFIG_HMEM_REPORTING !! 25 #if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS) 98 struct list_head cache_attrs; !! 26 struct work_struct node_work; 99 struct device *cache_dev; << 100 #endif 27 #endif 101 }; 28 }; 102 29 103 struct memory_block; 30 struct memory_block; 104 extern struct node *node_devices[]; 31 extern struct node *node_devices[]; >> 32 typedef void (*node_registration_func_t)(struct node *); 105 33 106 #if defined(CONFIG_MEMORY_HOTPLUG) && defined( !! 34 #if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_NUMA) 107 void register_memory_blocks_under_node(int nid !! 35 extern int link_mem_sections(int nid, unsigned long start_pfn, 108 unsigne !! 36 unsigned long end_pfn); 109 enum me << 110 #else 37 #else 111 static inline void register_memory_blocks_unde !! 38 static inline int link_mem_sections(int nid, unsigned long start_pfn, 112 !! 39 unsigned long end_pfn) 113 << 114 { 40 { >> 41 return 0; 115 } 42 } 116 #endif 43 #endif 117 44 118 extern void unregister_node(struct node *node) 45 extern void unregister_node(struct node *node); 119 #ifdef CONFIG_NUMA 46 #ifdef CONFIG_NUMA 120 extern void node_dev_init(void); << 121 /* Core of the node registration - only memory 47 /* Core of the node registration - only memory hotplug should use this */ 122 extern int __register_one_node(int nid); 48 extern int __register_one_node(int nid); 123 49 124 /* Registers an online node */ 50 /* Registers an online node */ 125 static inline int register_one_node(int nid) 51 static inline int register_one_node(int nid) 126 { 52 { 127 int error = 0; 53 int error = 0; 128 54 129 if (node_online(nid)) { 55 if (node_online(nid)) { 130 struct pglist_data *pgdat = NO 56 struct pglist_data *pgdat = NODE_DATA(nid); 131 unsigned long start_pfn = pgda 57 unsigned long start_pfn = pgdat->node_start_pfn; 132 unsigned long end_pfn = start_ 58 unsigned long end_pfn = start_pfn + pgdat->node_spanned_pages; 133 59 134 error = __register_one_node(ni 60 error = __register_one_node(nid); 135 if (error) 61 if (error) 136 return error; 62 return error; 137 register_memory_blocks_under_n !! 63 /* link memory sections under this node */ 138 !! 64 error = link_mem_sections(nid, start_pfn, end_pfn); 139 } 65 } 140 66 141 return error; 67 return error; 142 } 68 } 143 69 144 extern void unregister_one_node(int nid); 70 extern void unregister_one_node(int nid); 145 extern int register_cpu_under_node(unsigned in 71 extern int register_cpu_under_node(unsigned int cpu, unsigned int nid); 146 extern int unregister_cpu_under_node(unsigned 72 extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid); 147 extern void unregister_memory_block_under_node !! 73 extern int register_mem_sect_under_node(struct memory_block *mem_blk, 148 !! 74 void *arg); 149 extern int register_memory_node_under_compute_ !! 75 extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk, 150 !! 76 unsigned long phys_index); 151 !! 77 >> 78 #ifdef CONFIG_HUGETLBFS >> 79 extern void register_hugetlbfs_with_node(node_registration_func_t doregister, >> 80 node_registration_func_t unregister); >> 81 #endif 152 #else 82 #else 153 static inline void node_dev_init(void) << 154 { << 155 } << 156 static inline int __register_one_node(int nid) 83 static inline int __register_one_node(int nid) 157 { 84 { 158 return 0; 85 return 0; 159 } 86 } 160 static inline int register_one_node(int nid) 87 static inline int register_one_node(int nid) 161 { 88 { 162 return 0; 89 return 0; 163 } 90 } 164 static inline int unregister_one_node(int nid) 91 static inline int unregister_one_node(int nid) 165 { 92 { 166 return 0; 93 return 0; 167 } 94 } 168 static inline int register_cpu_under_node(unsi 95 static inline int register_cpu_under_node(unsigned int cpu, unsigned int nid) 169 { 96 { 170 return 0; 97 return 0; 171 } 98 } 172 static inline int unregister_cpu_under_node(un 99 static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid) 173 { 100 { 174 return 0; 101 return 0; 175 } 102 } 176 static inline void unregister_memory_block_und !! 103 static inline int register_mem_sect_under_node(struct memory_block *mem_blk, >> 104 void *arg) >> 105 { >> 106 return 0; >> 107 } >> 108 static inline int unregister_mem_sect_under_nodes(struct memory_block *mem_blk, >> 109 unsigned long phys_index) >> 110 { >> 111 return 0; >> 112 } >> 113 >> 114 static inline void register_hugetlbfs_with_node(node_registration_func_t reg, >> 115 node_registration_func_t unreg) 177 { 116 { 178 } 117 } 179 #endif 118 #endif 180 119 181 #define to_node(device) container_of(device, s 120 #define to_node(device) container_of(device, struct node, dev) 182 121 183 #endif /* _LINUX_NODE_H_ */ 122 #endif /* _LINUX_NODE_H_ */ 184 123
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.