aboutsummaryrefslogtreecommitdiff
path: root/numa.c
diff options
context:
space:
mode:
authorzhanghailiang <zhang.zhanghailiang@huawei.com>2014-11-04 19:49:30 +0800
committerMichael Tokarev <mjt@tls.msk.ru>2014-11-11 08:50:58 +0300
commit5b009e400809523e71f1b72bdaa2b681e2a5b1c7 (patch)
treebf88c2f67db1d2d8ffd16ceaaf5fdb62b4db1a09 /numa.c
parent7912d04be6322b16cfece6b698361ae6ed036ba9 (diff)
downloadqemu-arm-5b009e400809523e71f1b72bdaa2b681e2a5b1c7.tar.gz
numa: make 'info numa' take into account hotplugged memory
When do memory hotplug, if there is numa node, we should add the memory size to the corresponding node memory size. It affects the result of hmp command "info numa". Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Diffstat (limited to 'numa.c')
-rw-r--r--numa.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/numa.c b/numa.c
index 3b981359d1..afd28666b3 100644
--- a/numa.c
+++ b/numa.c
@@ -35,6 +35,7 @@
#include "hw/boards.h"
#include "sysemu/hostmem.h"
#include "qmp-commands.h"
+#include "hw/mem/pc-dimm.h"
QemuOptsList qemu_numa_opts = {
.name = "numa",
@@ -315,6 +316,43 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
}
}
+static void numa_stat_memory_devices(uint64_t node_mem[])
+{
+ MemoryDeviceInfoList *info_list = NULL;
+ MemoryDeviceInfoList **prev = &info_list;
+ MemoryDeviceInfoList *info;
+
+ qmp_pc_dimm_device_list(qdev_get_machine(), &prev);
+ for (info = info_list; info; info = info->next) {
+ MemoryDeviceInfo *value = info->value;
+
+ if (value) {
+ switch (value->kind) {
+ case MEMORY_DEVICE_INFO_KIND_DIMM:
+ node_mem[value->dimm->node] += value->dimm->size;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ qapi_free_MemoryDeviceInfoList(info_list);
+}
+
+void query_numa_node_mem(uint64_t node_mem[])
+{
+ int i;
+
+ if (nb_numa_nodes <= 0) {
+ return;
+ }
+
+ numa_stat_memory_devices(node_mem);
+ for (i = 0; i < nb_numa_nodes; i++) {
+ node_mem[i] += numa_info[i].node_mem;
+ }
+}
+
static int query_memdev(Object *obj, void *opaque)
{
MemdevList **list = opaque;