Skip to contentSkip to conversation

nvdimm: disable balloon

PATCH In review Denis V. Lunev 3 participants 6 messages Jan 27, 2016

lore
Share & tools
lore
#0 lore raw

v3 cover nvdimm: disable balloon

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 balloon almost immediately inflates balloon and effectively kill the guest as qemu counts nvdimm as part of the ram.

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]>

v3:
- do not use additional class variable

Vladimir Sementsov-Ogievskiy (2):
move get_current_ram_size to virtio-balloon.c
nvdimm: disable balloon

 hw/mem/pc-dimm.c                | 28 ++--------------------------
 hw/virtio/virtio-balloon.c      | 28 ++++++++++++++++++++++++++++
 include/exec/cpu-common.h       |  1 -
 qapi-schema.json                |  5 ++++-
 stubs/qmp_pc_dimm_device_list.c |  5 -----
 5 files changed, 34 insertions(+), 33 deletions(-)
Signature · 1 line
2.5.0
#1 lore raw

PATCH v3 1/2 move get_current_ram_size to virtio-balloon.c

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

get_current_ram_size() is used only in virtio-balloon.c This patch moves it into virtio-balloon and make it static, to allow some balloon-specific tuning.

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]>
---
 hw/mem/pc-dimm.c                | 26 --------------------------
 hw/virtio/virtio-balloon.c      | 26 ++++++++++++++++++++++++++
 include/exec/cpu-common.h       |  1 -
 stubs/qmp_pc_dimm_device_list.c |  5 -----
 4 files changed, 26 insertions(+), 32 deletions(-)
hw/mem/pc-dimm.c +0 -26
index d5cdab2..4f30950 100644
@@ -191,32 +191,6 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque)
     return 0;
 }
 
-ram_addr_t get_current_ram_size(void)
-{
-    MemoryDeviceInfoList *info_list = NULL;
-    MemoryDeviceInfoList **prev = &info_list;
-    MemoryDeviceInfoList *info;
-    ram_addr_t size = ram_size;
-
-    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->type) {
-            case MEMORY_DEVICE_INFO_KIND_DIMM:
-                size += value->u.dimm->size;
-                break;
-            default:
-                break;
-            }
-        }
-    }
-    qapi_free_MemoryDeviceInfoList(info_list);
-
-    return size;
-}
-
 static int pc_dimm_slot2bitmap(Object *obj, void *opaque)
 {
     unsigned long *bitmap = opaque;
hw/virtio/virtio-balloon.c +26 -0
index 9671635..6a4c4d2 100644
@@ -294,6 +294,32 @@ static void virtio_balloon_get_config(VirtIODevice *vdev, uint8_t *config_data)
     memcpy(config_data, &config, sizeof(struct virtio_balloon_config));
 }
 
+static ram_addr_t get_current_ram_size(void)
+{
+    MemoryDeviceInfoList *info_list = NULL;
+    MemoryDeviceInfoList **prev = &info_list;
+    MemoryDeviceInfoList *info;
+    ram_addr_t size = ram_size;
+
+    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->type) {
+            case MEMORY_DEVICE_INFO_KIND_DIMM:
+                size += value->u.dimm->size;
+                break;
+            default:
+                break;
+            }
+        }
+    }
+    qapi_free_MemoryDeviceInfoList(info_list);
+
+    return size;
+}
+
 static void virtio_balloon_set_config(VirtIODevice *vdev,
                                       const uint8_t *config_data)
 {
include/exec/cpu-common.h +0 -1
index 85aa403..a0ad2ac 100644
@@ -54,7 +54,6 @@ typedef uintptr_t ram_addr_t;
 #endif
 
 extern ram_addr_t ram_size;
-ram_addr_t get_current_ram_size(void);
 
 /* memory API */
 
stubs/qmp_pc_dimm_device_list.c +0 -5
index b584bd8..5cb220c 100644
@@ -5,8 +5,3 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque)
 {
    return 0;
 }
-
-ram_addr_t get_current_ram_size(void)
-{
-    return ram_size;
-}
Signature · 1 line
2.5.0
Reviewed-by on v3 1/2
#2 lore raw

Re: [Qemu-devel] [PATCH 1/2] move get_current_ram_size to virtio-balloon.c

Quoted 14 lines · Denis V. Lunev

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

get_current_ram_size() is used only in virtio-balloon.c This patch moves it into virtio-balloon and make it static, to allow some balloon-specific tuning.

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]>
Quoted 6 lines
---
 hw/mem/pc-dimm.c                | 26 --------------------------
 hw/virtio/virtio-balloon.c      | 26 ++++++++++++++++++++++++++
 include/exec/cpu-common.h       |  1 -
 stubs/qmp_pc_dimm_device_list.c |  5 -----
 4 files changed, 26 insertions(+), 32 deletions(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#3 lore raw

PATCH v3 2/2 nvdimm: disable balloon

In reply to 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 balloon 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 commit 463756d03:
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]>
---
 hw/mem/pc-dimm.c           | 2 ++
 hw/virtio/virtio-balloon.c | 4 +++-
 qapi-schema.json           | 5 ++++-
 3 files changed, 9 insertions(+), 2 deletions(-)
hw/mem/pc-dimm.c +2 -0
index 4f30950..2ff9f95 100644
@@ -19,6 +19,7 @@
  */
 
 #include "hw/mem/pc-dimm.h"
+#include "hw/mem/nvdimm.h"
 #include "qemu/config-file.h"
 #include "qapi/visitor.h"
 #include "qemu/range.h"
@@ -178,6 +179,7 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque)
             di->size = object_property_get_int(OBJECT(dimm), PC_DIMM_SIZE_PROP,
                                                NULL);
             di->memdev = object_get_canonical_path(OBJECT(dimm->hostmem));
+            di->balloonable = (object_dynamic_cast(obj, TYPE_NVDIMM) == NULL);
 
             info->u.dimm = di;
             elem->value = info;
hw/virtio/virtio-balloon.c +3 -1
index 6a4c4d2..0a3de75 100644
@@ -308,7 +308,9 @@ static 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->balloonable) {
+                    size += value->u.dimm->size;
+                }
                 break;
             default:
                 break;
qapi-schema.json +4 -1
index 8d04897..5934f81 100644
@@ -3924,6 +3924,8 @@
 #
 # @hotpluggable: true if device if could be added/removed while machine is running
 #
+# @balloonable: true if device take part in ballooning (since 2.6)
+#
 # Since: 2.1
 ##
 { 'struct': 'PCDIMMDeviceInfo',
@@ -3934,7 +3936,8 @@
             'node': 'int',
             'memdev': 'str',
             'hotplugged': 'bool',
-            'hotpluggable': 'bool'
+            'hotpluggable': 'bool',
+            'balloonable': 'bool'
           }
 }
 
Signature · 1 line
2.5.0
#4 lore raw

On Wed, 27 Jan 2016 16:24:29 +0300
"Denis V. Lunev" <[email protected]> wrote:

suggest to change subj to: don't use NVDIMM for balooning

Quoted 42 lines

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 balloon 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 commit 463756d03:
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]>
---
 hw/mem/pc-dimm.c           | 2 ++
 hw/virtio/virtio-balloon.c | 4 +++-
 qapi-schema.json           | 5 ++++-
 3 files changed, 9 insertions(+), 2 deletions(-)
hw/mem/pc-dimm.c +1 -0
index 4f30950..2ff9f95 100644
@@ -19,6 +19,7 @@
  */
 
 #include "hw/mem/pc-dimm.h"
+#include "hw/mem/nvdimm.h"
 #include "qemu/config-file.h"
 #include "qapi/visitor.h"
 #include "qemu/range.h"

hw/mem/pc-dimm.c int qmp_pc_dimm_device_list(Object *obj, void *opaque) · line 182

Quoted 4 lines
hw/mem/pc-dimm.c +1 -0
@@ -178,6 +179,7 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque)
             di->size = object_property_get_int(OBJECT(dimm), PC_DIMM_SIZE_PROP,
                                                NULL);
             di->memdev = object_get_canonical_path(OBJECT(dimm->hostmem));
+            di->balloonable = (object_dynamic_cast(obj, TYPE_NVDIMM) == NULL);

I don't think that balloonable is property of DIMM and that it should be displayed by MemoryDeviceInfo.
I'd drop this + the last hunk and put check directly into get_current_ram_size() in this patch.
And another path on top that adds 'type' to PCDIMMDeviceInfo and shows it in hmp_info_memory_devices() so that management tools/users would be able to distinguish entries.

Quoted 41 lines
hw/mem/pc-dimm.c +0 -0
             info->u.dimm = di;
             elem->value = info;
hw/virtio/virtio-balloon.c +3 -1
index 6a4c4d2..0a3de75 100644
@@ -308,7 +308,9 @@ static 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->balloonable) {
+                    size += value->u.dimm->size;
+                }
                 break;
             default:
                 break;
qapi-schema.json +4 -1
index 8d04897..5934f81 100644
@@ -3924,6 +3924,8 @@
 #
 # @hotpluggable: true if device if could be added/removed while machine is running
 #
+# @balloonable: true if device take part in ballooning (since 2.6)
+#
 # Since: 2.1
 ##
 { 'struct': 'PCDIMMDeviceInfo',
@@ -3934,7 +3936,8 @@
             'node': 'int',
             'memdev': 'str',
             'hotplugged': 'bool',
-            'hotpluggable': 'bool'
+            'hotpluggable': 'bool',
+            'balloonable': 'bool'
           }
 }
 
#5 lore raw
In reply to Denis V. Lunev
Quoted 6 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.

Intentional mid-line break?

Quoted 36 lines

In this case libvirt running QEMU along with configured balloon 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 commit 463756d03:
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]>
---
 hw/mem/pc-dimm.c           | 2 ++
 hw/virtio/virtio-balloon.c | 4 +++-
 qapi-schema.json           | 5 ++++-
 3 files changed, 9 insertions(+), 2 deletions(-)
hw/mem/pc-dimm.c +1 -0
index 4f30950..2ff9f95 100644
@@ -19,6 +19,7 @@
  */
 
 #include "hw/mem/pc-dimm.h"
+#include "hw/mem/nvdimm.h"
 #include "qemu/config-file.h"
 #include "qapi/visitor.h"
 #include "qemu/range.h"

hw/mem/pc-dimm.c int qmp_pc_dimm_device_list(Object *obj, void *opaque) · line 182

Quoted 4 lines
hw/mem/pc-dimm.c +1 -0
@@ -178,6 +179,7 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque)
             di->size = object_property_get_int(OBJECT(dimm), PC_DIMM_SIZE_PROP,
                                                NULL);
             di->memdev = object_get_canonical_path(OBJECT(dimm->hostmem));
+            di->balloonable = (object_dynamic_cast(obj, TYPE_NVDIMM) == NULL);

The outer () seem spurious to me; I might have shortened this to:

di->balloonable = !object_dynamic_cast(obj, TYPE_NVDIMM);

hw/mem/pc-dimm.c line 3927

Quoted 6 lines
hw/mem/pc-dimm.c +2 -0
+++ b/qapi-schema.json
@@ -3924,6 +3924,8 @@
 #
 # @hotpluggable: true if device if could be added/removed while machine is running
 #
+# @balloonable: true if device take part in ballooning (since 2.6)

s/take/takes/

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