4 #include "qemu/bitmap.h"
5 #include "qapi/qapi-types-machine.h"
6 #include "exec/cpu-common.h"
11 #define NUMA_NODE_UNASSIGNED MAX_NODES
12 #define NUMA_DISTANCE_MIN 10
13 #define NUMA_DISTANCE_DEFAULT 20
14 #define NUMA_DISTANCE_MAX 254
15 #define NUMA_DISTANCE_UNREACHABLE 255
17 /* the value of AcpiHmatLBInfo flags */
19 HMAT_LB_MEM_MEMORY
= 0,
20 HMAT_LB_MEM_CACHE_1ST_LEVEL
= 1,
21 HMAT_LB_MEM_CACHE_2ND_LEVEL
= 2,
22 HMAT_LB_MEM_CACHE_3RD_LEVEL
= 3,
23 HMAT_LB_LEVELS
/* must be the last entry */
26 /* the value of AcpiHmatLBInfo data type */
28 HMAT_LB_DATA_ACCESS_LATENCY
= 0,
29 HMAT_LB_DATA_READ_LATENCY
= 1,
30 HMAT_LB_DATA_WRITE_LATENCY
= 2,
31 HMAT_LB_DATA_ACCESS_BANDWIDTH
= 3,
32 HMAT_LB_DATA_READ_BANDWIDTH
= 4,
33 HMAT_LB_DATA_WRITE_BANDWIDTH
= 5,
34 HMAT_LB_TYPES
/* must be the last entry */
37 #define UINT16_BITS 16
39 typedef struct NodeInfo
{
41 struct HostMemoryBackend
*node_memdev
;
45 uint8_t lb_info_provided
;
47 uint8_t distance
[MAX_NODES
];
50 typedef struct NumaNodeMem
{
52 uint64_t node_plugged_mem
;
60 typedef struct HMAT_LB_Data HMAT_LB_Data
;
63 /* Indicates it's memory or the specified level memory side cache. */
66 /* Present the type of data, access/read/write latency or bandwidth. */
69 /* The range bitmap of bandwidth for calculating common base */
70 uint64_t range_bitmap
;
72 /* The common base unit for latencies or bandwidths */
75 /* Array to store the latencies or bandwidths */
78 typedef struct HMAT_LB_Info HMAT_LB_Info
;
81 /* Number of NUMA nodes */
84 /* Allow setting NUMA distance for different NUMA nodes */
85 bool have_numa_distance
;
87 /* Detect if HMAT support is enabled. */
90 /* NUMA nodes information */
91 NodeInfo nodes
[MAX_NODES
];
93 /* NUMA nodes HMAT Locality Latency and Bandwidth Information */
94 HMAT_LB_Info
*hmat_lb
[HMAT_LB_LEVELS
][HMAT_LB_TYPES
];
96 /* Memory Side Cache Information Structure */
97 NumaHmatCacheOptions
*hmat_cache
[MAX_NODES
][HMAT_LB_LEVELS
];
99 typedef struct NumaState NumaState
;
101 void set_numa_options(MachineState
*ms
, NumaOptions
*object
, Error
**errp
);
102 void parse_numa_opts(MachineState
*ms
);
103 void parse_numa_hmat_lb(NumaState
*numa_state
, NumaHmatLBOptions
*node
,
105 void parse_numa_hmat_cache(MachineState
*ms
, NumaHmatCacheOptions
*node
,
107 void numa_complete_configuration(MachineState
*ms
);
108 void query_numa_node_mem(NumaNodeMem node_mem
[], MachineState
*ms
);
109 extern QemuOptsList qemu_numa_opts
;
110 void numa_cpu_pre_plug(const struct CPUArchId
*slot
, DeviceState
*dev
,
112 bool numa_uses_legacy_mem(void);