| 
									
										
										
										
											2015-02-08 16:51:16 -02:00
										 |  |  | #ifndef SYSEMU_NUMA_H
 | 
					
						
							|  |  |  | #define SYSEMU_NUMA_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "qemu/bitmap.h"
 | 
					
						
							| 
									
										
										
										
											2019-08-12 07:23:53 +02:00
										 |  |  | #include "qapi/qapi-types-machine.h"
 | 
					
						
							|  |  |  | #include "exec/cpu-common.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct CPUArchId; | 
					
						
							| 
									
										
										
										
											2015-02-08 16:51:16 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-12 07:23:55 +02:00
										 |  |  | #define MAX_NODES 128
 | 
					
						
							|  |  |  | #define NUMA_NODE_UNASSIGNED MAX_NODES
 | 
					
						
							|  |  |  | #define NUMA_DISTANCE_MIN         10
 | 
					
						
							|  |  |  | #define NUMA_DISTANCE_DEFAULT     20
 | 
					
						
							|  |  |  | #define NUMA_DISTANCE_MAX         254
 | 
					
						
							|  |  |  | #define NUMA_DISTANCE_UNREACHABLE 255
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-13 09:19:23 +08:00
										 |  |  | /* the value of AcpiHmatLBInfo flags */ | 
					
						
							|  |  |  | enum { | 
					
						
							|  |  |  |     HMAT_LB_MEM_MEMORY           = 0, | 
					
						
							|  |  |  |     HMAT_LB_MEM_CACHE_1ST_LEVEL  = 1, | 
					
						
							|  |  |  |     HMAT_LB_MEM_CACHE_2ND_LEVEL  = 2, | 
					
						
							|  |  |  |     HMAT_LB_MEM_CACHE_3RD_LEVEL  = 3, | 
					
						
							|  |  |  |     HMAT_LB_LEVELS   /* must be the last entry */ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* the value of AcpiHmatLBInfo data type */ | 
					
						
							|  |  |  | enum { | 
					
						
							|  |  |  |     HMAT_LB_DATA_ACCESS_LATENCY   = 0, | 
					
						
							|  |  |  |     HMAT_LB_DATA_READ_LATENCY     = 1, | 
					
						
							|  |  |  |     HMAT_LB_DATA_WRITE_LATENCY    = 2, | 
					
						
							|  |  |  |     HMAT_LB_DATA_ACCESS_BANDWIDTH = 3, | 
					
						
							|  |  |  |     HMAT_LB_DATA_READ_BANDWIDTH   = 4, | 
					
						
							|  |  |  |     HMAT_LB_DATA_WRITE_BANDWIDTH  = 5, | 
					
						
							|  |  |  |     HMAT_LB_TYPES   /* must be the last entry */ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define UINT16_BITS       16
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-15 15:17:52 -06:00
										 |  |  | struct NodeInfo { | 
					
						
							| 
									
										
										
										
											2015-02-08 16:51:16 -02:00
										 |  |  |     uint64_t node_mem; | 
					
						
							|  |  |  |     struct HostMemoryBackend *node_memdev; | 
					
						
							|  |  |  |     bool present; | 
					
						
							| 
									
										
										
										
											2019-12-13 09:19:22 +08:00
										 |  |  |     bool has_cpu; | 
					
						
							| 
									
										
										
										
											2019-12-13 09:19:23 +08:00
										 |  |  |     uint8_t lb_info_provided; | 
					
						
							| 
									
										
										
										
											2019-12-13 09:19:22 +08:00
										 |  |  |     uint16_t initiator; | 
					
						
							| 
									
										
										
											
												numa: Allow setting NUMA distance for different NUMA nodes
This patch is going to add SLIT table support in QEMU, and provides
additional option `dist` for command `-numa` to allow user set vNUMA
distance by QEMU command.
With this patch, when a user wants to create a guest that contains
several vNUMA nodes and also wants to set distance among those nodes,
the QEMU command would like:
```
-numa node,nodeid=0,cpus=0 \
-numa node,nodeid=1,cpus=1 \
-numa node,nodeid=2,cpus=2 \
-numa node,nodeid=3,cpus=3 \
-numa dist,src=0,dst=1,val=21 \
-numa dist,src=0,dst=2,val=31 \
-numa dist,src=0,dst=3,val=41 \
-numa dist,src=1,dst=2,val=21 \
-numa dist,src=1,dst=3,val=31 \
-numa dist,src=2,dst=3,val=21 \
```
Signed-off-by: He Chen <he.chen@linux.intel.com>
Message-Id: <1493260558-20728-1-git-send-email-he.chen@linux.intel.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
											
										 
											2017-04-27 10:35:58 +08:00
										 |  |  |     uint8_t distance[MAX_NODES]; | 
					
						
							| 
									
										
										
										
											2017-05-02 18:29:55 +02:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2015-06-29 13:50:25 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-29 17:30:20 +02:00
										 |  |  | struct NumaNodeMem { | 
					
						
							|  |  |  |     uint64_t node_mem; | 
					
						
							|  |  |  |     uint64_t node_plugged_mem; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-13 09:19:23 +08:00
										 |  |  | struct HMAT_LB_Data { | 
					
						
							|  |  |  |     uint8_t     initiator; | 
					
						
							|  |  |  |     uint8_t     target; | 
					
						
							|  |  |  |     uint64_t    data; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | typedef struct HMAT_LB_Data HMAT_LB_Data; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct HMAT_LB_Info { | 
					
						
							|  |  |  |     /* Indicates it's memory or the specified level memory side cache. */ | 
					
						
							|  |  |  |     uint8_t     hierarchy; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Present the type of data, access/read/write latency or bandwidth. */ | 
					
						
							|  |  |  |     uint8_t     data_type; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* The range bitmap of bandwidth for calculating common base */ | 
					
						
							|  |  |  |     uint64_t    range_bitmap; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* The common base unit for latencies or bandwidths */ | 
					
						
							|  |  |  |     uint64_t    base; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Array to store the latencies or bandwidths */ | 
					
						
							|  |  |  |     GArray      *list; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | typedef struct HMAT_LB_Info HMAT_LB_Info; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-09 14:57:22 +08:00
										 |  |  | struct NumaState { | 
					
						
							|  |  |  |     /* Number of NUMA nodes */ | 
					
						
							|  |  |  |     int num_nodes; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-09 14:57:23 +08:00
										 |  |  |     /* Allow setting NUMA distance for different NUMA nodes */ | 
					
						
							|  |  |  |     bool have_numa_distance; | 
					
						
							| 
									
										
										
										
											2019-08-09 14:57:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-13 09:19:22 +08:00
										 |  |  |     /* Detect if HMAT support is enabled. */ | 
					
						
							|  |  |  |     bool hmat_enabled; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-09 14:57:24 +08:00
										 |  |  |     /* NUMA nodes information */ | 
					
						
							|  |  |  |     NodeInfo nodes[MAX_NODES]; | 
					
						
							| 
									
										
										
										
											2019-12-13 09:19:23 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /* NUMA nodes HMAT Locality Latency and Bandwidth Information */ | 
					
						
							|  |  |  |     HMAT_LB_Info *hmat_lb[HMAT_LB_LEVELS][HMAT_LB_TYPES]; | 
					
						
							| 
									
										
										
										
											2019-12-13 09:19:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /* Memory Side Cache Information Structure */ | 
					
						
							|  |  |  |     NumaHmatCacheOptions *hmat_cache[MAX_NODES][HMAT_LB_LEVELS]; | 
					
						
							| 
									
										
										
										
											2019-08-09 14:57:22 +08:00
										 |  |  | }; | 
					
						
							|  |  |  | typedef struct NumaState NumaState; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-19 22:10:43 +02:00
										 |  |  | void set_numa_options(MachineState *ms, NumaOptions *object, Error **errp); | 
					
						
							| 
									
										
										
										
											2017-05-10 13:29:45 +02:00
										 |  |  | void parse_numa_opts(MachineState *ms); | 
					
						
							| 
									
										
										
										
											2019-12-13 09:19:23 +08:00
										 |  |  | void parse_numa_hmat_lb(NumaState *numa_state, NumaHmatLBOptions *node, | 
					
						
							|  |  |  |                         Error **errp); | 
					
						
							| 
									
										
										
										
											2019-12-13 09:19:24 +08:00
										 |  |  | void parse_numa_hmat_cache(MachineState *ms, NumaHmatCacheOptions *node, | 
					
						
							|  |  |  |                            Error **errp); | 
					
						
							| 
									
										
										
										
											2018-05-04 10:37:39 +02:00
										 |  |  | void numa_complete_configuration(MachineState *ms); | 
					
						
							| 
									
										
										
										
											2019-08-09 14:57:22 +08:00
										 |  |  | void query_numa_node_mem(NumaNodeMem node_mem[], MachineState *ms); | 
					
						
							| 
									
										
										
										
											2015-02-08 16:51:16 -02:00
										 |  |  | extern QemuOptsList qemu_numa_opts; | 
					
						
							| 
									
										
										
										
											2019-08-12 07:23:53 +02:00
										 |  |  | void numa_cpu_pre_plug(const struct CPUArchId *slot, DeviceState *dev, | 
					
						
							|  |  |  |                        Error **errp); | 
					
						
							| 
									
										
										
										
											2020-02-19 11:08:39 -05:00
										 |  |  | bool numa_uses_legacy_mem(void); | 
					
						
							| 
									
										
										
										
											2019-08-12 07:23:53 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-08 16:51:16 -02:00
										 |  |  | #endif
 |