From 9d93df4c8f42cd2f1dd1837a243c0ed5af8d96a8 Mon Sep 17 00:00:00 2001 From: Jinrong Liang Date: Tue, 18 Mar 2025 10:24:05 +0800 Subject: [PATCH] vm-migration: Optimize downtime by moving stop_dirty_log() The larger the VM memory, the greater the memory pressure, and the greater the stop_dirty_log() overhead. Moving stop_dirty_log() outside the downtime period can reduce downtime. Signed-off-by: Jinrong Liang --- vmm/src/lib.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/vmm/src/lib.rs b/vmm/src/lib.rs index cf28a38b5..e96b6e3fa 100644 --- a/vmm/src/lib.rs +++ b/vmm/src/lib.rs @@ -1209,9 +1209,6 @@ impl Vmm { // Send last batch of dirty pages Self::vm_maybe_send_dirty_pages(vm, &mut socket)?; - - // Stop logging dirty pages - vm.stop_dirty_log()?; } // Capture snapshot and send it let vm_snapshot = vm.snapshot()?; @@ -1231,6 +1228,11 @@ impl Vmm { MigratableError::MigrateSend(anyhow!("Error completing migration")), )?; + // Stop logging dirty pages + if !send_data_migration.local { + vm.stop_dirty_log()?; + } + info!("Migration complete"); // Let every Migratable object know about the migration being complete