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/ram.c | |
parent | abbf1d7f9bb43ba5fac7a9c27b67d9a78749e67a (diff) |
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/ram.c')
-rw-r--r-- | migration/ram.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/migration/ram.c b/migration/ram.c index ef4f508b6c..c5240eb39d 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; |