Discussion:
[pve-devel] pve-qemu-kvm : fix ballooning with memory hotplug && numa
Alexandre Derumier
2015-03-09 09:57:25 UTC
Permalink
Currently balloning don't see dimm devices (hotplugged or numa memdev)

this also fix memory display in gui (as we take info for max_mem from ballon device)
http://forum.proxmox.com/threads/21102-Memory-display-in-GUI-with-Numa
Alexandre Derumier
2015-03-09 09:57:26 UTC
Permalink
patch1 && 2 are already in qemu upstream
patch3 fix proxmox patch

Signed-off-by: Alexandre Derumier <***@odiso.com>
---
debian/patches/series | 3 +
debian/patches/virtio-balloon-dimmfix1.patch | 93 ++++++++++++++++++++++++++
debian/patches/virtio-balloon-dimmfix2.patch | 93 ++++++++++++++++++++++++++
debian/patches/virtio-balloon-dimmfix3.patch | 27 ++++++++
4 files changed, 216 insertions(+)
create mode 100644 debian/patches/virtio-balloon-dimmfix1.patch
create mode 100644 debian/patches/virtio-balloon-dimmfix2.patch
create mode 100644 debian/patches/virtio-balloon-dimmfix3.patch

diff --git a/debian/patches/series b/debian/patches/series
index 1381414..24e9d09 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -27,3 +27,6 @@ disable-efi-enable-pxe-roms.patch
backup-vma-allow-empty-backups.patch
glusterfs-daemonize.patch
gluster-backupserver.patch
+virtio-balloon-dimmfix1.patch
+virtio-balloon-dimmfix2.patch
+virtio-balloon-dimmfix3.patch
diff --git a/debian/patches/virtio-balloon-dimmfix1.patch b/debian/patches/virtio-balloon-dimmfix1.patch
new file mode 100644
index 0000000..3f1e1ad
--- /dev/null
+++ b/debian/patches/virtio-balloon-dimmfix1.patch
@@ -0,0 +1,93 @@
+From patchwork Wed Mar 4 19:13:32 2015
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: [PULL,
+ 2/5] virtio-balloon: Fix balloon not working correctly when hotplug
+ memory
+From: Luiz Capitulino <***@redhat.com>
+X-Patchwork-Id: 446384
+Message-Id: <1425496415-6161-3-git-send-email-***@redhat.com>
+To: ***@linaro.org
+Cc: qemu-***@nongnu.org
+Date: Wed, 4 Mar 2015 14:13:32 -0500
+
+From: zhanghailiang <***@huawei.com>
+
+When do memory balloon, it takes the 'ram_size' as the VM's current ram size,
+But 'ram_size' is the startup configured ram size, it does not take into
+account the hotplugged memory.
+
+As a result, the balloon result will be confused.
+Steps to reproduce:
+(1)Start VM: qemu -m size=1024,slots=4,maxmem=8G
+(2)In VM: #free -m : 1024M
+(3)qmp balloon 512M
+(4)In VM: #free -m : 512M
+(5)hotplug pc-dimm 1G
+(6)In VM: #free -m : 1512M
+(7)qmp balloon 256M
+(8)In VM: #free -m :1256M
+We expect the VM's available ram size to be 256M after 'qmp balloon 256M'
+command, but VM's real available ram size is 1256M.
+
+For "qmp balloon" is not performance critical code, we use function
+'get_current_ram_size' to get VM's current ram size.
+
+Signed-off-by: zhanghailiang <***@huawei.com>
+Signed-off-by: Luiz Capitulino <***@redhat.com>
+Signed-off-by: Alexandre Derumier <***@odiso.com>
+---
+ hw/virtio/virtio-balloon.c | 16 +++++++++-------
+ 1 file changed, 9 insertions(+), 7 deletions(-)
+
+diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
+index 14390e1..df3333c 100644
+--- a/hw/virtio/virtio-balloon.c
++++ b/hw/virtio/virtio-balloon.c
+@@ -294,10 +294,12 @@ static void virtio_balloon_set_config(VirtIODevice *vdev,
+ VirtIOBalloon *dev = VIRTIO_BALLOON(vdev);
+ struct virtio_balloon_config config;
+ uint32_t oldactual = dev->actual;
++ ram_addr_t vm_ram_size = get_current_ram_size();
++
+ memcpy(&config, config_data, sizeof(struct virtio_balloon_config));
+ dev->actual = le32_to_cpu(config.actual);
+ if (dev->actual != oldactual) {
+- qapi_event_send_balloon_change(ram_size -
++ qapi_event_send_balloon_change(vm_ram_size -
+ ((ram_addr_t) dev->actual << VIRTIO_BALLOON_PFN_SHIFT),
+ &error_abort);
+ }
+@@ -312,9 +314,8 @@ static uint32_t virtio_balloon_get_features(VirtIODevice *vdev, uint32_t f)
+ static void virtio_balloon_stat(void *opaque, BalloonInfo *info)
+ {
+ VirtIOBalloon *dev = opaque;
+- info->actual = ram_size - ((uint64_t) dev->actual <<
+- VIRTIO_BALLOON_PFN_SHIFT);
+-
++ info->actual = get_current_ram_size() - ((uint64_t) dev->actual <<
++ VIRTIO_BALLOON_PFN_SHIFT);
+ info->max_mem = ram_size;
+
+ if (!(balloon_stats_enabled(dev) && balloon_stats_supported(dev) &&
+@@ -349,12 +350,13 @@ static void virtio_balloon_to_target(void *opaque, ram_addr_t target)
+ {
+ VirtIOBalloon *dev = VIRTIO_BALLOON(opaque);
+ VirtIODevice *vdev = VIRTIO_DEVICE(dev);
++ ram_addr_t vm_ram_size = get_current_ram_size();
+
+- if (target > ram_size) {
+- target = ram_size;
++ if (target > vm_ram_size) {
++ target = vm_ram_size;
+ }
+ if (target) {
+- dev->num_pages = (ram_size - target) >> VIRTIO_BALLOON_PFN_SHIFT;
++ dev->num_pages = (vm_ram_size - target) >> VIRTIO_BALLOON_PFN_SHIFT;
+ virtio_notify_config(vdev);
+ }
+ }
+--
+1.7.10.4
+
diff --git a/debian/patches/virtio-balloon-dimmfix2.patch b/debian/patches/virtio-balloon-dimmfix2.patch
new file mode 100644
index 0000000..782d5a4
--- /dev/null
+++ b/debian/patches/virtio-balloon-dimmfix2.patch
@@ -0,0 +1,93 @@
+From patchwork Wed Mar 4 19:13:31 2015
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: [PULL, 1/5] pc-dimm: add a function to calculate VM's current RAM size
+From: Luiz Capitulino <***@redhat.com>
+X-Patchwork-Id: 446386
+Message-Id: <1425496415-6161-2-git-send-email-***@redhat.com>
+To: ***@linaro.org
+Cc: qemu-***@nongnu.org
+Date: Wed, 4 Mar 2015 14:13:31 -0500
+
+From: zhanghailiang <***@huawei.com>
+
+The global parameter 'ram_size' does not take into account
+the hotplugged memory.
+
+In some codes, we use 'ram_size' as current VM's real RAM size,
+which is not correct.
+
+Add function 'get_current_ram_size' to calculate VM's current RAM size,
+it will enumerate present memory devices and also plus ram_size.
+
+Signed-off-by: zhanghailiang <***@huawei.com>
+Signed-off-by: Luiz Capitulino <***@redhat.com>
+---
+ hw/mem/pc-dimm.c | 26 ++++++++++++++++++++++++++
+ include/exec/cpu-common.h | 1 +
+ stubs/qmp_pc_dimm_device_list.c | 5 +++++
+ 3 files changed, 32 insertions(+)
+
+diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
+index f27a087..de81b9c 100644
+--- a/hw/mem/pc-dimm.c
++++ b/hw/mem/pc-dimm.c
+@@ -100,6 +100,32 @@ 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->kind) {
++ case MEMORY_DEVICE_INFO_KIND_DIMM:
++ size += value->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;
+diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
+index 427b851..fcc3162 100644
+--- a/include/exec/cpu-common.h
++++ b/include/exec/cpu-common.h
+@@ -52,6 +52,7 @@ typedef uintptr_t ram_addr_t;
+ #endif
+
+ extern ram_addr_t ram_size;
++ram_addr_t get_current_ram_size(void);
+
+ /* memory API */
+
+diff --git a/stubs/qmp_pc_dimm_device_list.c b/stubs/qmp_pc_dimm_device_list.c
+index 5cb220c..b584bd8 100644
+--- a/stubs/qmp_pc_dimm_device_list.c
++++ b/stubs/qmp_pc_dimm_device_list.c
+@@ -5,3 +5,8 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque)
+ {
+ return 0;
+ }
++
++ram_addr_t get_current_ram_size(void)
++{
++ return ram_size;
++}
diff --git a/debian/patches/virtio-balloon-dimmfix3.patch b/debian/patches/virtio-balloon-dimmfix3.patch
new file mode 100644
index 0000000..a8de329
--- /dev/null
+++ b/debian/patches/virtio-balloon-dimmfix3.patch
@@ -0,0 +1,27 @@
+From f818a6aa247b71e8185a3277910ac1cd935432d1 Mon Sep 17 00:00:00 2001
+From: Alexandre Derumier <***@odiso.com>
+Date: Mon, 9 Mar 2015 10:18:01 +0100
+Subject: [PATCH] info max_mem : get_current_ram_size
+
+
+Signed-off-by: Alexandre Derumier <***@odiso.com>
+---
+ hw/virtio/virtio-balloon.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
+index df3333c..7f6da3f 100644
+--- a/hw/virtio/virtio-balloon.c
++++ b/hw/virtio/virtio-balloon.c
+@@ -316,7 +316,7 @@ static void virtio_balloon_stat(void *opaque, BalloonInfo *info)
+ VirtIOBalloon *dev = opaque;
+ info->actual = get_current_ram_size() - ((uint64_t) dev->actual <<
+ VIRTIO_BALLOON_PFN_SHIFT);
+- info->max_mem = ram_size;
++ info->max_mem = get_current_ram_size();
+
+ if (!(balloon_stats_enabled(dev) && balloon_stats_supported(dev) &&
+ dev->stats_last_update)) {
+--
+1.7.10.4
+
--
1.7.10.4
Dietmar Maurer
2015-03-10 06:44:58 UTC
Permalink
Post by Alexandre Derumier
patch1 && 2 are already in qemu upstream
patch3 fix proxmox patch
You already sent patch3 to qemu people? Do they plan to include it?

There is a planned qemu release for today (2.2.1):

http://wiki.qemu.org/Planning/2.2

I will wait for that to see what patches are already included.
Alexandre DERUMIER
2015-03-10 07:11:03 UTC
Permalink
patch3 is a patch for proxmox virtio-balloon-fix-query.patch ;)
(feel free to merge them)

original qemu don't have info->max_mem in qmp balloon info.


----- Mail original -----
De: "dietmar" <***@proxmox.com>
À: "pve-devel" <pve-***@pve.proxmox.com>
Envoyé: Mardi 10 Mars 2015 07:44:58
Objet: Re: [pve-devel] [PATCH] fix ballooning with memory hotplug
Post by Alexandre Derumier
patch1 && 2 are already in qemu upstream
patch3 fix proxmox patch
You already sent patch3 to qemu people? Do they plan to include it?

There is a planned qemu release for today (2.2.1):

http://wiki.qemu.org/Planning/2.2

I will wait for that to see what patches are already included.

_______________________________________________
pve-devel mailing list
pve-***@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
Dietmar Maurer
2015-03-10 08:07:49 UTC
Permalink
Post by Alexandre DERUMIER
patch3 is a patch for proxmox virtio-balloon-fix-query.patch ;)
(feel free to merge them)
Sorry, I am confused by all those balloon fixes. The last patch
was "always setup balloon polling interval". The other patches
called "balloon: use qom-get for guest balloon statistics V5" have
been reverted.

So what patch do you refer to? Maybe you can include a link?
Alexandre DERUMIER
2015-03-10 08:19:18 UTC
Permalink
Post by Alexandre DERUMIER
Post by Dietmar Maurer
So what patch do you refer to? Maybe you can include a link?
Oh sorry,
it's was about debian/patches/ files inside the commit


patch1 && 2 are already in qemu upstream
patch3 fix proxmox patch

Signed-off-by: Alexandre Derumier <***@odiso.com>
---
debian/patches/series | 3 +
debian/patches/virtio-balloon-dimmfix1.patch | 93 ++++++++++++++++++++++++++
debian/patches/virtio-balloon-dimmfix2.patch | 93 ++++++++++++++++++++++++++
debian/patches/virtio-balloon-dimmfix3.patch | 27 ++++++++ >>>>>THIS ONE IS THE THIRD PATCH



----- Mail original -----
De: "dietmar" <***@proxmox.com>
À: "aderumier" <***@odiso.com>
Cc: "pve-devel" <pve-***@pve.proxmox.com>
Envoyé: Mardi 10 Mars 2015 09:07:49
Objet: Re: [pve-devel] [PATCH] fix ballooning with memory hotplug
Post by Alexandre DERUMIER
patch3 is a patch for proxmox virtio-balloon-fix-query.patch ;)
(feel free to merge them)
Sorry, I am confused by all those balloon fixes. The last patch
was "always setup balloon polling interval". The other patches
called "balloon: use qom-get for guest balloon statistics V5" have
been reverted.

So what patch do you refer to? Maybe you can include a link?
Dietmar Maurer
2015-03-10 08:34:37 UTC
Permalink
Post by Alexandre DERUMIER
Post by Dietmar Maurer
So what patch do you refer to? Maybe you can include a link?
Oh sorry,
it's was about debian/patches/ files inside the commit
Oh, finally got it :-)
Dietmar Maurer
2015-03-11 07:05:46 UTC
Permalink
Ok, I update to 2.2.1 and applied this patch - thanks!

Just uploaded the new package to the pvetest repository.
Post by Alexandre Derumier
Currently balloning don't see dimm devices (hotplugged or numa memdev)
this also fix memory display in gui (as we take info for max_mem from ballon device)
http://forum.proxmox.com/threads/21102-Memory-display-in-GUI-with-Numa
_______________________________________________
pve-devel mailing list
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
Loading...