0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef _LINUX_NODE_H_
0016 #define _LINUX_NODE_H_
0017
0018 #include <linux/device.h>
0019 #include <linux/cpumask.h>
0020 #include <linux/list.h>
0021 #include <linux/workqueue.h>
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 struct node_hmem_attrs {
0032 unsigned int read_bandwidth;
0033 unsigned int write_bandwidth;
0034 unsigned int read_latency;
0035 unsigned int write_latency;
0036 };
0037
0038 enum cache_indexing {
0039 NODE_CACHE_DIRECT_MAP,
0040 NODE_CACHE_INDEXED,
0041 NODE_CACHE_OTHER,
0042 };
0043
0044 enum cache_write_policy {
0045 NODE_CACHE_WRITE_BACK,
0046 NODE_CACHE_WRITE_THROUGH,
0047 NODE_CACHE_WRITE_OTHER,
0048 };
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059 struct node_cache_attrs {
0060 enum cache_indexing indexing;
0061 enum cache_write_policy write_policy;
0062 u64 size;
0063 u16 line_size;
0064 u8 level;
0065 };
0066
0067 #ifdef CONFIG_HMEM_REPORTING
0068 void node_add_cache(unsigned int nid, struct node_cache_attrs *cache_attrs);
0069 void node_set_perf_attrs(unsigned int nid, struct node_hmem_attrs *hmem_attrs,
0070 unsigned access);
0071 #else
0072 static inline void node_add_cache(unsigned int nid,
0073 struct node_cache_attrs *cache_attrs)
0074 {
0075 }
0076
0077 static inline void node_set_perf_attrs(unsigned int nid,
0078 struct node_hmem_attrs *hmem_attrs,
0079 unsigned access)
0080 {
0081 }
0082 #endif
0083
0084 struct node {
0085 struct device dev;
0086 struct list_head access_list;
0087
0088 #if defined(CONFIG_MEMORY_HOTPLUG) && defined(CONFIG_HUGETLBFS)
0089 struct work_struct node_work;
0090 #endif
0091 #ifdef CONFIG_HMEM_REPORTING
0092 struct list_head cache_attrs;
0093 struct device *cache_dev;
0094 #endif
0095 };
0096
0097 struct memory_block;
0098 extern struct node *node_devices[];
0099 typedef void (*node_registration_func_t)(struct node *);
0100
0101 #if defined(CONFIG_MEMORY_HOTPLUG) && defined(CONFIG_NUMA)
0102 void register_memory_blocks_under_node(int nid, unsigned long start_pfn,
0103 unsigned long end_pfn,
0104 enum meminit_context context);
0105 #else
0106 static inline void register_memory_blocks_under_node(int nid, unsigned long start_pfn,
0107 unsigned long end_pfn,
0108 enum meminit_context context)
0109 {
0110 }
0111 #endif
0112
0113 extern void unregister_node(struct node *node);
0114 #ifdef CONFIG_NUMA
0115 extern void node_dev_init(void);
0116
0117 extern int __register_one_node(int nid);
0118
0119
0120 static inline int register_one_node(int nid)
0121 {
0122 int error = 0;
0123
0124 if (node_online(nid)) {
0125 struct pglist_data *pgdat = NODE_DATA(nid);
0126 unsigned long start_pfn = pgdat->node_start_pfn;
0127 unsigned long end_pfn = start_pfn + pgdat->node_spanned_pages;
0128
0129 error = __register_one_node(nid);
0130 if (error)
0131 return error;
0132 register_memory_blocks_under_node(nid, start_pfn, end_pfn,
0133 MEMINIT_EARLY);
0134 }
0135
0136 return error;
0137 }
0138
0139 extern void unregister_one_node(int nid);
0140 extern int register_cpu_under_node(unsigned int cpu, unsigned int nid);
0141 extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid);
0142 extern void unregister_memory_block_under_nodes(struct memory_block *mem_blk);
0143
0144 extern int register_memory_node_under_compute_node(unsigned int mem_nid,
0145 unsigned int cpu_nid,
0146 unsigned access);
0147
0148 #ifdef CONFIG_HUGETLBFS
0149 extern void register_hugetlbfs_with_node(node_registration_func_t doregister,
0150 node_registration_func_t unregister);
0151 #endif
0152 #else
0153 static inline void node_dev_init(void)
0154 {
0155 }
0156 static inline int __register_one_node(int nid)
0157 {
0158 return 0;
0159 }
0160 static inline int register_one_node(int nid)
0161 {
0162 return 0;
0163 }
0164 static inline int unregister_one_node(int nid)
0165 {
0166 return 0;
0167 }
0168 static inline int register_cpu_under_node(unsigned int cpu, unsigned int nid)
0169 {
0170 return 0;
0171 }
0172 static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
0173 {
0174 return 0;
0175 }
0176 static inline void unregister_memory_block_under_nodes(struct memory_block *mem_blk)
0177 {
0178 }
0179
0180 static inline void register_hugetlbfs_with_node(node_registration_func_t reg,
0181 node_registration_func_t unreg)
0182 {
0183 }
0184 #endif
0185
0186 #define to_node(device) container_of(device, struct node, dev)
0187
0188 static inline bool node_is_toptier(int node)
0189 {
0190 return node_state(node, N_CPU);
0191 }
0192
0193 #endif