Skip to contentSkip to conversation

nvdimm: disable balloon

PATCH Superseded Denis V. Lunev 4 participants 6 messages Jan 18, 2016 – Jan 25, 2016

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvdimm: disable balloon

From: Vladimir Sementsov-Ogievskiy <[email protected]>

NVDIMM for now is planned to use as a backing store for DAX filesystem in the guest and thus this memory is excluded from guest memory management and LRUs.

In this case libvirt running QEMU along with configured ballon almost immediately inflates balloon and effectively kill the guest as qemu counts nvdimm as part of the ram.

Counting dimm devices as part of the ram for ballooning was started from patch
virtio-balloon: Fix balloon not working correctly when hotplug memory

CC Stefan Hajnoczi <[email protected]>
CC Xiao Guangrong <[email protected]>
CC "Michael S. Tsirkin" <[email protected]>
CC Igor Mammedov <[email protected]>
CC Eric Blake <[email protected]>
CC Markus Armbruster <[email protected]>

---
The patch is submitted start a discussion. It may be technically correct, but for us the situation is a bit shady.

 hw/mem/nvdimm.c          | 4 ++++
 hw/mem/pc-dimm.c         | 7 ++++++-
 include/hw/mem/pc-dimm.h | 1 +
 qapi-schema.json         | 5 ++++-
 4 files changed, 15 insertions(+), 2 deletions(-)
hw/mem/nvdimm.c +4 -0
index 4fd397f..4f4d29a 100644
@@ -27,9 +27,13 @@
 static void nvdimm_class_init(ObjectClass *oc, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(oc);
+    PCDIMMDeviceClass *ddc = PC_DIMM_CLASS(oc);
 
     /* nvdimm hotplug has not been supported yet. */
     dc->hotpluggable = false;
+
+    /* ballooning is not supported */
+    ddc->in_ram = false;
 }
 
 static TypeInfo nvdimm_info = {
hw/mem/pc-dimm.c +6 -1
index d5cdab2..e0f869d 100644
@@ -164,6 +164,7 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque)
             MemoryDeviceInfo *info = g_new0(MemoryDeviceInfo, 1);
             PCDIMMDeviceInfo *di = g_new0(PCDIMMDeviceInfo, 1);
             DeviceClass *dc = DEVICE_GET_CLASS(obj);
+            PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(obj);
             PCDIMMDevice *dimm = PC_DIMM(obj);
 
             if (dev->id) {
@@ -172,6 +173,7 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque)
             }
             di->hotplugged = dev->hotplugged;
             di->hotpluggable = dc->hotpluggable;
+            di->in_ram = ddc->in_ram;
             di->addr = dimm->addr;
             di->slot = dimm->slot;
             di->node = dimm->node;
@@ -205,7 +207,9 @@ ram_addr_t get_current_ram_size(void)
         if (value) {
             switch (value->type) {
             case MEMORY_DEVICE_INFO_KIND_DIMM:
-                size += value->u.dimm->size;
+                if (value->u.dimm->in_ram) {
+                    size += value->u.dimm->size;
+                }
                 break;
             default:
                 break;
@@ -444,6 +448,7 @@ static void pc_dimm_class_init(ObjectClass *oc, void *data)
     dc->props = pc_dimm_properties;
     dc->desc = "DIMM memory module";
 
+    ddc->in_ram = true;
     ddc->get_memory_region = pc_dimm_get_memory_region;
 }
 
include/hw/mem/pc-dimm.h +1 -0
index d83bf30..3bcb505 100644
@@ -65,6 +65,7 @@ typedef struct PCDIMMDevice {
 typedef struct PCDIMMDeviceClass {
     /* private */
     DeviceClass parent_class;
+    bool in_ram;
 
     /* public */
     MemoryRegion *(*get_memory_region)(PCDIMMDevice *dimm);
qapi-schema.json +4 -1
index b3038b2..613b4d5 100644
@@ -3922,6 +3922,8 @@
 #
 # @hotpluggable: true if device if could be added/removed while machine is running
 #
+# @in-ram: true if device if should be counted in current ram size (since 2.6)
+#
 # Since: 2.1
 ##
 { 'struct': 'PCDIMMDeviceInfo',
@@ -3932,7 +3934,8 @@
             'node': 'int',
             'memdev': 'str',
             'hotplugged': 'bool',
-            'hotpluggable': 'bool'
+            'hotpluggable': 'bool',
+            'in-ram': 'bool'
           }
 }
 
Signature · 1 line
2.1.4
#1 lore raw
Quoted 10 lines · Denis V. Lunev

From: Vladimir Sementsov-Ogievskiy <[email protected]>

NVDIMM for now is planned to use as a backing store for DAX filesystem in the guest and thus this memory is excluded from guest memory management and LRUs.

In this case libvirt running QEMU along with configured ballon almost immediately inflates balloon and effectively kill the guest as qemu counts nvdimm as part of the ram.

It looks good me.

However, it is not related to this patch, why not use the 'total memory' reported by guest instead? It is more precise as a) BIOS and other components will occupy available memory and b) guest may limit the memory size it can use...

Quoted 61 lines

Counting dimm devices as part of the ram for ballooning was started from patch
virtio-balloon: Fix balloon not working correctly when hotplug memory

CC Stefan Hajnoczi <[email protected]>
CC Xiao Guangrong <[email protected]>
CC "Michael S. Tsirkin" <[email protected]>
CC Igor Mammedov <[email protected]>
CC Eric Blake <[email protected]>
CC Markus Armbruster <[email protected]>

---
The patch is submitted start a discussion. It may be technically correct, but for us the situation is a bit shady.

  hw/mem/nvdimm.c          | 4 ++++
  hw/mem/pc-dimm.c         | 7 ++++++-
  include/hw/mem/pc-dimm.h | 1 +
  qapi-schema.json         | 5 ++++-
  4 files changed, 15 insertions(+), 2 deletions(-)
hw/mem/nvdimm.c +4 -0
index 4fd397f..4f4d29a 100644
@@ -27,9 +27,13 @@
  static void nvdimm_class_init(ObjectClass *oc, void *data)
  {
      DeviceClass *dc = DEVICE_CLASS(oc);
+    PCDIMMDeviceClass *ddc = PC_DIMM_CLASS(oc);
 
      /* nvdimm hotplug has not been supported yet. */
      dc->hotpluggable = false;
+
+    /* ballooning is not supported */
+    ddc->in_ram = false;
  }
 
  static TypeInfo nvdimm_info = {
hw/mem/pc-dimm.c +2 -0
index d5cdab2..e0f869d 100644
@@ -164,6 +164,7 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque)
              MemoryDeviceInfo *info = g_new0(MemoryDeviceInfo, 1);
              PCDIMMDeviceInfo *di = g_new0(PCDIMMDeviceInfo, 1);
              DeviceClass *dc = DEVICE_GET_CLASS(obj);
+            PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(obj);
              PCDIMMDevice *dimm = PC_DIMM(obj);
 
              if (dev->id) {
@@ -172,6 +173,7 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque)
              }
              di->hotplugged = dev->hotplugged;
              di->hotpluggable = dc->hotpluggable;
+            di->in_ram = ddc->in_ram;
              di->addr = dimm->addr;
              di->slot = dimm->slot;
              di->node = dimm->node;

hw/mem/pc-dimm.c ram_addr_t get_current_ram_size(void) · line 212

Quoted 7 lines
hw/mem/pc-dimm.c +3 -1
@@ -205,7 +207,9 @@ ram_addr_t get_current_ram_size(void)
          if (value) {
              switch (value->type) {
              case MEMORY_DEVICE_INFO_KIND_DIMM:
-                size += value->u.dimm->size;
+                if (value->u.dimm->in_ram) {
+                    size += value->u.dimm->size;
+                }

Can we use "object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)" to filter out NVDIMM device?

Quoted 37 lines
hw/mem/pc-dimm.c +1 -0
                  break;
              default:
                  break;
@@ -444,6 +448,7 @@ static void pc_dimm_class_init(ObjectClass *oc, void *data)
      dc->props = pc_dimm_properties;
      dc->desc = "DIMM memory module";
 
+    ddc->in_ram = true;
      ddc->get_memory_region = pc_dimm_get_memory_region;
  }
 
include/hw/mem/pc-dimm.h +1 -0
index d83bf30..3bcb505 100644
@@ -65,6 +65,7 @@ typedef struct PCDIMMDevice {
  typedef struct PCDIMMDeviceClass {
      /* private */
      DeviceClass parent_class;
+    bool in_ram;
 
      /* public */
      MemoryRegion *(*get_memory_region)(PCDIMMDevice *dimm);
qapi-schema.json +2 -0
index b3038b2..613b4d5 100644
@@ -3922,6 +3922,8 @@
  #
  # @hotpluggable: true if device if could be added/removed while machine is running
  #
+# @in-ram: true if device if should be counted in current ram size (since 2.6)
+#
  # Since: 2.1
  ##
  { 'struct': 'PCDIMMDeviceInfo',

qapi-schema.json line 3938

Quoted 6 lines
qapi-schema.json +2 -1
@@ -3932,7 +3934,8 @@
              'node': 'int',
              'memdev': 'str',
              'hotplugged': 'bool',
-            'hotpluggable': 'bool'
+            'hotpluggable': 'bool',
+            'in-ram': 'bool'

What is it used for?

#2 lore raw
Quoted 14 lines · Xiao Guangrong
Quoted 10 lines · Denis V. Lunev

From: Vladimir Sementsov-Ogievskiy <[email protected]>

NVDIMM for now is planned to use as a backing store for DAX filesystem in the guest and thus this memory is excluded from guest memory management and LRUs.

In this case libvirt running QEMU along with configured ballon almost immediately inflates balloon and effectively kill the guest as qemu counts nvdimm as part of the ram.

Quoted 5 lines

It looks good me.

However, it is not related to this patch, why not use the 'total memory' reported by guest instead? It is more precise as a) BIOS and other components will occupy available memory and b) guest may limit the memory size it can use...

What do you mean? fix virtio_balloon_set_config instead of get_current_ram_size ? Or what?

Quoted 66 lines
Quoted 66 lines

Counting dimm devices as part of the ram for ballooning was started from patch
virtio-balloon: Fix balloon not working correctly when hotplug memory

CC Stefan Hajnoczi <[email protected]>
CC Xiao Guangrong <[email protected]>
CC "Michael S. Tsirkin" <[email protected]>
CC Igor Mammedov <[email protected]>
CC Eric Blake <[email protected]>
CC Markus Armbruster <[email protected]>

---
The patch is submitted start a discussion. It may be technically correct, but for us the situation is a bit shady.

  hw/mem/nvdimm.c          | 4 ++++
  hw/mem/pc-dimm.c         | 7 ++++++-
  include/hw/mem/pc-dimm.h | 1 +
  qapi-schema.json         | 5 ++++-
  4 files changed, 15 insertions(+), 2 deletions(-)
hw/mem/nvdimm.c +4 -0
index 4fd397f..4f4d29a 100644
@@ -27,9 +27,13 @@
  static void nvdimm_class_init(ObjectClass *oc, void *data)
  {
      DeviceClass *dc = DEVICE_CLASS(oc);
+    PCDIMMDeviceClass *ddc = PC_DIMM_CLASS(oc);
 
      /* nvdimm hotplug has not been supported yet. */
      dc->hotpluggable = false;
+
+    /* ballooning is not supported */
+    ddc->in_ram = false;
  }
 
  static TypeInfo nvdimm_info = {
hw/mem/pc-dimm.c +1 -0
index d5cdab2..e0f869d 100644
@@ -164,6 +164,7 @@ int qmp_pc_dimm_device_list(Object *obj, void 
 *opaque)
              MemoryDeviceInfo *info = g_new0(MemoryDeviceInfo, 1);
              PCDIMMDeviceInfo *di = g_new0(PCDIMMDeviceInfo, 1);
              DeviceClass *dc = DEVICE_GET_CLASS(obj);
+            PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(obj);
              PCDIMMDevice *dimm = PC_DIMM(obj);
 
              if (dev->id) {
hw/mem/pc-dimm.c +1 -0
@@ -172,6 +173,7 @@ int qmp_pc_dimm_device_list(Object *obj, void 
 *opaque)
              }
              di->hotplugged = dev->hotplugged;
              di->hotpluggable = dc->hotpluggable;
+            di->in_ram = ddc->in_ram;
              di->addr = dimm->addr;
              di->slot = dimm->slot;
              di->node = dimm->node;
hw/mem/pc-dimm.c +0 -0
@@ -205,7 +207,9 @@ ch(void)
          if (value) {
              switch (value->type) {
Quoted 8 lines

hw/mem/pc-dimm.c ram_addr_t get_current_ram_size(void) · line 212

Quoted 5 lines
hw/mem/pc-dimm.c +3 -1
              case MEMORY_DEVICE_INFO_KIND_DIMM:
-                size += value->u.dimm->size;
+                if (value->u.dimm->in_ram) {
+                    size += value->u.dimm->size;
+                }

Can we use "object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)" to filter out NVDIMM device?

Hm, this will be ok too. and simpler.. If it ok for you, let's just check it here.

Quoted 41 lines
Quoted 41 lines
hw/mem/pc-dimm.c +1 -0
                  break;
              default:
                  break;
@@ -444,6 +448,7 @@ static void pc_dimm_class_init(ObjectClass *oc, 
 void *data)
      dc->props = pc_dimm_properties;
      dc->desc = "DIMM memory module";
 
+    ddc->in_ram = true;
      ddc->get_memory_region = pc_dimm_get_memory_region;
  }
include/hw/mem/pc-dimm.h +1 -0
index d83bf30..3bcb505 100644
@@ -65,6 +65,7 @@ typedef struct PCDIMMDevice {
  typedef struct PCDIMMDeviceClass {
      /* private */
      DeviceClass parent_class;
+    bool in_ram;
 
      /* public */
      MemoryRegion *(*get_memory_region)(PCDIMMDevice *dimm);
qapi-schema.json +0 -0
index b3038b2..613b4d5 100644
@@ -3922,6 +3922,8 @@
  #
  # @hotpluggable: true if device if could be added/removed while 

machine is running
#
+# @in-ram: true if device if should be counted in current ram size (since 2.6)

qapi-schema.json +1 -0
+#
  # Since: 2.1
  ##
  { 'struct': 'PCDIMMDeviceInfo',
@@ -3932,7 +3934,8 @@
Quoted 8 lines

qapi-schema.json line 3938

Quoted 6 lines
qapi-schema.json +2 -1
              'node': 'int',
              'memdev': 'str',
              'hotplugged': 'bool',
-            'hotpluggable': 'bool'
+            'hotpluggable': 'bool',
+            'in-ram': 'bool'

What is it used for?

only for check in ram_addr_t get_current_ram_size()

Signature · 3 lines
Best regards,
Vladimir
* now, @virtuozzo.com instead of @parallels.com. Sorry for this inconvenience.
#3 lore raw
Quoted 15 lines · Vladimir Sementsov-Ogievskiy
Quoted 14 lines · Xiao Guangrong
Quoted 10 lines · Denis V. Lunev

From: Vladimir Sementsov-Ogievskiy <[email protected]>

NVDIMM for now is planned to use as a backing store for DAX filesystem in the guest and thus this memory is excluded from guest memory management and LRUs.

In this case libvirt running QEMU along with configured ballon almost immediately inflates balloon and effectively kill the guest as qemu counts nvdimm as part of the ram.

Quoted 7 lines
Quoted 5 lines

It looks good me.

However, it is not related to this patch, why not use the 'total memory' reported by guest instead? It is more precise as a) BIOS and other components will occupy available memory and b) guest may limit the memory size it can use...

What do you mean? fix virtio_balloon_set_config instead of get_current_ram_size ? Or what?

No. I just thrown the question and hoped some one can figure it out, it is not about this patch.

#4 lore raw
In reply to Vladimir Sementsov-Ogievskiy
Quoted 98 lines · Vladimir Sementsov-Ogievskiy
Quoted 14 lines · Xiao Guangrong
Quoted 10 lines · Denis V. Lunev

From: Vladimir Sementsov-Ogievskiy <[email protected]>

NVDIMM for now is planned to use as a backing store for DAX filesystem in the guest and thus this memory is excluded from guest memory management and LRUs.

In this case libvirt running QEMU along with configured ballon almost immediately inflates balloon and effectively kill the guest as qemu counts nvdimm as part of the ram.

Quoted 5 lines

It looks good me.

However, it is not related to this patch, why not use the 'total memory' reported by guest instead? It is more precise as a) BIOS and other components will occupy available memory and b) guest may limit the memory size it can use...

What do you mean? fix virtio_balloon_set_config instead of get_current_ram_size ? Or what?

Quoted 66 lines
Quoted 66 lines

Counting dimm devices as part of the ram for ballooning was started from patch
virtio-balloon: Fix balloon not working correctly when hotplug memory

CC Stefan Hajnoczi <[email protected]>
CC Xiao Guangrong <[email protected]>
CC "Michael S. Tsirkin" <[email protected]>
CC Igor Mammedov <[email protected]>
CC Eric Blake <[email protected]>
CC Markus Armbruster <[email protected]>

---
The patch is submitted start a discussion. It may be technically correct, but for us the situation is a bit shady.

  hw/mem/nvdimm.c          | 4 ++++
  hw/mem/pc-dimm.c         | 7 ++++++-
  include/hw/mem/pc-dimm.h | 1 +
  qapi-schema.json         | 5 ++++-
  4 files changed, 15 insertions(+), 2 deletions(-)
hw/mem/nvdimm.c +4 -0
index 4fd397f..4f4d29a 100644
@@ -27,9 +27,13 @@
  static void nvdimm_class_init(ObjectClass *oc, void *data)
  {
      DeviceClass *dc = DEVICE_CLASS(oc);
+    PCDIMMDeviceClass *ddc = PC_DIMM_CLASS(oc);
 
      /* nvdimm hotplug has not been supported yet. */
      dc->hotpluggable = false;
+
+    /* ballooning is not supported */
+    ddc->in_ram = false;
  }
 
  static TypeInfo nvdimm_info = {
hw/mem/pc-dimm.c +1 -0
index d5cdab2..e0f869d 100644
@@ -164,6 +164,7 @@ int qmp_pc_dimm_device_list(Object *obj, void 
 *opaque)
              MemoryDeviceInfo *info = g_new0(MemoryDeviceInfo, 1);
              PCDIMMDeviceInfo *di = g_new0(PCDIMMDeviceInfo, 1);
              DeviceClass *dc = DEVICE_GET_CLASS(obj);
+            PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(obj);
              PCDIMMDevice *dimm = PC_DIMM(obj);
 
              if (dev->id) {
hw/mem/pc-dimm.c +1 -0
@@ -172,6 +173,7 @@ int qmp_pc_dimm_device_list(Object *obj, void 
 *opaque)
              }
              di->hotplugged = dev->hotplugged;
              di->hotpluggable = dc->hotpluggable;
+            di->in_ram = ddc->in_ram;
              di->addr = dimm->addr;
              di->slot = dimm->slot;
              di->node = dimm->node;
hw/mem/pc-dimm.c +0 -0
@@ -205,7 +207,9 @@ ch(void)
          if (value) {
              switch (value->type) {
Quoted 8 lines

hw/mem/pc-dimm.c ram_addr_t get_current_ram_size(void) · line 212

Quoted 5 lines
hw/mem/pc-dimm.c +3 -1
              case MEMORY_DEVICE_INFO_KIND_DIMM:
-                size += value->u.dimm->size;
+                if (value->u.dimm->in_ram) {
+                    size += value->u.dimm->size;
+                }

Can we use "object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)" to filter out NVDIMM device?

Quoted 1 line

Hm, this will be ok too. and simpler.. If it ok for you, let's just check it here.

No, we cant, there is no access to dev here. only info. But, if not use qmp_pc_dimm_device_list, with it dev -> info transition, and write simple pc_dimm_device_list it would be possible.

Quoted 54 lines
Quoted 42 lines
Quoted 42 lines
hw/mem/pc-dimm.c +1 -0
                  break;
              default:
                  break;
@@ -444,6 +448,7 @@ static void pc_dimm_class_init(ObjectClass *oc, 
 void *data)
      dc->props = pc_dimm_properties;
      dc->desc = "DIMM memory module";
 
+    ddc->in_ram = true;
      ddc->get_memory_region = pc_dimm_get_memory_region;
  }
include/hw/mem/pc-dimm.h +1 -0
index d83bf30..3bcb505 100644
@@ -65,6 +65,7 @@ typedef struct PCDIMMDevice {
  typedef struct PCDIMMDeviceClass {
      /* private */
      DeviceClass parent_class;
+    bool in_ram;
 
      /* public */
      MemoryRegion *(*get_memory_region)(PCDIMMDevice *dimm);
qapi-schema.json +0 -0
index b3038b2..613b4d5 100644
@@ -3922,6 +3922,8 @@
  #
  # @hotpluggable: true if device if could be added/removed while 

machine is running
#
+# @in-ram: true if device if should be counted in current ram size (since 2.6)

qapi-schema.json +1 -0
+#
  # Since: 2.1
  ##
  { 'struct': 'PCDIMMDeviceInfo',
@@ -3932,7 +3934,8 @@
Quoted 8 lines

qapi-schema.json line 3938

Quoted 6 lines
qapi-schema.json +2 -1
              'node': 'int',
              'memdev': 'str',
              'hotplugged': 'bool',
-            'hotpluggable': 'bool'
+            'hotpluggable': 'bool',
+            'in-ram': 'bool'

What is it used for?

only for check in ram_addr_t get_current_ram_size()

Signature · 3 lines
Best regards,
Vladimir
* now, @virtuozzo.com instead of @parallels.com. Sorry for this inconvenience.
#5 lore raw
In reply to Denis V. Lunev
Quoted 7 lines · Denis V. Lunev

From: Vladimir Sementsov-Ogievskiy <[email protected]>

NVDIMM for now is planned to use as a backing store for DAX filesystem in the guest and thus this memory is excluded from guest memory management and LRUs.

In this case libvirt running QEMU along with configured ballon almost

s/ballon/balloon/

Quoted 6 lines

immediately inflates balloon and effectively kill the guest as qemu counts nvdimm as part of the ram.

Counting dimm devices as part of the ram for ballooning was started from patch
virtio-balloon: Fix balloon not working correctly when hotplug memory

Useful to mention the commit id: 463756d03

Quoted 9 lines
CC Stefan Hajnoczi <[email protected]>
CC Xiao Guangrong <[email protected]>
CC "Michael S. Tsirkin" <[email protected]>
CC Igor Mammedov <[email protected]>
CC Eric Blake <[email protected]>
CC Markus Armbruster <[email protected]>

I'm just doing an interface review.

qapi-schema.json line 3925

Quoted 11 lines

---
The patch is submitted start a discussion. It may be technically correct, but for us the situation is a bit shady.

+++ b/qapi-schema.json

qapi-schema.json +1 -0
@@ -3922,6 +3922,8 @@
 #
 # @hotpluggable: true if device if could be added/removed while machine is running
 #
+# @in-ram: true if device if should be counted in current ram size (since 2.6)

Output-only, so you are okay adding a new non-optional field. However, is "should be counted" the right wording, or would it be better as "is counted", given that the user doesn't have any way to change whether a device gets counted or not, but is merely learning the state previously chosen by the device.

As for whether it makes sense technically, I'll leave that to discussion.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org