qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Glauber Costa <glommer@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com
Subject: [Qemu-devel] [PATCH 1/2] add non-arbitrary migration stop condition
Date: Thu, 21 May 2009 18:49:33 -0400	[thread overview]
Message-ID: <1242946174-30451-2-git-send-email-glommer@redhat.com> (raw)
In-Reply-To: <1242946174-30451-1-git-send-email-glommer@redhat.com>

Currently, we're entering migration's stage 3 when
a treshold of 10 pages remain to be transferred in the system.

This has hurt some users. However, any proposed threshold is
arbitrary by nature, and would only shift the annoyance.

The proposal of this patch is to define a max_downtime variable,
which represents the maximum downtime a migration user is willing
to suffer. Then, based on the bandwidth of last iteration, we
calculate how much data we can transfer in such a window of time.

Whenever we reach that value (or lower), we know is safe to enter
stage3.

This has largely improved the situation for me.
On localhost migrations, where one would expect things to go as
quickly as me running away from the duty of writting software for
windows, a kernel compile was enough to get the migration stuck.

It takes 3 ~ 5 iterations now.

Signed-off-by: Glauber Costa <glommer@redhat.com>
---
 migration.c |    7 +++++++
 migration.h |    2 ++
 vl.c        |   14 ++++++++++++--
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/migration.c b/migration.c
index 401383c..4036e64 100644
--- a/migration.c
+++ b/migration.c
@@ -107,6 +107,13 @@ void do_migrate_set_speed(Monitor *mon, const char *value)
     
 }
 
+static int64_t max_downtime = 30000000;
+
+int64_t migrate_max_downtime(void)
+{
+    return max_downtime;
+}
+
 void do_info_migrate(Monitor *mon)
 {
     MigrationState *s = current_migration;
diff --git a/migration.h b/migration.h
index 696618d..b0637ba 100644
--- a/migration.h
+++ b/migration.h
@@ -55,6 +55,8 @@ void do_migrate_cancel(Monitor *mon);
 
 void do_migrate_set_speed(Monitor *mon, const char *value);
 
+int64_t migrate_max_downtime(void);
+
 void do_info_migrate(Monitor *mon);
 
 int exec_start_incoming_migration(const char *host_port);
diff --git a/vl.c b/vl.c
index 346da57..5ca06f9 100644
--- a/vl.c
+++ b/vl.c
@@ -3235,7 +3235,6 @@ static int ram_save_block(QEMUFile *f)
     return found;
 }
 
-static ram_addr_t ram_save_threshold = 10;
 static uint64_t bytes_transferred = 0;
 
 static ram_addr_t ram_save_remaining(void)
@@ -3269,6 +3268,9 @@ uint64_t ram_bytes_total(void)
 static int ram_save_live(QEMUFile *f, int stage, void *opaque)
 {
     ram_addr_t addr;
+    uint64_t bytes_transferred_last;
+    double bwidth = 0;
+    int64_t expected_time = 0;
 
     if (stage == 1) {
         /* Make sure all dirty bits are set */
@@ -3283,6 +3285,9 @@ static int ram_save_live(QEMUFile *f, int stage, void *opaque)
         qemu_put_be64(f, last_ram_offset | RAM_SAVE_FLAG_MEM_SIZE);
     }
 
+    bytes_transferred_last = bytes_transferred;
+    bwidth = get_clock();
+
     while (!qemu_file_rate_limit(f)) {
         int ret;
 
@@ -3292,6 +3297,9 @@ static int ram_save_live(QEMUFile *f, int stage, void *opaque)
             break;
     }
 
+    bwidth = get_clock() - bwidth;
+    bwidth = (bytes_transferred - bytes_transferred_last) / bwidth;
+
     /* try transferring iterative blocks of memory */
 
     if (stage == 3) {
@@ -3305,7 +3313,9 @@ static int ram_save_live(QEMUFile *f, int stage, void *opaque)
 
     qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
 
-    return (stage == 2) && (ram_save_remaining() < ram_save_threshold);
+    expected_time = (ram_save_remaining() * TARGET_PAGE_SIZE) / bwidth;
+   
+    return (stage == 2) && (expected_time <= migrate_max_downtime());
 }
 
 static int ram_load_dead(QEMUFile *f, void *opaque)
-- 
1.5.6.6

  reply	other threads:[~2009-05-21 22:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-21 22:49 [Qemu-devel] [PATCH 0/2] Transfer of funds Glauber Costa
2009-05-21 22:49 ` Glauber Costa [this message]
2009-05-21 22:49   ` [Qemu-devel] [PATCH 2/2] set migration max downtime Glauber Costa
2009-05-22  2:09     ` Anthony Liguori
2009-05-24 11:07       ` Avi Kivity
2009-05-24 19:47         ` Anthony Liguori
2009-05-24 19:52           ` Avi Kivity
2009-05-24 22:40             ` M. Warner Losh
2009-05-22  2:08   ` [Qemu-devel] [PATCH 1/2] add non-arbitrary migration stop condition Anthony Liguori
2009-05-24  8:29     ` Avi Kivity
  -- strict thread matches above, loose matches on Subject: below --
2009-05-28 19:22 [Qemu-devel] [PATCH 0/2] Add non-arbitrary treshold for migration Glauber Costa
2009-05-28 19:22 ` [Qemu-devel] [PATCH 1/2] add non-arbitrary migration stop condition Glauber Costa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1242946174-30451-2-git-send-email-glommer@redhat.com \
    --to=glommer@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).