[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 8/8] migration: do not flush_compressed_data at t
From: |
guangrong . xiao |
Subject: |
[Qemu-devel] [PATCH v2 8/8] migration: do not flush_compressed_data at the end of each iteration |
Date: |
Thu, 19 Jul 2018 20:15:20 +0800 |
From: Xiao Guangrong <address@hidden>
flush_compressed_data() needs to wait all compression threads to
finish their work, after that all threads are free until the
migration feeds new request to them, reducing its call can improve
the throughput and use CPU resource more effectively
We do not need to flush all threads at the end of iteration, the
data can be kept locally until the memory block is changed or
memory migration starts over in that case we will meet a dirtied
page which may still exists in compression threads's ring
Signed-off-by: Xiao Guangrong <address@hidden>
---
migration/ram.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/migration/ram.c b/migration/ram.c
index 89305c7af5..fdab13821d 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -315,6 +315,8 @@ struct RAMState {
uint64_t iterations;
/* number of dirty bits in the bitmap */
uint64_t migration_dirty_pages;
+ /* last dirty_sync_count we have seen */
+ uint64_t dirty_sync_count;
/* protects modification of the bitmap */
QemuMutex bitmap_mutex;
/* The RAMBlock used in the last src_page_requests */
@@ -2532,6 +2534,7 @@ static void ram_save_cleanup(void *opaque)
}
xbzrle_cleanup();
+ flush_compressed_data(*rsp);
compress_threads_save_cleanup();
ram_state_cleanup(rsp);
}
@@ -3203,6 +3206,17 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
ram_control_before_iterate(f, RAM_CONTROL_ROUND);
+ /*
+ * if memory migration starts over, we will meet a dirtied page which
+ * may still exists in compression threads's ring, so we should flush
+ * the compressed data to make sure the new page is not overwritten by
+ * the old one in the destination.
+ */
+ if (ram_counters.dirty_sync_count != rs->dirty_sync_count) {
+ rs->dirty_sync_count = ram_counters.dirty_sync_count;
+ flush_compressed_data(rs);
+ }
+
t0 = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
i = 0;
while ((ret = qemu_file_rate_limit(f)) == 0 ||
@@ -3235,7 +3249,6 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
}
i++;
}
- flush_compressed_data(rs);
rcu_read_unlock();
/*
--
2.14.4
- Re: [Qemu-devel] [PATCH v2 4/8] migration: introduce save_zero_page_to_file, (continued)
- [Qemu-devel] [PATCH v2 5/8] migration: drop the return value of do_compress_ram_page, guangrong . xiao, 2018/07/19
- [Qemu-devel] [PATCH v2 6/8] migration: move handle of zero page to the thread, guangrong . xiao, 2018/07/19
- Re: [Qemu-devel] [PATCH v2 6/8] migration: move handle of zero page to the thread, Peter Xu, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 6/8] migration: move handle of zero page to the thread, Xiao Guangrong, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 6/8] migration: move handle of zero page to the thread, Peter Xu, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 6/8] migration: move handle of zero page to the thread, Xiao Guangrong, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 6/8] migration: move handle of zero page to the thread, Peter Xu, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 6/8] migration: move handle of zero page to the thread, Xiao Guangrong, 2018/07/24
[Qemu-devel] [PATCH v2 8/8] migration: do not flush_compressed_data at the end of each iteration,
guangrong . xiao <=
- Re: [Qemu-devel] [PATCH v2 8/8] migration: do not flush_compressed_data at the end of each iteration, Peter Xu, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 8/8] migration: do not flush_compressed_data at the end of each iteration, Xiao Guangrong, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 8/8] migration: do not flush_compressed_data at the end of each iteration, Peter Xu, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 8/8] migration: do not flush_compressed_data at the end of each iteration, Xiao Guangrong, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 8/8] migration: do not flush_compressed_data at the end of each iteration, Peter Xu, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 8/8] migration: do not flush_compressed_data at the end of each iteration, Xiao Guangrong, 2018/07/24
[Qemu-devel] [PATCH v2 7/8] migration: hold the lock only if it is really needed, guangrong . xiao, 2018/07/19