nvdimm: disable balloon
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.
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
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.
--- 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
@@ -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
@@ -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
@@ -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
@@ -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
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 invirtio-balloon.cThis patch moves it into virtio-balloon and make it static, to allow some balloon-specific tuning.Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>Signed-off-by Denis V. Lunev <[email protected]>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
PATCH v3 2/2 nvdimm: disable balloon
In reply to Denis V. LunevFrom: 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
--- 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
@@ -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
@@ -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
@@ -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
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 memorySigned-off-by Vladimir Sementsov-Ogievskiy <[email protected]>Signed-off-by Denis V. Lunev <[email protected]>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@@ -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
-0info->u.dimm = di; elem->value = info;hw/virtio/virtio-balloon.c +3
-1@@ -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@@ -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' } }
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 memorySigned-off-by Vladimir Sementsov-Ogievskiy <[email protected]>Signed-off-by Denis V. Lunev <[email protected]>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@@ -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