[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 11/13] Exit loop if we have been there too long
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PATCH 11/13] Exit loop if we have been there too long |
Date: |
Fri, 29 Jun 2012 18:44:02 +0200 |
Checking each 64 pages is a random magic number as good as any other.
We don't want to test too many times, but on the other hand,
qemu_get_clock_ns() is not so expensive either. We want to be sure
that we spent less than 50ms (half of buffered_file timer), if we
spent more than 100ms, all the accounting got wrong.
Signed-off-by: Juan Quintela <address@hidden>
---
arch_init.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/arch_init.c b/arch_init.c
index 643b696..64c3caa 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -309,12 +309,15 @@ static void migration_end(void)
memory_global_dirty_log_stop();
}
+#define MAX_WAIT 50 /* ms, half buffered_file limit */
+
int ram_save_live(QEMUFile *f, int stage, void *opaque)
{
ram_addr_t addr;
uint64_t bytes_transferred_last;
double bwidth = 0;
int ret;
+ int i;
if (stage < 0) {
migration_end();
@@ -354,6 +357,7 @@ int ram_save_live(QEMUFile *f, int stage, void *opaque)
bytes_transferred_last = bytes_transferred;
bwidth = qemu_get_clock_ns(rt_clock);
+ i = 0;
while ((ret = qemu_file_rate_limit(f)) == 0) {
int bytes_sent;
@@ -362,6 +366,20 @@ int ram_save_live(QEMUFile *f, int stage, void *opaque)
if (bytes_sent == 0) { /* no more blocks */
break;
}
+ /* we want to check in the 1st loop, just in case it was the 1st time
+ and we had to sync the dirty bitmap.
+ qemu_get_clock_ns() is a bit expensive, so we only check each some
+ iterations
+ */
+ if ((i & 63) == 0) {
+ uint64_t t1 = (qemu_get_clock_ns(rt_clock) - bwidth) / 1000000;
+ if (t1 > MAX_WAIT) {
+ DPRINTF("big wait: " PRIu64 " milliseconds, %d iterations\n",
+ t1, i);
+ break;
+ }
+ }
+ i++;
}
if (ret < 0) {
--
1.7.10.4
- [Qemu-devel] [PATCH v3 00/13] Migration tree, Juan Quintela, 2012/06/29
- [Qemu-devel] [PATCH 02/13] Add MigrationParams structure, Juan Quintela, 2012/06/29
- [Qemu-devel] [PATCH 01/13] Add missing check for host_from_stream_offset return value for RAM_SAVE_FLAG_PAGE, Juan Quintela, 2012/06/29
- [Qemu-devel] [PATCH 05/13] Add migration_end function, Juan Quintela, 2012/06/29
- [Qemu-devel] [PATCH 07/13] Add tracepoints for savevm section start/end, Juan Quintela, 2012/06/29
- [Qemu-devel] [PATCH 04/13] Add debugging infrastructure, Juan Quintela, 2012/06/29
- [Qemu-devel] [PATCH 11/13] Exit loop if we have been there too long,
Juan Quintela <=
- [Qemu-devel] [PATCH 06/13] Add spent time for migration, Juan Quintela, 2012/06/29
- [Qemu-devel] [PATCH 03/13] Add save_block_hdr function, Juan Quintela, 2012/06/29
- [Qemu-devel] [PATCH 08/13] No need to iterate if we already are over the limit, Juan Quintela, 2012/06/29
- [Qemu-devel] [PATCH 12/13] dirty bitmap: abstract its use, Juan Quintela, 2012/06/29
- [Qemu-devel] [PATCH 10/13] Only calculate expected_time for stage 2, Juan Quintela, 2012/06/29
- [Qemu-devel] [PATCH 13/13] Maintain the number of dirty pages, Juan Quintela, 2012/06/29
- [Qemu-devel] [PATCH 09/13] Only TCG needs TLB handling, Juan Quintela, 2012/06/29