Extend "info numa" with hotplugged memory information
PATCH v6 1/3 Extend "info numa" with hotplugged memory information
Report amount of hotplugged memory in addition to total amount per NUMA node.
--- include/qemu/typedefs.h | 1 + include/sysemu/numa.h | 7 ++++++- monitor.c | 9 ++++++--- numa.c | 18 +++++++++++++----- 4 files changed, 26 insertions(+), 9 deletions(-)
include/qemu/typedefs.h +1 -0
@@ -100,6 +100,7 @@ typedef struct uWireSlave uWireSlave;typedef struct VirtIODevice VirtIODevice ;typedef struct Visitor Visitor ;typedef struct node_info NodeInfo ; +typedef struct numa_node_mem NumaNodeMem ;typedef void SaveStateHandler (QEMUFile *f,void *opaque);typedef int LoadStateHandler (QEMUFile *f,void *opaque,int version_id);
include/sysemu/numa.h +6 -1
@@ -24,9 +24,14 @@ struct node_info {uint8_t distance[MAX_NODES ]; }; +struct numa_node_mem { +uint64_t node_mem; +uint64_t node_hotpluggable_mem; +}; +extern NodeInfo numa_info[MAX_NODES ];void parse_numa_opts (MachineState *ms); -void query_numa_node_mem (uint64_t node_mem[]); +void query_numa_node_mem (NumaNodeMem node_mem[]);extern QemuOptsList qemu_numa_opts;void numa_set_mem_node_id (ram_addr_t addr,uint64_t size,uint32_t node);void numa_unset_mem_node_id (ram_addr_t addr,uint64_t size,uint32_t node);
monitor.c +6 -3
@@ -1710,11 +1710,12 @@ static void hmp_info_mtree(Monitor *mon, const QDict *qdict)static void hmp_info_numa (Monitor *mon,const QDict *qdict) {int i; -uint64_t *node_mem; +NumaNodeMem *node_mem;CpuInfoList *cpu_list, *cpu; cpu_list =qmp_query_cpus (&error_abort); - node_mem =g_new0 (uint64_t, nb_numa_nodes); + node_mem =g_new0 (NumaNodeMem, 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++) {
@@ -1727,7 +1728,9 @@ static void hmp_info_numa(Monitor *mon, const QDict *qdict) }monitor_printf (mon,"\n" );monitor_printf (mon,"node %d size: %" PRId64" MB\n" , i, - node_mem[i] >>20 ); + node_mem[i].node_mem >>20 ); +monitor_printf (mon,"node %d hotplugged: %" PRId64" MB\n" , i, + node_mem[i].node_hotpluggable_mem >>20 ); }qapi_free_CpuInfoList (cpu_list);g_free (node_mem);
numa.c +13 -5
@@ -591,11 +591,12 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner, } } -static void numa_stat_memory_devices (uint64_t node_mem[]) +static void numa_stat_memory_devices (NumaNodeMem node_mem[]) {MemoryDeviceInfoList *info_list =NULL ;MemoryDeviceInfoList **prev = &info_list;MemoryDeviceInfoList *info; +PCDIMMDeviceInfo *pcdimm_info;qmp_pc_dimm_device_list (qdev_get_machine (), &prev);for (info = info_list; info; info = info->next) {
@@ -603,9 +604,16 @@ static void numa_stat_memory_devices(uint64_t node_mem[])if (value) {switch (value->type) { -case MEMORY_DEVICE_INFO_KIND_DIMM : - node_mem[value->u.dimm.data->node] += value->u.dimm.data->size; +case MEMORY_DEVICE_INFO_KIND_DIMM : { + pcdimm_info = value->u.dimm.data; + node_mem[pcdimm_info->node].node_mem += pcdimm_info->size; +if (pcdimm_info->hotpluggable && pcdimm_info->hotplugged) { + node_mem[pcdimm_info->node].node_hotpluggable_mem += + pcdimm_info->size; + }break ; + } +default :break ; }
@@ -614,7 +622,7 @@ static void numa_stat_memory_devices(uint64_t node_mem[])qapi_free_MemoryDeviceInfoList (info_list); } -void query_numa_node_mem (uint64_t node_mem[]) +void query_numa_node_mem (NumaNodeMem node_mem[]) {int i;
@@ -624,7 +632,7 @@ void query_numa_node_mem(uint64_t node_mem[])numa_stat_memory_devices (node_mem);for (i =0 ; i < nb_numa_nodes; i++) { - node_mem[i] += numa_info[i].node_mem; + node_mem[i].node_mem += numa_info[i].node_mem; } }
Signature · 1 line
2.1.4
PATCH v6 2/3 qmp: introduce query-memory-size-summary command
Command above provides the following memory information in bytes:
* base-memory - size of "base" memory specified with command line option -m.
* plugged-memory - amount of memory that was hot-plugged. If target does not have CONFIG_MEM_HOTPLUG enabled, no value is reported.
--- hw/mem/pc-dimm.c | 5 +++++ include/hw/mem/pc-dimm.h | 1 + qapi-schema.json | 25 +++++++++++++++++++++++++ qmp.c | 13 +++++++++++++ stubs/Makefile.objs | 2 +- stubs/qmp_pc_dimm.c | 13 +++++++++++++ stubs/qmp_pc_dimm_device_list.c | 8 -------- 7 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 stubs/qmp_pc_dimm.c delete mode 100644 stubs/qmp_pc_dimm_device_list.c
hw/mem/pc-dimm.c +5 -0
@@ -159,6 +159,11 @@ uint64_t pc_existing_dimms_capacity(Error **errp)return cap.size; } +uint64_t get_plugged_memory_size (void ) +{ +return pc_existing_dimms_capacity (&error_abort); +} +int qmp_pc_dimm_device_list (Object *obj,void *opaque) {MemoryDeviceInfoList ***prev = opaque;
include/hw/mem/pc-dimm.h +1 -0
@@ -95,6 +95,7 @@ int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp);int qmp_pc_dimm_device_list (Object *obj,void *opaque);uint64_t pc_existing_dimms_capacity (Error **errp); +uint64_t get_plugged_memory_size (void );void pc_dimm_memory_plug (DeviceState *dev,MemoryHotplugState *hpms,MemoryRegion *mr,uint64_t align,Error **errp); void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms,
qapi-schema.json +25 -0
@@ -4408,6 +4408,31 @@ '*unavailable-features': [ 'str' ], 'typename': 'str' } } ## +# @MemoryInfo: +# +# Actual memory information in bytes. +# +# @base-memory: size of "base" memory specified with command line +# option -m. +# +# @plugged-memory: size memory that can be hot-unplugged. +# +# Since: 2.10.0 +## +{ 'struct': 'MemoryInfo', + 'data' : { 'base-memory': 'size', '*plugged-memory': 'size' } } + +## +# @query-memory-size-summary: +# +# Return the amount of initially allocated and hot-plugged (if +# enabled) memory in bytes. +# +# Since: 2.10.0 +## +{ 'command': 'query-memory-size-summary', 'returns': 'MemoryInfo' } + +## # @query-cpu-definitions: # # Return a list of supported virtual CPU definitions
qmp.c +13 -0
@@ -709,3 +709,16 @@ ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error **errp)return head; } + +MemoryInfo *qmp_query_memory_size_summary (Error **errp) +{ +MemoryInfo *mem_info =g_malloc0 (sizeof (MemoryInfo)); + + mem_info->base_memory = ram_size; + + mem_info->plugged_memory =get_plugged_memory_size (); + mem_info->has_plugged_memory = + mem_info->plugged_memory != (uint64_t )-1 ; + +return mem_info; +}
stubs/Makefile.objs +1 -1
@@ -32,7 +32,7 @@ stub-obj-y += uuid.o stub-obj-y += vm-stop.o stub-obj-y += vmstate.o stub-obj-$(CONFIG_WIN32) += fd-register.o -stub-obj-y += qmp_pc_dimm_device_list.o +stub-obj-y += qmp_pc_dimm.o stub-obj-y += target-monitor-defs.o stub-obj-y += target-get-monitor-def.o stub-obj-y += pc_madt_cpu_entry.o
stubs/qmp_pc_dimm.c new file +13 -0
@@ -0,0 +1,13 @@ +#include "qemu/osdep.h" +#include "qom/object.h" +#include "hw/mem/pc-dimm.h" + +int qmp_pc_dimm_device_list (Object *obj,void *opaque) +{ +return 0 ; +} + +uint64_t get_plugged_memory_size (void ) +{ +return (uint64_t )-1 ; +}
stubs/qmp_pc_dimm_device_list.c deleted +0 -8
@@ -1,8 +0,0 @@ -#include "qemu/osdep.h" -#include "qom/object.h" -#include "hw/mem/pc-dimm.h" - -int qmp_pc_dimm_device_list (Object *obj,void *opaque) -{ -return 0 ; -}
Signature · 1 line
2.1.4
Re: [Qemu-devel] [PATCH v6 2/3] qmp: introduce query-memory-size-summary command
Quoted 1 line · Vadim Galitsyn
Command above provides the following memory information in bytes:
My general preference for reading a commit message is to treat the subject line as a one-line summary (the what), and then the commit message body as something that can be read independently, starting with an implicit "Apply this patch to...". Your sentence reads awkwardly in that light ("Apply this patch to command above provides..."). Better might be:
Add a new query-memory-size-summary command which provides...
Yes, it repeats some of the subject line, but remember, not all mail clients display the subject line immediately adjacent and in the same font as the body, so making the reader refer back to the subject to get context can be a distraction.
Quoted 8 lines
* base-memory - size of "base" memory specified with command line option -m.
* plugged-memory - amount of memory that was hot-plugged. If target does not have
CONFIG_MEM_HOTPLUGenabled, no value is reported.
Quoted 9 lines
--- hw/mem/pc-dimm.c | 5 +++++ include/hw/mem/pc-dimm.h | 1 + qapi-schema.json | 25 +++++++++++++++++++++++++ qmp.c | 13 +++++++++++++ stubs/Makefile.objs | 2 +- stubs/qmp_pc_dimm.c | 13 +++++++++++++ stubs/qmp_pc_dimm_device_list.c | 8 -------- 7 files changed, 58 insertions(+), 9 deletions(-)
You may want to look at using scripts/git.orderfile, to rearrange your patch so that interface changes (.json, .h) occur before implementation (.c). For now, I'm just focusing on the interface:
qapi-schema.json line 4418
Quoted 13 lines
+++
b/qapi-schema.jsonqapi-schema.json +8
-0@@ -4408,6 +4408,31 @@ '*unavailable-features': [ 'str' ], 'typename': 'str' } } ## +# @MemoryInfo: +# +# Actual memory information in bytes. +# +# @base-memory: size of "base" memory specified with command line +# option -m. +# +# @plugged-memory: size memory that can be hot-unplugged.
Please also document when this field will be omitted.
Review line 4420
Quoted 2 lines
(quoted diff) +2
-0+# +# Since: 2.10.0
You missed 2.10. This must be 2.11.
qapi-schema.json line 4431
Quoted 11 lines
qapi-schema.json +11
-0+## +{ 'struct': 'MemoryInfo', + 'data' : { 'base-memory': 'size', '*plugged-memory': 'size' } } + +## +# @query-memory-size-summary: +# +# Return the amount of initially allocated and hot-plugged (if +# enabled) memory in bytes. +# +# Since: 2.10.0
2.11
Also, consider including an example usage (there are efforts underway to add automatic testing based on the examples, and a query-* command should be easy to test in that manner).
Quoted 6 lines
qapi-schema.json +4
-0+## +{ 'command': 'query-memory-size-summary', 'returns': 'MemoryInfo' } + +## # @query-cpu-definitions: #
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH v6 3/3 hmp: introduce 'info memory_size_summary' command
In reply to Vadim GalitsynThis command is an equivalent of QMP command query-memory-size-summary. It provides the following memory information in bytes:
* base-memory - size of "base" memory specified with command line option -m.
* plugged-memory - amount of memory that was hot-plugged. If target does not have CONFIG_MEM_HOTPLUG enabled, no value is reported.
--- hmp-commands-info.hx | 16 ++++++++++++++++ hmp.c | 16 ++++++++++++++++ hmp.h | 1 + 3 files changed, 33 insertions(+)
hmp-commands-info.hx +16 -0
@@ -850,6 +850,22 @@ ETEXI }, STEXI +@item info memory_size_summary +@findex memory_size_summary +Display the amount of initially allocated and hot-plugged (if +enabled) memory in bytes. +ETEXI + + { + .name = "memory_size_summary", + .args_type = "", + .params = "", + .help = "show the amount of initially allocated and " + "hot-plugged (if enabled) memory in bytes.", + .cmd = hmp_info_memory_size_summary, + }, + +STEXI @end table ETEXI
hmp.c +16 -0
@@ -2868,3 +2868,19 @@ void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict)hmp_handle_error (mon, &err);qapi_free_GuidInfo (info); } + +void hmp_info_memory_size_summary (Monitor *mon,const QDict *qdict) +{ +MemoryInfo *info =qmp_query_memory_size_summary (&error_abort); +if (info) { +monitor_printf (mon,"base memory: %" PRIu64"\n" , + info->base_memory); + +if (info->has_plugged_memory) { +monitor_printf (mon,"plugged memory: %" PRIu64"\n" , + info->plugged_memory); + } + +qapi_free_MemoryInfo (info); + } +}
hmp.h +1 -0
@@ -145,5 +145,6 @@ void hmp_info_dump(Monitor *mon, const QDict *qdict);void hmp_info_ramblock (Monitor *mon,const QDict *qdict);void hmp_hotpluggable_cpus (Monitor *mon,const QDict *qdict);void hmp_info_vm_generation_id (Monitor *mon,const QDict *qdict); +void hmp_info_memory_size_summary (Monitor *mon,const QDict *qdict);#endif
Signature · 1 line
2.1.4
Re: [Qemu-devel] [PATCH v6 3/3] hmp: introduce 'info memory_size_summary' command
Quoted 57 lines · * Vadim Galitsyn ([email protected]) wrote:
This command is an equivalent of QMP command query-memory-size-summary. It provides the following memory information in bytes:
* base-memory - size of "base" memory specified with command line option -m.
* plugged-memory - amount of memory that was hot-plugged. If target does not have
CONFIG_MEM_HOTPLUGenabled, no value is reported.Signed-off-by Vasilis Liaskovitis <[email protected]>Signed-off-by Mohammed Gamal <[email protected]>Signed-off-by Eduardo Otubo <[email protected]>Signed-off-by Vadim Galitsyn <[email protected]>Reviewed-by Eugene Crosser <[email protected]>Cc Dr. David Alan Gilbert <[email protected]>Cc Markus Armbruster <[email protected]>Cc Igor Mammedov <[email protected]>Cc Eric Blake <[email protected]>--- hmp-commands-info.hx | 16 ++++++++++++++++ hmp.c | 16 ++++++++++++++++ hmp.h | 1 + 3 files changed, 33 insertions(+)hmp-commands-info.hx +16
-0@@ -850,6 +850,22 @@ ETEXI }, STEXI +@item info memory_size_summary +@findex memory_size_summary +Display the amount of initially allocated and hot-plugged (if +enabled) memory in bytes. +ETEXI + + { + .name = "memory_size_summary", + .args_type = "", + .params = "", + .help = "show the amount of initially allocated and " + "hot-plugged (if enabled) memory in bytes.", + .cmd = hmp_info_memory_size_summary, + }, + +STEXI @end table ETEXIhmp.c +0
-0
hmp.c void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict) · line 2874
Quoted 7 lines
hmp.c +4
-0@@ -2868,3 +2868,19 @@ void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict)hmp_handle_error (mon, &err);qapi_free_GuidInfo (info); } + +void hmp_info_memory_size_summary (Monitor *mon,const QDict *qdict) +{ +MemoryInfo *info =qmp_query_memory_size_summary (&error_abort);
That should use hmp_handle_error rather than error_abort; see hmp_info_vm_generation_id as an example.
Other than that, I'm happy from the HMP side.
Dave
Quoted 26 lines
hmp.c +12
-0+if (info) { +monitor_printf (mon,"base memory: %" PRIu64"\n" , + info->base_memory); + +if (info->has_plugged_memory) { +monitor_printf (mon,"plugged memory: %" PRIu64"\n" , + info->plugged_memory); + } + +qapi_free_MemoryInfo (info); + } +}hmp.h +1
-0@@ -145,5 +145,6 @@ void hmp_info_dump(Monitor *mon, const QDict *qdict);void hmp_info_ramblock (Monitor *mon,const QDict *qdict);void hmp_hotpluggable_cpus (Monitor *mon,const QDict *qdict);void hmp_info_vm_generation_id (Monitor *mon,const QDict *qdict); +void hmp_info_memory_size_summary (Monitor *mon,const QDict *qdict);#endif Signature · 1 line
2.1.4
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 3 lines · Vadim Galitsyn
Report amount of hotplugged memory in addition to total amount per NUMA node.
meta-comment: when sending a multi-patch series, it's best to include a 0/3 cover letter. This, and more tips, are found at
http://wiki.qemu.org/Contribute/SubmitAPatch
Quoted 16 lines
Signed-off-by Vadim Galitsyn <[email protected]>Cc Eduardo Habkost <[email protected]>Cc David Hildenbrand <[email protected]>--- include/qemu/typedefs.h | 1 + include/sysemu/numa.h | 7 ++++++- monitor.c | 9 ++++++--- numa.c | 18 +++++++++++++----- 4 files changed, 26 insertions(+), 9 deletions(-)include/qemu/typedefs.h +0
-0
include/qemu/typedefs.h typedef struct uWireSlave uWireSlave; · line 103
Quoted 4 lines
include/qemu/typedefs.h +1
-0@@ -100,6 +100,7 @@ typedef struct uWireSlave uWireSlave;typedef struct VirtIODevice VirtIODevice ;typedef struct Visitor Visitor ;typedef struct node_info NodeInfo ; +typedef struct numa_node_mem NumaNodeMem ;
Please follow HACKING naming conventions - name the struct NumaNodeMem in all places (just because node_info didn't follow the rules doesn't mean your addition should break them). Also, this file should stay sorted.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org