diff options
author | Juan Quintela <quintela@redhat.com> | 2017-03-14 18:20:30 +0100 |
---|---|---|
committer | Juan Quintela <quintela@redhat.com> | 2017-04-21 12:25:38 +0200 |
commit | 47ad861976d8490047c53d5a80b562776f3c951b (patch) | |
tree | 0a2e183f707019153fca373e6b8ed484018c3232 /migration | |
parent | abbf1d7f9bb43ba5fac7a9c27b67d9a78749e67a (diff) | |
download | qemu-47ad861976d8490047c53d5a80b562776f3c951b.zip qemu-47ad861976d8490047c53d5a80b562776f3c951b.tar.gz qemu-47ad861976d8490047c53d5a80b562776f3c951b.tar.bz2 |
ram: Move dirty_pages_rate to RAMState
Treat it like the rest of ram stats counters. Export its value the
same way. As an added bonus, no more MigrationState used in
migration_bitmap_sync();
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
--
Again, dave was the one reviewing it
Diffstat (limited to 'migration')
-rw-r--r-- | migration/migration.c | 7 | ||||
-rw-r--r-- | migration/ram.c | 12 |
2 files changed, 12 insertions, 7 deletions
diff --git a/migration/migration.c b/migration/migration.c index dcf9b94..e430aec 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -661,7 +661,7 @@ static void populate_ram_info(MigrationInfo *info, MigrationState *s) if (s->state != MIGRATION_STATUS_COMPLETED) { info->ram->remaining = ram_bytes_remaining(); - info->ram->dirty_pages_rate = s->dirty_pages_rate; + info->ram->dirty_pages_rate = ram_dirty_pages_rate(); } } @@ -1117,7 +1117,6 @@ MigrationState *migrate_init(const MigrationParams *params) s->mbps = 0.0; s->downtime = 0; s->expected_downtime = 0; - s->dirty_pages_rate = 0; s->setup_time = 0; s->start_postcopy = false; s->postcopy_after_devices = false; @@ -2007,8 +2006,8 @@ static void *migration_thread(void *opaque) bandwidth, max_size); /* if we haven't sent anything, we don't want to recalculate 10000 is a small enough number for our purposes */ - if (s->dirty_pages_rate && transferred_bytes > 10000) { - s->expected_downtime = s->dirty_pages_rate * + if (ram_dirty_pages_rate() && transferred_bytes > 10000) { + s->expected_downtime = ram_dirty_pages_rate() * (1ul << qemu_target_page_bits()) / bandwidth; } diff --git a/migration/ram.c b/migration/ram.c index ef4f508..c5240eb 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -212,6 +212,8 @@ struct RAMState { uint64_t migration_dirty_pages; /* total number of bytes transferred */ uint64_t bytes_transferred; + /* number of dirtied pages in the last second */ + uint64_t dirty_pages_rate; /* protects modification of the bitmap */ QemuMutex bitmap_mutex; /* Ram Bitmap protected by RCU */ @@ -276,6 +278,11 @@ uint64_t ram_dirty_sync_count(void) return ram_state.bitmap_sync_count; } +uint64_t ram_dirty_pages_rate(void) +{ + return ram_state.dirty_pages_rate; +} + /* used by the search for pages to send */ struct PageSearchStatus { /* Current block being searched */ @@ -666,7 +673,6 @@ uint64_t ram_pagesize_summary(void) static void migration_bitmap_sync(RAMState *rs) { RAMBlock *block; - MigrationState *s = migrate_get_current(); int64_t end_time; uint64_t bytes_xfer_now; @@ -705,7 +711,7 @@ static void migration_bitmap_sync(RAMState *rs) throttling */ bytes_xfer_now = ram_bytes_transferred(); - if (s->dirty_pages_rate && + if (rs->dirty_pages_rate && (rs->num_dirty_pages_period * TARGET_PAGE_SIZE > (bytes_xfer_now - rs->bytes_xfer_prev) / 2) && (rs->dirty_rate_high_cnt++ >= 2)) { @@ -726,7 +732,7 @@ static void migration_bitmap_sync(RAMState *rs) rs->iterations_prev = rs->iterations; rs->xbzrle_cache_miss_prev = rs->xbzrle_cache_miss; } - s->dirty_pages_rate = rs->num_dirty_pages_period * 1000 + rs->dirty_pages_rate = rs->num_dirty_pages_period * 1000 / (end_time - rs->time_last_bitmap_sync); rs->time_last_bitmap_sync = end_time; rs->num_dirty_pages_period = 0; |