Skip to content

Commit

Permalink
migration: defer migration_end & blk_mig_cleanup
Browse files Browse the repository at this point in the history
Because of the patch 3ea3b7fa9af067982f34b of kvm, which introduces a
lazy collapsing of small sptes into large sptes mechanism, now
migration_end() is a time consuming operation because it calls
memroy_global_dirty_log_stop(), which will trigger the dropping of small
sptes operation and takes about dozens of milliseconds, so call
migration_end() before all the vmsate data has already been transferred
to the destination will prolong VM downtime. This operation should be
deferred after all the data has been transferred to the destination.

blk_mig_cleanup() can be deferred too.

For a VM with 8G RAM, this patch can reduce the VM downtime about 30 ms.

Signed-off-by: Liang Li <liang.z.li@intel.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>al3
Reviewed-by: Amit Shah <amit.shah@redhat.com>al3
Signed-off-by: Juan Quintela <quintela@redhat.com>al3
  • Loading branch information
Liang Li authored and Juan Quintela committed Nov 4, 2015
1 parent 79cf9fa commit 94f5a43
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
1 change: 0 additions & 1 deletion migration/block.c
Expand Up @@ -750,7 +750,6 @@ static int block_save_complete(QEMUFile *f, void *opaque)

qemu_put_be64(f, BLK_MIG_FLAG_EOS);

blk_mig_cleanup();
return 0;
}

Expand Down
13 changes: 6 additions & 7 deletions migration/migration.c
Expand Up @@ -613,12 +613,9 @@ static void migrate_fd_cleanup(void *opaque)

assert(s->state != MIGRATION_STATUS_ACTIVE);

if (s->state != MIGRATION_STATUS_COMPLETED) {
qemu_savevm_state_cancel();
if (s->state == MIGRATION_STATUS_CANCELLING) {
migrate_set_state(s, MIGRATION_STATUS_CANCELLING,
MIGRATION_STATUS_CANCELLED);
}
if (s->state == MIGRATION_STATUS_CANCELLING) {
migrate_set_state(s, MIGRATION_STATUS_CANCELLING,
MIGRATION_STATUS_CANCELLED);
}

notifier_list_notify(&migration_state_notifiers, s);
Expand Down Expand Up @@ -1028,6 +1025,7 @@ static void *migration_thread(void *opaque)
int64_t initial_bytes = 0;
int64_t max_size = 0;
int64_t start_time = initial_time;
int64_t end_time;
bool old_vm_running = false;

rcu_register_thread();
Expand Down Expand Up @@ -1089,10 +1087,11 @@ static void *migration_thread(void *opaque)

/* If we enabled cpu throttling for auto-converge, turn it off. */
cpu_throttle_stop();
end_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);

qemu_mutex_lock_iothread();
qemu_savevm_state_cancel();
if (s->state == MIGRATION_STATUS_COMPLETED) {
int64_t end_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
uint64_t transferred_bytes = qemu_ftell(s->file);
s->total_time = end_time - s->total_time;
s->downtime = end_time - start_time;
Expand Down
1 change: 0 additions & 1 deletion migration/ram.c
Expand Up @@ -1344,7 +1344,6 @@ static int ram_save_complete(QEMUFile *f, void *opaque)

rcu_read_unlock();

migration_end();
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);

return 0;
Expand Down

0 comments on commit 94f5a43

Please sign in to comment.