qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Haozhong Zhang <haozhong.zhang@intel.com>,
	Eric Blake <eblake@redhat.com>,
	Igor Mammedov <imammedo@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Markus Armbruster <armbru@redhat.com>
Subject: [Qemu-devel] [PULL 19/22] qmp: distinguish PC-DIMM and NVDIMM in MemoryDeviceInfoList
Date: Tue, 13 Mar 2018 23:45:38 +0200	[thread overview]
Message-ID: <1520977432-187679-20-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1520977432-187679-1-git-send-email-mst@redhat.com>

From: Haozhong Zhang <haozhong.zhang@intel.com>

It may need to treat PC-DIMM and NVDIMM differently, e.g., when
deciding the necessity of non-volatile flag bit in SRAT memory
affinity structures.

A new field 'nvdimm' is added to the union type MemoryDeviceInfo for
such purpose. Its type is currently PCDIMMDeviceInfo and will be
updated when necessary in the future.

It also fixes "info memory-devices"/query-memory-devices which
currently show nvdimm devices as dimm devices since
object_dynamic_cast(obj, TYPE_PC_DIMM) happily cast nvdimm to
TYPE_PC_DIMM which it's been inherited from.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 qapi/misc.json   |  6 +++++-
 hmp.c            | 14 +++++++++++---
 hw/mem/pc-dimm.c | 10 +++++++++-
 numa.c           | 19 +++++++++++++------
 4 files changed, 38 insertions(+), 11 deletions(-)

diff --git a/qapi/misc.json b/qapi/misc.json
index bcd5d10..6bf082f 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -2852,7 +2852,11 @@
 #
 # Since: 2.1
 ##
-{ 'union': 'MemoryDeviceInfo', 'data': {'dimm': 'PCDIMMDeviceInfo'} }
+{ 'union': 'MemoryDeviceInfo',
+  'data': { 'dimm': 'PCDIMMDeviceInfo',
+            'nvdimm': 'PCDIMMDeviceInfo'
+          }
+}
 
 ##
 # @query-memory-devices:
diff --git a/hmp.c b/hmp.c
index ba9e299..a277517 100644
--- a/hmp.c
+++ b/hmp.c
@@ -2423,7 +2423,18 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
             switch (value->type) {
             case MEMORY_DEVICE_INFO_KIND_DIMM:
                 di = value->u.dimm.data;
+                break;
+
+            case MEMORY_DEVICE_INFO_KIND_NVDIMM:
+                di = value->u.nvdimm.data;
+                break;
+
+            default:
+                di = NULL;
+                break;
+            }
 
+            if (di) {
                 monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
                                MemoryDeviceInfoKind_str(value->type),
                                di->id ? di->id : "");
@@ -2436,9 +2447,6 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
                                di->hotplugged ? "true" : "false");
                 monitor_printf(mon, "  hotpluggable: %s\n",
                                di->hotpluggable ? "true" : "false");
-                break;
-            default:
-                break;
             }
         }
     }
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index 4d050fe..51350d9 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -20,6 +20,7 @@
 
 #include "qemu/osdep.h"
 #include "hw/mem/pc-dimm.h"
+#include "hw/mem/nvdimm.h"
 #include "qapi/error.h"
 #include "qemu/config-file.h"
 #include "qapi/visitor.h"
@@ -250,6 +251,7 @@ MemoryDeviceInfoList *qmp_pc_dimm_device_list(void)
         MemoryDeviceInfoList *elem = g_new0(MemoryDeviceInfoList, 1);
         MemoryDeviceInfo *info = g_new0(MemoryDeviceInfo, 1);
         PCDIMMDeviceInfo *di = g_new0(PCDIMMDeviceInfo, 1);
+        bool is_nvdimm = object_dynamic_cast(obj, TYPE_NVDIMM);
         DeviceClass *dc = DEVICE_GET_CLASS(obj);
         DeviceState *dev = DEVICE(obj);
 
@@ -265,7 +267,13 @@ MemoryDeviceInfoList *qmp_pc_dimm_device_list(void)
         di->size = object_property_get_uint(obj, PC_DIMM_SIZE_PROP, NULL);
         di->memdev = object_get_canonical_path(OBJECT(dimm->hostmem));
 
-        info->u.dimm.data = di;
+        if (!is_nvdimm) {
+            info->u.dimm.data = di;
+            info->type = MEMORY_DEVICE_INFO_KIND_DIMM;
+        } else {
+            info->u.nvdimm.data = di;
+            info->type = MEMORY_DEVICE_INFO_KIND_NVDIMM;
+        }
         elem->value = info;
         elem->next = NULL;
         if (prev) {
diff --git a/numa.c b/numa.c
index 9442704..1116c90 100644
--- a/numa.c
+++ b/numa.c
@@ -529,18 +529,25 @@ static void numa_stat_memory_devices(NumaNodeMem node_mem[])
 
         if (value) {
             switch (value->type) {
-            case MEMORY_DEVICE_INFO_KIND_DIMM: {
+            case MEMORY_DEVICE_INFO_KIND_DIMM:
                 pcdimm_info = value->u.dimm.data;
+                break;
+
+            case MEMORY_DEVICE_INFO_KIND_NVDIMM:
+                pcdimm_info = value->u.nvdimm.data;
+                break;
+
+            default:
+                pcdimm_info = NULL;
+                break;
+            }
+
+            if (pcdimm_info) {
                 node_mem[pcdimm_info->node].node_mem += pcdimm_info->size;
                 if (pcdimm_info->hotpluggable && pcdimm_info->hotplugged) {
                     node_mem[pcdimm_info->node].node_plugged_mem +=
                         pcdimm_info->size;
                 }
-                break;
-            }
-
-            default:
-                break;
             }
         }
     }
-- 
MST

  parent reply	other threads:[~2018-03-13 21:45 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-13 21:45 [Qemu-devel] [PULL 00/22] virtio,vhost,pci,pc: features, cleanups Michael S. Tsirkin
2018-03-13 21:45 ` [Qemu-devel] [PULL 01/22] scripts/update-linux-headers: add ethtool.h and update to 4.16.0-rc4 Michael S. Tsirkin
2018-03-13 21:45 ` [Qemu-devel] [PULL 03/22] virtio-net: add linkspeed and duplex settings to virtio-net Michael S. Tsirkin
2018-03-13 21:45 ` [Qemu-devel] [PULL 02/22] virtio-net: use 64-bit values for feature flags Michael S. Tsirkin
2018-03-13 21:45 ` [Qemu-devel] [PULL 04/22] acpi: remove unused acpi-dsdt.aml Michael S. Tsirkin
2018-03-13 21:45 ` [Qemu-devel] [PULL 05/22] pc: replace pm object initialization with one-liner in acpi_get_pm_info() Michael S. Tsirkin
2018-03-13 21:45 ` [Qemu-devel] [PULL 06/22] acpi: reuse AcpiGenericAddress instead of Acpi20GenericAddress Michael S. Tsirkin
2018-03-13 21:45 ` [Qemu-devel] [PULL 07/22] acpi: add build_append_gas() helper for Generic Address Structure Michael S. Tsirkin
2018-03-13 21:45 ` [Qemu-devel] [PULL 08/22] acpi: move ACPI_PORT_SMI_CMD define to header it belongs to Michael S. Tsirkin
2018-03-13 21:45 ` [Qemu-devel] [PULL 09/22] pc: acpi: isolate FADT specific data into AcpiFadtData structure Michael S. Tsirkin
2018-03-13 21:45 ` [Qemu-devel] [PULL 11/22] acpi: move build_fadt() from i386 specific to generic ACPI source Michael S. Tsirkin
2018-03-13 21:45 ` [Qemu-devel] [PULL 10/22] pc: acpi: use build_append_foo() API to construct FADT Michael S. Tsirkin
2018-03-13 21:45 ` [Qemu-devel] [PULL 12/22] virt_arm: acpi: reuse common build_fadt() Michael S. Tsirkin
2018-03-13 21:45 ` [Qemu-devel] [PULL 13/22] tests: acpi: don't read all fields in test_acpi_fadt_table() Michael S. Tsirkin
2018-03-13 21:45 ` [Qemu-devel] [PULL 15/22] qemu-options-wrapper.h: fix include patch Michael S. Tsirkin
2018-03-13 21:45 ` [Qemu-devel] [PULL 14/22] vhost: used_memslots refactoring Michael S. Tsirkin
2018-03-13 21:45 ` [Qemu-devel] [PULL 17/22] hw/pci: remove obsolete PCIDevice->init() Michael S. Tsirkin
2018-03-13 21:45 ` [Qemu-devel] [PULL 16/22] standard-headers: update virtio_net.h Michael S. Tsirkin
2018-03-13 21:45 ` [Qemu-devel] [PULL 18/22] pc-dimm: make qmp_pc_dimm_device_list() sort devices by address Michael S. Tsirkin
2018-03-13 21:45 ` [Qemu-devel] [PULL 20/22] hw/acpi-build: build SRAT memory affinity structures for DIMM devices Michael S. Tsirkin
2018-03-13 21:45 ` Michael S. Tsirkin [this message]
2018-03-13 21:45 ` [Qemu-devel] [PULL 21/22] tests/bios-tables-test: add test cases for DIMM proximity Michael S. Tsirkin
2018-03-13 21:45 ` [Qemu-devel] [PULL 22/22] test/acpi-test-data: add ACPI tables for dimmpxm test Michael S. Tsirkin
2018-03-16 16:31 ` [Qemu-devel] [PULL 00/22] virtio, vhost, pci, pc: features, cleanups Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1520977432-187679-20-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=haozhong.zhang@intel.com \
    --cc=imammedo@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).