Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 340e01248478ba8b78a6d4d1809b1eff > files > 180

kvm-83-270.el5_11.src.rpm

From e0d933426ad93babd4b9ea46bac7c013ae0e9985 Mon Sep 17 00:00:00 2001
From: Glauber Costa <glommer@redhat.com>
Date: Wed, 6 Apr 2011 16:55:51 -0300
Subject: [PATCH 1/3] Make migration robust to trashing workloads.

RH-Author: Glauber Costa <glommer@redhat.com>
Message-id: <1302108951-12451-1-git-send-email-glommer@redhat.com>
Patchwork-id: 21557
O-Subject: [PATCH] Make migration robust to trashing workloads.
Bugzilla: 690521
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Jes Sorensen <Jes.Sorensen@redhat.com>
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>

RH-Author: Glauber Costa <glommer@redhat.com>
Bugzilla: 690521
RH-Upstream-status: N/A

Our recent bigmem migration series changed significantly the behaviour of
ram_save_live() - for the best.
It did, however, introduce a regression, described in 690521.

Some migrations that were working before, started failing to converge to
stage3. While investigating, I found out that this is due to we not updating
the whole  bitmap everytime. When we do update, some workloads would have dirtied
almost all ram back, and then we just keep retransfering what we've already did.

This patch seems to achieve a good compromise. We still will update the dirty log
infrequently, to help bigmem, but we do that before we transfer anything.
This leads to less duplicated transfers, and thus a more efficient migration

Signed-off-by: Glauber Costa <glommer@redhat.com>
---
 qemu/vl.c |   43 +++++++++++++++++++++++++------------------
 1 files changed, 25 insertions(+), 18 deletions(-)

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 qemu/vl.c |   43 +++++++++++++++++++++++++------------------
 1 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/qemu/vl.c b/qemu/vl.c
index 4c6f49f..fdc6343 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -3483,6 +3483,7 @@ static int ram_save_live(QEMUFile *f, int stage, void *opaque)
     ram_addr_t addr;
     double bwidth = 0;
     int i;
+    uint64_t target_size;
 
     if (stage == 1) {
         /* Make sure all dirty bits are set */
@@ -3497,6 +3498,27 @@ static int ram_save_live(QEMUFile *f, int stage, void *opaque)
         qemu_put_be64(f, phys_ram_size | RAM_SAVE_FLAG_MEM_SIZE);
     }
 
+    if (stage == 2) {
+        /* We have setup the target as 100ms.  a gigabit ethernet can
+           write at ~ 100MB/s, so in 100ms it can write ~10MB.
+
+           100ms (in ns) / 10 / TARGET_PAGE_SIZE = 2441 pages (~9.5MB)
+
+           For upstream we need a better solution.
+        */
+
+        target_size = migrate_max_downtime() / 10/ TARGET_PAGE_SIZE;
+
+        if (ram_save_remaining () <= target_size) {
+            int r;
+            if (kvm_enabled() && (r = kvm_update_dirty_pages_log())) {
+                printf("%s: update dirty pages log failed %d\n", __FUNCTION__, r);
+                qemu_file_set_has_error(f);
+                return 0;
+            }
+        }
+    }
+
     bwidth = get_clock();
 
     i = 0;
@@ -3530,25 +3552,10 @@ static int ram_save_live(QEMUFile *f, int stage, void *opaque)
     qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
 
     if (stage == 2) {
-        /* We have setup the target as 100ms.  a gigabit ethernet can
-           write at ~ 100MB/s, so in 100ms it can write ~10MB.
-
-           100ms (in ns) / 10 / TARGET_PAGE_SIZE = 2441 pages (~9.5MB)
-
-           For upstream we need a better solution.
-        */
-        uint64_t target_size = migrate_max_downtime() / 10/ TARGET_PAGE_SIZE;
-
-        if (ram_save_remaining () <= target_size) {
-            int r;
-            if (kvm_enabled() && (r = kvm_update_dirty_pages_log())) {
-                printf("%s: update dirty pages log failed %d\n", __FUNCTION__, r);
-                qemu_file_set_has_error(f);
-                return 0;
-            }
-            return ram_save_remaining () <= target_size;
-        }
+        target_size = migrate_max_downtime() / 10/ TARGET_PAGE_SIZE;
+        return ram_save_remaining () <= target_size;
     }
+
     return 0;
 }
 
-- 
1.7.3.2