| 1 |
|
| 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.
|
| 14 |
|
| 15 | #ifndef _LINUX_NODE_H_
|
| 16 | #define _LINUX_NODE_H_
|
| 17 |
|
| 18 | #include <linux/device.h>
|
| 19 | #include <linux/list.h>
|
| 20 |
|
| 21 | |
| 22 | * struct access_coordinate - generic performance coordinates container
|
| 23 | *
|
| 24 | * @read_bandwidth: Read bandwidth in MB/s
|
| 25 | * @write_bandwidth: Write bandwidth in MB/s
|
| 26 | * @read_latency: Read latency in nanoseconds
|
| 27 | * @write_latency: Write latency in nanoseconds
|
| 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 ACCESS CLASS 0
|
| 38 | * - access_coordinate between target node and nearest initiator node
|
| 39 | * ACCESS_COORDINATE_CPU correlates to ACCESS CLASS 1
|
| 40 | * - access_coordinate between target node and nearest CPU node
|
| 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 | enum cache_mode {
|
| 61 | NODE_CACHE_ADDR_MODE_RESERVED,
|
| 62 | NODE_CACHE_ADDR_MODE_EXTENDED_LINEAR,
|
| 63 | };
|
| 64 |
|
| 65 | |
| 66 | * struct node_cache_attrs - system memory caching attributes
|
| 67 | *
|
| 68 | * @indexing: The ways memory blocks may be placed in cache
|
| 69 | * @write_policy: Write back or write through policy
|
| 70 | * @size: Total size of cache in bytes
|
| 71 | * @line_size: Number of bytes fetched on a cache miss
|
| 72 | * @level: The cache hierarchy level
|
| 73 | * @address_mode: The address mode
|
| 74 |
|
| 75 | struct node_cache_attrs {
|
| 76 | enum cache_indexing indexing;
|
| 77 | enum cache_write_policy write_policy;
|
| 78 | u64 size;
|
| 79 | u16 line_size;
|
| 80 | u8 level;
|
| 81 | u16 address_mode;
|
| 82 | };
|
| 83 |
|
| 84 | #ifdef CONFIG_HMEM_REPORTING
|
| 85 | void node_add_cache(unsigned int nid, struct node_cache_attrs *cache_attrs);
|
| 86 | void node_set_perf_attrs(unsigned int nid, struct access_coordinate *coord,
|
| 87 | enum access_coordinate_class access);
|
| 88 | void node_update_perf_attrs(unsigned int nid, struct access_coordinate *coord,
|
| 89 | enum access_coordinate_class access);
|
| 90 | #else
|
| 91 | static inline void node_add_cache(unsigned int nid,
|
| 92 | struct node_cache_attrs *cache_attrs)
|
| 93 | {
|
| 94 | }
|
| 95 |
|
| 96 | static inline void node_set_perf_attrs(unsigned int nid,
|
| 97 | struct access_coordinate *coord,
|
| 98 | enum access_coordinate_class access)
|
| 99 | {
|
| 100 | }
|
| 101 |
|
| 102 | static inline void node_update_perf_attrs(unsigned int nid,
|
| 103 | struct access_coordinate *coord,
|
| 104 | enum access_coordinate_class access)
|
| 105 | {
|
| 106 | }
|
| 107 | #endif
|
| 108 |
|
| 109 | struct node {
|
| 110 | struct device dev;
|
| 111 | struct list_head access_list;
|
| 112 | #ifdef CONFIG_HMEM_REPORTING
|
| 113 | struct list_head cache_attrs;
|
| 114 | struct device *cache_dev;
|
| 115 | #endif
|
| 116 | };
|
| 117 |
|
| 118 | struct memory_block;
|
| 119 | extern struct node *node_devices[];
|
| 120 |
|
| 121 | #if defined(CONFIG_MEMORY_HOTPLUG) && defined(CONFIG_NUMA)
|
| 122 | void register_memory_blocks_under_node_hotplug(int nid, unsigned long start_pfn,
|
| 123 | unsigned long end_pfn);
|
| 124 | #else
|
| 125 | static inline void register_memory_blocks_under_node_hotplug(int nid,
|
| 126 | unsigned long start_pfn,
|
| 127 | unsigned long end_pfn)
|
| 128 | {
|
| 129 | }
|
| 130 | static inline void register_memory_blocks_under_nodes(void)
|
| 131 | {
|
| 132 | }
|
| 133 | #endif
|
| 134 |
|
| 135 | struct node_notify {
|
| 136 | int nid;
|
| 137 | };
|
| 138 |
|
| 139 | #define NODE_ADDING_FIRST_MEMORY (1<<0)
|
| 140 | #define NODE_ADDED_FIRST_MEMORY (1<<1)
|
| 141 | #define NODE_CANCEL_ADDING_FIRST_MEMORY (1<<2)
|
| 142 | #define NODE_REMOVING_LAST_MEMORY (1<<3)
|
| 143 | #define NODE_REMOVED_LAST_MEMORY (1<<4)
|
| 144 | #define NODE_CANCEL_REMOVING_LAST_MEMORY (1<<5)
|
| 145 |
|
| 146 | #if defined(CONFIG_MEMORY_HOTPLUG) && defined(CONFIG_NUMA)
|
| 147 | extern int register_node_notifier(struct notifier_block *nb);
|
| 148 | extern void unregister_node_notifier(struct notifier_block *nb);
|
| 149 | extern int node_notify(unsigned long val, void *v);
|
| 150 |
|
| 151 | #define hotplug_node_notifier(fn, pri) ({ \
|
| 152 | static __meminitdata struct notifier_block fn##_node_nb =\
|
| 153 | { .notifier_call = fn, .priority = pri };\
|
| 154 | register_node_notifier(&fn##_node_nb); \
|
| 155 | })
|
| 156 | #else
|
| 157 | static inline int register_node_notifier(struct notifier_block *nb)
|
| 158 | {
|
| 159 | return 0;
|
| 160 | }
|
| 161 | static inline void unregister_node_notifier(struct notifier_block *nb)
|
| 162 | {
|
| 163 | }
|
| 164 | static inline int node_notify(unsigned long val, void *v)
|
| 165 | {
|
| 166 | return 0;
|
| 167 | }
|
| 168 | static inline int hotplug_node_notifier(notifier_fn_t fn, int pri)
|
| 169 | {
|
| 170 | return 0;
|
| 171 | }
|
| 172 | #endif
|
| 173 |
|
| 174 | #ifdef CONFIG_NUMA
|
| 175 | extern void node_dev_init(void);
|
| 176 |
|
| 177 | int register_node(int nid);
|
| 178 | void unregister_node(int nid);
|
| 179 | extern int register_cpu_under_node(unsigned int cpu, unsigned int nid);
|
| 180 | extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid);
|
| 181 | extern void unregister_memory_block_under_nodes(struct memory_block *mem_blk);
|
| 182 |
|
| 183 | extern int register_memory_node_under_compute_node(unsigned int mem_nid,
|
| 184 | unsigned int cpu_nid,
|
| 185 | enum access_coordinate_class access);
|
| 186 | #else
|
| 187 | static inline void node_dev_init(void)
|
| 188 | {
|
| 189 | }
|
| 190 | static inline int register_node(int nid)
|
| 191 | {
|
| 192 | return 0;
|
| 193 | }
|
| 194 | static inline int unregister_node(int nid)
|
| 195 | {
|
| 196 | return 0;
|
| 197 | }
|
| 198 | static inline int register_cpu_under_node(unsigned int cpu, unsigned int nid)
|
| 199 | {
|
| 200 | return 0;
|
| 201 | }
|
| 202 | static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
|
| 203 | {
|
| 204 | return 0;
|
| 205 | }
|
| 206 | static inline void unregister_memory_block_under_nodes(struct memory_block *mem_blk)
|
| 207 | {
|
| 208 | }
|
| 209 | #endif
|
| 210 |
|
| 211 | #define to_node(device) container_of(device, struct node, dev)
|
| 212 |
|
| 213 | #endif
|