[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-trivial] [PULL 04/11] numa: make 'info numa' take into account hot
From: |
Michael Tokarev |
Subject: |
[Qemu-trivial] [PULL 04/11] numa: make 'info numa' take into account hotplugged memory |
Date: |
Tue, 11 Nov 2014 17:46:26 +0300 |
From: zhanghailiang <address@hidden>
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 <address@hidden>
Signed-off-by: zhanghailiang <address@hidden>
Signed-off-by: Michael Tokarev <address@hidden>
---
include/sysemu/sysemu.h | 1 +
monitor.c | 6 +++++-
numa.c | 38 ++++++++++++++++++++++++++++++++++++++
3 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 0037a69..50de1d3 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -161,6 +161,7 @@ typedef struct node_info {
extern NodeInfo numa_info[MAX_NODES];
void set_numa_nodes(void);
void set_numa_modes(void);
+void query_numa_node_mem(uint64_t node_mem[]);
extern QemuOptsList qemu_numa_opts;
int numa_init_func(QemuOpts *opts, void *opaque);
diff --git a/monitor.c b/monitor.c
index 1fc201a..32db7ee 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1948,7 +1948,10 @@ static void do_info_numa(Monitor *mon, const QDict
*qdict)
{
int i;
CPUState *cpu;
+ uint64_t *node_mem;
+ node_mem = g_new0(uint64_t, nb_numa_nodes);
+ query_numa_node_mem(node_mem);
monitor_printf(mon, "%d nodes\n", nb_numa_nodes);
for (i = 0; i < nb_numa_nodes; i++) {
monitor_printf(mon, "node %d cpus:", i);
@@ -1959,8 +1962,9 @@ static void do_info_numa(Monitor *mon, const QDict *qdict)
}
monitor_printf(mon, "\n");
monitor_printf(mon, "node %d size: %" PRId64 " MB\n", i,
- numa_info[i].node_mem >> 20);
+ node_mem[i] >> 20);
}
+ g_free(node_mem);
}
#ifdef CONFIG_PROFILER
diff --git a/numa.c b/numa.c
index 3b98135..afd2866 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;
--
1.7.10.4
- [Qemu-trivial] [PULL 00/11 for-2.2] Trivial patches for 2014-11-11, Michael Tokarev, 2014/11/11
- [Qemu-trivial] [PULL 01/11] icc_bus: fix typo ICC_BRIGDE -> ICC_BRIDGE, Michael Tokarev, 2014/11/11
- [Qemu-trivial] [PULL 02/11] qemu-doc.texi: fix typos in x509 examples, Michael Tokarev, 2014/11/11
- [Qemu-trivial] [PULL 07/11] coroutine-sigaltstack: Change jmp_buf to sigjmp_buf, Michael Tokarev, 2014/11/11
- [Qemu-trivial] [PULL 11/11] block: Fix comment for bdrv_co_get_block_status, Michael Tokarev, 2014/11/11
- [Qemu-trivial] [PULL 09/11] target-i386: cpu: keeping function parameters alignment on new line, Michael Tokarev, 2014/11/11
- [Qemu-trivial] [PULL 10/11] sysbus: Correct SYSTEM_BUS(obj) defines, Michael Tokarev, 2014/11/11
- [Qemu-trivial] [PULL 05/11] gdbstub: Add a missing case of signal number translation in gdbstub, Michael Tokarev, 2014/11/11
- [Qemu-trivial] [PULL 03/11] slirp/smbd: modify/set several parameters in generated smbd.conf, Michael Tokarev, 2014/11/11
- [Qemu-trivial] [PULL 04/11] numa: make 'info numa' take into account hotplugged memory,
Michael Tokarev <=
- [Qemu-trivial] [PULL 08/11] xen-hvm: Remove redundant variable 'xstate', Michael Tokarev, 2014/11/11
- [Qemu-trivial] [PULL 06/11] pc-bios: petalogix-s3adsp1800.dtb: Use 'xlnx, xps-ethernetlite-2.00.a' instead of 'xlnx, xps-ethernetlite-2.00.b', Michael Tokarev, 2014/11/11
- Re: [Qemu-trivial] [Qemu-devel] [PULL 00/11 for-2.2] Trivial patches for 2014-11-11, Peter Maydell, 2014/11/11