Skip to contentSkip to conversation

augment info migrate with page status

PATCH In review Glauber Costa 6 participants 11 messages May 20, 2009 – May 22, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 augment info migrate with page status

This patch augments info migrate output with status about:
* pages remaining
* pages transferred

This should be enough for management tools to realize whether or not there is progress in migration. We can add more information later on, if the need arrives

---
 migration.c |    2 ++
 sysemu.h    |    6 ++++++
 vl.c        |   13 +++++++++++--
 3 files changed, 19 insertions(+), 2 deletions(-)
migration.c +2 -0
index b9e3368..88d63c0 100644
@@ -116,6 +116,8 @@ void do_info_migrate(Monitor *mon)
         switch (s->get_status(s)) {
         case MIG_STATE_ACTIVE:
             monitor_printf(mon, "active\n");
+            monitor_printf(mon, "remaining ram pages: %u\n", ram_save_remaining());
+            monitor_printf(mon, "transferred ram pages: %u\n", ram_save_transferred());
             break;
         case MIG_STATE_COMPLETED:
             monitor_printf(mon, "completed\n");
sysemu.h +6 -0
index 7d65804..76ab84b 100644
@@ -28,6 +28,12 @@ void qemu_del_vm_change_state_handler(VMChangeStateEntry *e);
 void vm_start(void);
 void vm_stop(int reason);
 
+#ifdef NEED_CPU_H
+#include "cpu-defs.h"
+ram_addr_t ram_save_remaining(void);
+ram_addr_t ram_save_transferred(void);
+#endif
+
 int64_t cpu_get_ticks(void);
 void cpu_enable_ticks(void);
 void cpu_disable_ticks(void);
vl.c +11 -2
index 9f25cd4..97a1bc6 100644
@@ -3236,8 +3236,9 @@ static int ram_save_block(QEMUFile *f)
 }
 
 static ram_addr_t ram_save_threshold = 10;
+static ram_addr_t pages_transferred = 0;
 
-static ram_addr_t ram_save_remaining(void)
+ram_addr_t ram_save_remaining(void)
 {
     ram_addr_t addr;
     ram_addr_t count = 0;
@@ -3250,6 +3251,11 @@ static ram_addr_t ram_save_remaining(void)
     return count;
 }
 
+ram_addr_t ram_save_transferred(void)
+{
+    return pages_transferred;
+}
+
 static int ram_save_live(QEMUFile *f, int stage, void *opaque)
 {
     ram_addr_t addr;
@@ -3271,6 +3277,7 @@ static int ram_save_live(QEMUFile *f, int stage, void *opaque)
         int ret;
 
         ret = ram_save_block(f);
+        pages_transferred += ret;
         if (ret == 0) /* no more blocks */
             break;
     }
@@ -3280,7 +3287,9 @@ static int ram_save_live(QEMUFile *f, int stage, void *opaque)
     if (stage == 3) {
 
         /* flush all remaining blocks regardless of rate limiting */
-        while (ram_save_block(f) != 0);
+        while (ram_save_block(f) != 0) {
+            pages_transferred++;
+        }
         cpu_physical_memory_set_dirty_tracking(0);
     }
 
Signature · 1 line
1.5.6.6
#1 lore raw
Quoted 50 lines · Glauber Costa

This patch augments info migrate output with status about:
* pages remaining
* pages transferred

This should be enough for management tools to realize whether or not there is progress in migration. We can add more information later on, if the need arrives

---
 migration.c |    2 ++
 sysemu.h    |    6 ++++++
 vl.c        |   13 +++++++++++--
 3 files changed, 19 insertions(+), 2 deletions(-)
migration.c +2 -0
index b9e3368..88d63c0 100644
@@ -116,6 +116,8 @@ void do_info_migrate(Monitor *mon)
         switch (s->get_status(s)) {
         case MIG_STATE_ACTIVE:
             monitor_printf(mon, "active\n");
+            monitor_printf(mon, "remaining ram pages: %u\n", ram_save_remaining());
+            monitor_printf(mon, "transferred ram pages: %u\n", ram_save_transferred());
             break;
         case MIG_STATE_COMPLETED:
             monitor_printf(mon, "completed\n");
sysemu.h +6 -0
index 7d65804..76ab84b 100644
@@ -28,6 +28,12 @@ void qemu_del_vm_change_state_handler(VMChangeStateEntry *e);
 void vm_start(void);
 void vm_stop(int reason);
 
+#ifdef NEED_CPU_H
+#include "cpu-defs.h"
+ram_addr_t ram_save_remaining(void);
+ram_addr_t ram_save_transferred(void);
+#endif
+
 int64_t cpu_get_ticks(void);
 void cpu_enable_ticks(void);
 void cpu_disable_ticks(void);
vl.c +0 -0
index 9f25cd4..97a1bc6 100644

vl.c static int ram_save_block(QEMUFile *f) · line 3240

Quoted 5 lines
vl.c +1 -0
@@ -3236,8 +3236,9 @@ static int ram_save_block(QEMUFile *f)
 }
 
 static ram_addr_t ram_save_threshold = 10;
+static ram_addr_t pages_transferred = 0;
 

It would be nice to zero pages_transferred each migration operation. ram_save_threshold is really to small. From Uri's past measurements, as value of 50 is a better suite. Alternately it can be parametrized by the monitor command.

In general there is small drawback in the current approach:
The way bandwidth is capped, iirc, in every second you start consuming migration bandwidth. If the bandwidth allocation was consumed after 100msec, you'll wait 900msec. In this period, mgmt app reading the ram_save_remaining will notice that migration does not progress and might either increase bandwidth or stop the guest. That's why #of no-progress-iteration has advantage.

Quoted 38 lines
vl.c +10 -2
-static ram_addr_t ram_save_remaining(void)
+ram_addr_t ram_save_remaining(void)
 {
     ram_addr_t addr;
     ram_addr_t count = 0;
@@ -3250,6 +3251,11 @@ static ram_addr_t ram_save_remaining(void)
     return count;
 }
 
+ram_addr_t ram_save_transferred(void)
+{
+    return pages_transferred;
+}
+
 static int ram_save_live(QEMUFile *f, int stage, void *opaque)
 {
     ram_addr_t addr;
@@ -3271,6 +3277,7 @@ static int ram_save_live(QEMUFile *f, int stage, void *opaque)
         int ret;
 
         ret = ram_save_block(f);
+        pages_transferred += ret;
         if (ret == 0) /* no more blocks */
             break;
     }
@@ -3280,7 +3287,9 @@ static int ram_save_live(QEMUFile *f, int stage, void *opaque)
     if (stage == 3) {
 
         /* flush all remaining blocks regardless of rate limiting */
-        while (ram_save_block(f) != 0);
+        while (ram_save_block(f) != 0) {
+            pages_transferred++;
+        }
         cpu_physical_memory_set_dirty_tracking(0);
     }
 
#2 lore raw
Quoted 8 lines · Dor Laor
Quoted 3 lines

static ram_addr_t ram_save_threshold = 10;
+static ram_addr_t pages_transferred = 0;

It would be nice to zero pages_transferred each migration operation. ram_save_threshold is really to small. From Uri's past measurements, as value of 50 is a better suite. Alternately it can be parametrized by the monitor command.

Quoted 6 lines

In general there is small drawback in the current approach:
The way bandwidth is capped, iirc, in every second you start consuming migration bandwidth. If the bandwidth allocation was consumed after 100msec, you'll wait 900msec. In this period, mgmt app reading the ram_save_remaining will notice that migration does not progress and might either increase bandwidth or stop the guest. That's why #of no-progress-iteration has advantage.

If I were implementing this in libvirt, here's what I would do:

B = MB/sec bandwidth limit
S = guest size in MB
C = some constant factor, perhaps 4-5

T = S / B * C

1) Wait for T seconds or until migration completes.
2) If timeout occurred:
a) M = actual transfer rate for migration in MB/sec
b) If M < B, T1 = S / M * C
c) T = T1 - T
d) If T <= 0, migration failed
d) else goto 1

Basically, this institutes a policy that a migration must complete after transferring C * guest_size amount of data. It adjusts for observed bandwidth rate vs. capped. It makes sense from an administrative perspective because you are probably only willing to waste so much network bandwidth on attempting to migrate. Obviously, C and B are tunables that heavily depend on the relatively priority of the migration.

Whether you force a non-live migration after failure of a live migration is an administrative decision.

Signature · 3 lines
Regards,

Anthony Liguori
#3 lore raw
In reply to Dor Laor
Quoted 2 lines

It would be nice to zero pages_transferred each migration operation.

Yeah, that makes sense.

Quoted 3 lines

ram_save_threshold is really to small. From Uri's past measurements, as value of 50 is a
better suite.

Every value is arbitrary in essence. If after this patches we still see need to change that, I'd say change it to a percentage of guest total memory, or even better, the average number of pages that were transferred per iteration

Quoted 1 line

Alternately it can be parametrized by the monitor command.

With this, I completely disagree. Let us say we switch in the future to a new migration algorithm that does not rely on any treshold at all. What should we do with this parameter?

This is totally implementation dependant, and should not be exposed. the bandwidth is what we want to control externally.

Quoted 9 lines

In general there is small drawback in the current approach:
The way bandwidth is capped, iirc, in every second you start consuming migration
bandwidth. If the bandwidth allocation was consumed after 100msec, you'll wait 900msec.
In this period, mgmt app reading the ram_save_remaining will notice that migration does
not progress and might either increase bandwidth or stop the guest.

So what? If one second is too much, have them to use 500ms. Also, if the bandwidth was consumed after 100 ms and the number of remaining pages _increased_ when mgmt tool read it again, this is the most genuine case of need for increasing bandwidth in the whole universe.

Or have them use a better algorithm altogether.
The point is, this is not qemu's problem.

#4 lore raw
Quoted 9 lines · Glauber Costa
Quoted 2 lines

Alternately it can be parametrized by the monitor command.

With this, I completely disagree. Let us say we switch in the future to a new migration algorithm that does not rely on any treshold at all. What should we do with this parameter?

This is totally implementation dependant, and should not be exposed. the bandwidth is what we want to control externally.

We want to control bandwidth and application downtime. Why not specify those as parameters?

qemu will live migrate using the specified bandwidth until it reaches a page count that allows it to stop the guest and complete migration within the allowed downtime.

Signature · 1 line
error compiling committee.c: too many arguments to function
#5 lore raw
In reply to Glauber Costa
Quoted 3 lines · Glauber Costa

This patch augments info migrate output with status about:
* pages remaining
* pages transferred

Could you add 'pages total' and/or possibly 'page size', so apps using this can more easily do calculations, without having to worry about hardcoding page sizes for each architecture they deal with.

Oh, what happens if the guest is backed by huge pages ? Does the 'pages transferred' always count in terms of 4k pages, even if 2 M & 1 GB pages are in use ?

Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#6 lore raw
Quoted 8 lines · Daniel P. Berrange
Quoted 3 lines · Glauber Costa

This patch augments info migrate output with status about:
* pages remaining
* pages transferred

Could you add 'pages total' and/or possibly 'page size', so apps using this can more easily do calculations, without having to worry about hardcoding page sizes for each architecture they deal with.

That can be done.

Quoted 4 lines

Oh, what happens if the guest is backed by huge pages ? Does the 'pages transferred' always count in terms of 4k pages, even if 2 M & 1 GB pages are in use ?

Right now, IIRC, migration code scan pages in multiples of TARGET_PAGE_SIZE. we don't have any code path to deal with pages larger than that.

However, I believe it makes sense to be specific that we're talking about TARGET_PAGE_SIZE pages. In the future, we may then have separate lines for each kind of page being transferred.

In a nutshell, we can have something in the lines of:
pages total:
X 4K pages
Y 2M pages
pages remaining:
X' 4k pages
Y' 2M pages
pages transferred:
X'' 4k pages
Y'' 2M pages

Of course, 2M would only be shown in this example if we are really using any.

How do you feel about that?

#7 lore raw
In reply to Daniel P. Berrange
Quoted 7 lines · Daniel P. Berrange
Quoted 4 lines · Glauber Costa

This patch augments info migrate output with status about:
* pages remaining
* pages transferred

Quoted 7 lines

Could you add 'pages total' and/or possibly 'page size', so apps using this can more easily do calculations, without having to worry about hardcoding page sizes for each architecture they deal with.

Oh, what happens if the guest is backed by huge pages ? Does the 'pages transferred' always count in terms of 4k pages, even if 2 M & 1 GB pages are in use ?

We should just use bytes. I don't see how backing page size matters.

Signature · 1 line
error compiling committee.c: too many arguments to function
#8 lore raw
Quoted 12 lines · Avi Kivity
Quoted 11 lines · Daniel P. Berrange
Quoted 4 lines · Glauber Costa

This patch augments info migrate output with status about:
* pages remaining
* pages transferred

Could you add 'pages total' and/or possibly 'page size', so apps using this can more easily do calculations, without having to worry about hardcoding page sizes for each architecture they deal with.

Quoted 6 lines
Quoted 4 lines

Oh, what happens if the guest is backed by huge pages ? Does the 'pages transferred' always count in terms of 4k pages, even if 2 M & 1 GB pages are in use ?

We should just use bytes. I don't see how backing page size matters.

That works for me, because ultimately bytes is what I'd want at libvirt layer.

Regards,
Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#9 lore raw
Quoted 18 lines · Daniel P. Berrange
Quoted 17 lines · Avi Kivity
Quoted 15 lines · Daniel P. Berrange
Quoted 4 lines · Glauber Costa

This patch augments info migrate output with status about:
* pages remaining
* pages transferred

Could you add 'pages total' and/or possibly 'page size', so apps using this can more easily do calculations, without having to worry about hardcoding page sizes for each architecture they deal with.

Oh, what happens if the guest is backed by huge pages ? Does the 'pages transferred' always count in terms of 4k pages, even if 2 M & 1 GB pages are in use ?

Quoted 4 lines
Quoted 1 line

We should just use bytes. I don't see how backing page size matters.

That works for me, because ultimately bytes is what I'd want at libvirt layer.

agreed.

#10 lore raw

[Qemu-devel] QEMU Official OS Support PAge

In reply to Glauber Costa

Hi all,

I want to publicly thank Andrew Clarke for informing me about the spamming on the list, and to all the ones that still collaborate with us all and update or post the status of qemu on it.

I know the captcha is now really difficult to understand. But I do not see any other way to stop that spam. If you know a better one, please, contact me.

Kindly Regards,
Natalia Portillo