aboutsummaryrefslogtreecommitdiff
path: root/migration/ram.c
diff options
context:
space:
mode:
authorXiao Guangrong <xiaoguangrong@tencent.com>2018-06-04 17:55:12 +0800
committerDr. David Alan Gilbert <dgilbert@redhat.com>2018-06-15 14:40:56 +0100
commitb734035b61c0943c11bc591549d81de3ed7c0029 (patch)
tree1ab83c92497995d47e776aebc898f63ef21308c6 /migration/ram.c
parente0e7a45d7fa64563191d3723fc4a4570122e6e42 (diff)
migration: introduce migration_update_rates
It is used to slightly clean the code up, no logic is changed Signed-off-by: Xiao Guangrong <xiaoguangrong@tencent.com> Message-Id: <20180604095520.8563-5-xiaoguangrong@tencent.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Diffstat (limited to 'migration/ram.c')
-rw-r--r--migration/ram.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/migration/ram.c b/migration/ram.c
index d273a19699..77071a43ed 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1141,6 +1141,25 @@ uint64_t ram_pagesize_summary(void)
return summary;
}
+static void migration_update_rates(RAMState *rs, int64_t end_time)
+{
+ uint64_t iter_count = rs->iterations - rs->iterations_prev;
+
+ /* calculate period counters */
+ ram_counters.dirty_pages_rate = rs->num_dirty_pages_period * 1000
+ / (end_time - rs->time_last_bitmap_sync);
+
+ if (!iter_count) {
+ return;
+ }
+
+ if (migrate_use_xbzrle()) {
+ xbzrle_counters.cache_miss_rate = (double)(xbzrle_counters.cache_miss -
+ rs->xbzrle_cache_miss_prev) / iter_count;
+ rs->xbzrle_cache_miss_prev = xbzrle_counters.cache_miss;
+ }
+}
+
static void migration_bitmap_sync(RAMState *rs)
{
RAMBlock *block;
@@ -1170,9 +1189,6 @@ static void migration_bitmap_sync(RAMState *rs)
/* more than 1 second = 1000 millisecons */
if (end_time > rs->time_last_bitmap_sync + 1000) {
- /* calculate period counters */
- ram_counters.dirty_pages_rate = rs->num_dirty_pages_period * 1000
- / (end_time - rs->time_last_bitmap_sync);
bytes_xfer_now = ram_counters.transferred;
/* During block migration the auto-converge logic incorrectly detects
@@ -1194,16 +1210,9 @@ static void migration_bitmap_sync(RAMState *rs)
}
}
- if (migrate_use_xbzrle()) {
- if (rs->iterations_prev != rs->iterations) {
- xbzrle_counters.cache_miss_rate =
- (double)(xbzrle_counters.cache_miss -
- rs->xbzrle_cache_miss_prev) /
- (rs->iterations - rs->iterations_prev);
- rs->xbzrle_cache_miss_prev = xbzrle_counters.cache_miss;
- }
- rs->iterations_prev = rs->iterations;
- }
+ migration_update_rates(rs, end_time);
+
+ rs->iterations_prev = rs->iterations;
/* reset period counters */
rs->time_last_bitmap_sync = end_time;