Skip to content

Commit

Permalink
migration: Add dirty_pages_rate to query migrate output
Browse files Browse the repository at this point in the history
It indicates how many pages were dirtied during the last second.

Signed-off-by: Juan Quintela <quintela@redhat.com>
  • Loading branch information
Juan Quintela committed Oct 17, 2012
1 parent c6bf8e0 commit 8d01719
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
18 changes: 18 additions & 0 deletions arch_init.c
Expand Up @@ -369,6 +369,14 @@ static void migration_bitmap_sync(void)
RAMBlock *block;
ram_addr_t addr;
uint64_t num_dirty_pages_init = migration_dirty_pages;
MigrationState *s = migrate_get_current();
static int64_t start_time;
static int64_t num_dirty_pages_period;
int64_t end_time;

if (!start_time) {
start_time = qemu_get_clock_ms(rt_clock);
}

trace_migration_bitmap_sync_start();
memory_global_sync_dirty_bitmap(get_system_memory());
Expand All @@ -385,6 +393,16 @@ static void migration_bitmap_sync(void)
}
trace_migration_bitmap_sync_end(migration_dirty_pages
- num_dirty_pages_init);
num_dirty_pages_period += migration_dirty_pages - num_dirty_pages_init;
end_time = qemu_get_clock_ms(rt_clock);

/* more than 1 second = 1000 millisecons */
if (end_time > start_time + 1000) {
s->dirty_pages_rate = num_dirty_pages_period * 1000
/ (end_time - start_time);
start_time = end_time;
num_dirty_pages_period = 0;
}
}


Expand Down
4 changes: 4 additions & 0 deletions hmp.c
Expand Up @@ -175,6 +175,10 @@ void hmp_info_migrate(Monitor *mon)
info->ram->normal);
monitor_printf(mon, "normal bytes: %" PRIu64 " kbytes\n",
info->ram->normal_bytes >> 10);
if (info->ram->dirty_pages_rate) {
monitor_printf(mon, "dirty pages rate: %" PRIu64 " pages\n",
info->ram->dirty_pages_rate);
}
}

if (info->has_disk) {
Expand Down
2 changes: 2 additions & 0 deletions migration.c
Expand Up @@ -180,6 +180,8 @@ MigrationInfo *qmp_query_migrate(Error **errp)
info->ram->duplicate = dup_mig_pages_transferred();
info->ram->normal = norm_mig_pages_transferred();
info->ram->normal_bytes = norm_mig_bytes_transferred();
info->ram->dirty_pages_rate = s->dirty_pages_rate;


if (blk_mig_active()) {
info->has_disk = true;
Expand Down
1 change: 1 addition & 0 deletions migration.h
Expand Up @@ -42,6 +42,7 @@ struct MigrationState
int64_t total_time;
int64_t downtime;
int64_t expected_downtime;
int64_t dirty_pages_rate;
bool enabled_capabilities[MIGRATION_CAPABILITY_MAX];
int64_t xbzrle_cache_size;
};
Expand Down
8 changes: 6 additions & 2 deletions qapi-schema.json
Expand Up @@ -383,13 +383,17 @@
#
# @normal : number of normal pages (since 1.2)
#
# @normal-bytes : number of normal bytes sent (since 1.2)
# @normal-bytes: number of normal bytes sent (since 1.2)
#
# @dirty-pages-rate: number of pages dirtied by second by the
# guest (since 1.3)
#
# Since: 0.14.0
##
{ 'type': 'MigrationStats',
'data': {'transferred': 'int', 'remaining': 'int', 'total': 'int' ,
'duplicate': 'int', 'normal': 'int', 'normal-bytes': 'int' } }
'duplicate': 'int', 'normal': 'int', 'normal-bytes': 'int',
'dirty-pages-rate' : 'int' } }

##
# @XBZRLECacheStats
Expand Down

0 comments on commit 8d01719

Please sign in to comment.