All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [query-memory-size-summary] Report page size
@ 2023-05-19  8:10 Andrei Gudkov via
  2023-05-19 15:22 ` Eric Blake
  2023-05-25 14:55 ` Markus Armbruster
  0 siblings, 2 replies; 4+ messages in thread
From: Andrei Gudkov via @ 2023-05-19  8:10 UTC (permalink / raw)
  To: qemu-devel
  Cc: eduardo, marcel.apfelbaum, philmd, wangyanan55, eblake, armbru,
	Andrei Gudkov

Some commands (query-migrate and calc-dirty-rate) report values
in units of pages. However, currently the only place where we can
get page size is through query-migrate and only after migration
has started. query-memory-size-summary seems like an appropritate
place where it should be reported instead.

Signed-off-by: Andrei Gudkov <gudkov.andrei@huawei.com>
---
 qapi/machine.json          | 8 ++++++--
 hw/core/machine-qmp-cmds.c | 3 +++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/qapi/machine.json b/qapi/machine.json
index 37660d8f2a..10b2d686da 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -1125,10 +1125,13 @@
 #     field is omitted if target doesn't support memory hotplug (i.e.
 #     CONFIG_MEM_DEVICE not defined at build time).
 #
+# @page-size: the number of bytes per target page (since 8.1)
+#
 # Since: 2.11
 ##
 { 'struct': 'MemoryInfo',
-  'data'  : { 'base-memory': 'size', '*plugged-memory': 'size' } }
+  'data'  : { 'base-memory': 'size', '*plugged-memory': 'size',
+              'page-size': 'size' } }
 
 ##
 # @query-memory-size-summary:
@@ -1139,7 +1142,8 @@
 # Example:
 #
 # -> { "execute": "query-memory-size-summary" }
-# <- { "return": { "base-memory": 4294967296, "plugged-memory": 0 } }
+# <- { "return": { "page-size": 4096, "base-memory": 34359738368,
+#      "plugged-memory": 0 } }
 #
 # Since: 2.11
 ##
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index 3860a50c3b..b768ff372f 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -27,6 +27,7 @@
 #include "sysemu/numa.h"
 #include "sysemu/runstate.h"
 #include "sysemu/sysemu.h"
+#include "exec/target_page.h"
 
 /*
  * fast means: we NEVER interrupt vCPU threads to retrieve
@@ -289,6 +290,8 @@ MemoryInfo *qmp_query_memory_size_summary(Error **errp)
     mem_info->has_plugged_memory =
         mem_info->plugged_memory != (uint64_t)-1;
 
+    mem_info->page_size = qemu_target_page_size();
+
     return mem_info;
 }
 
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-27  7:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-19  8:10 [PATCH] [query-memory-size-summary] Report page size Andrei Gudkov via
2023-05-19 15:22 ` Eric Blake
2023-05-25 14:55 ` Markus Armbruster
2023-05-27  7:05   ` Markus Armbruster

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.