[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 11/17] migration: optimize the downtime
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 11/17] migration: optimize the downtime |
Date: |
Tue, 1 Aug 2017 18:17:19 +0200 |
From: Jay Zhou <address@hidden>
Qemu_savevm_state_cleanup takes about 300ms in my ram migration tests
with a 8U24G vm(20G is really occupied), the main cost comes from
KVM_SET_USER_MEMORY_REGION ioctl when mem.memory_size = 0 in
kvm_set_user_memory_region. In kmod, the main cost is
kvm_zap_obsolete_pages, which traverses the active_mmu_pages list to
zap the unsync sptes.
It can be optimized by delaying memory_global_dirty_log_stop to the next
vm_start.
Changes v2->v3:
- NULL VMChangeStateHandler if it is deleted and protect the scenario
of nested invocations of memory_global_dirty_log_start/stop [Paolo]
Changes v1->v2:
- create a VMChangeStateHandler in memory.c to reduce the coupling [Paolo]
Signed-off-by: Jay Zhou <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
memory.c | 36 +++++++++++++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/memory.c b/memory.c
index a7bc70a..c0adc35 100644
--- a/memory.c
+++ b/memory.c
@@ -2357,8 +2357,15 @@ void memory_global_dirty_log_sync(void)
}
}
+static VMChangeStateEntry *vmstate_change;
+
void memory_global_dirty_log_start(void)
{
+ if (vmstate_change) {
+ qemu_del_vm_change_state_handler(vmstate_change);
+ vmstate_change = NULL;
+ }
+
global_dirty_log = true;
MEMORY_LISTENER_CALL_GLOBAL(log_global_start, Forward);
@@ -2369,7 +2376,7 @@ void memory_global_dirty_log_start(void)
memory_region_transaction_commit();
}
-void memory_global_dirty_log_stop(void)
+static void memory_global_dirty_log_do_stop(void)
{
global_dirty_log = false;
@@ -2381,6 +2388,33 @@ void memory_global_dirty_log_stop(void)
MEMORY_LISTENER_CALL_GLOBAL(log_global_stop, Reverse);
}
+static void memory_vm_change_state_handler(void *opaque, int running,
+ RunState state)
+{
+ if (running) {
+ memory_global_dirty_log_do_stop();
+
+ if (vmstate_change) {
+ qemu_del_vm_change_state_handler(vmstate_change);
+ vmstate_change = NULL;
+ }
+ }
+}
+
+void memory_global_dirty_log_stop(void)
+{
+ if (!runstate_is_running()) {
+ if (vmstate_change) {
+ return;
+ }
+ vmstate_change = qemu_add_vm_change_state_handler(
+ memory_vm_change_state_handler, NULL);
+ return;
+ }
+
+ memory_global_dirty_log_do_stop();
+}
+
static void listener_add_address_space(MemoryListener *listener,
AddressSpace *as)
{
--
1.8.3.1
- Re: [Qemu-devel] [PULL 02/17] cpu_physical_memory_sync_dirty_bitmap: Fix alignment check, (continued)
- [Qemu-devel] [PULL 01/17] vl.c/exit: pause cpus before closing block devices, Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 05/17] char: don't exit on hmp 'chardev-add help', Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 04/17] char-fd: remove useless chr pointer, Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 03/17] accel: cleanup error output, Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 06/17] docs: document deprecation policy & deprecated features in appendix, Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 08/17] exec: Add lock parameter to qemu_ram_ptr_length, Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 09/17] bt: stop the sdp memory allocation craziness, Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 10/17] qemu-options: document existance of versioned machine types, Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 11/17] migration: optimize the downtime,
Paolo Bonzini <=
- [Qemu-devel] [PULL 12/17] hw/scsi/vmw_pvscsi: Remove the dead error handling, Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 13/17] hw/scsi/vmw_pvscsi: Convert to realize, Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 14/17] rtc-test: cleanup register_b_set_flag test, Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 15/17] rtc-test: introduce more update tests, Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 16/17] mc146818rtc: simplify check_update_timer, Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 17/17] mc146818rtc: implement UIP latching as intended, Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 07/17] target-i386: kvm_get/put_vcpu_events don't handle sipi_vector, Paolo Bonzini, 2017/08/01
- Re: [Qemu-devel] [PULL 00/17] Misc changes for QEMU 2.10-rc1 (?), no-reply, 2017/08/01