[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 13/13] migration: Use multifd before we check for the zero pag
From: |
Juan Quintela |
Subject: |
[PATCH v6 13/13] migration: Use multifd before we check for the zero page |
Date: |
Wed, 11 May 2022 00:42:20 +0200 |
So we use multifd to transmit zero pages.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
- Check zero_page property before using new code (Dave)
---
migration/ram.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/migration/ram.c b/migration/ram.c
index 0a91b87bd2..64e45ba915 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2181,6 +2181,32 @@ static int ram_save_target_page_legacy(RAMState *rs,
PageSearchStatus *pss)
return ram_save_page(rs, pss);
}
+/**
+ * ram_save_target_page_multifd: save one target page
+ *
+ * Returns the number of pages written
+ *
+ * @rs: current RAM state
+ * @pss: data about the page we want to send
+ */
+static int ram_save_target_page_multifd(RAMState *rs, PageSearchStatus *pss)
+{
+ RAMBlock *block = pss->block;
+ ram_addr_t offset = ((ram_addr_t)pss->page) << TARGET_PAGE_BITS;
+ int res;
+
+ if (!migration_in_postcopy()) {
+ return ram_save_multifd_page(rs, block, offset);
+ }
+
+ res = save_zero_page(rs, block, offset);
+ if (res > 0) {
+ return res;
+ }
+
+ return ram_save_page(rs, pss);
+}
+
/**
* ram_save_host_page: save a whole host page
*
@@ -2944,7 +2970,11 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
ram_control_before_iterate(f, RAM_CONTROL_SETUP);
ram_control_after_iterate(f, RAM_CONTROL_SETUP);
- (*rsp)->ram_save_target_page = ram_save_target_page_legacy;
+ if (migrate_use_multifd() && migrate_use_multifd_zero_page()) {
+ (*rsp)->ram_save_target_page = ram_save_target_page_multifd;
+ } else {
+ (*rsp)->ram_save_target_page = ram_save_target_page_legacy;
+ }
multifd_send_sync_main(f);
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
qemu_fflush(f);
--
2.35.1
- [PATCH v6 05/13] multifd: Count the number of bytes sent correctly, (continued)
- [PATCH v6 05/13] multifd: Count the number of bytes sent correctly, Juan Quintela, 2022/05/10
- [PATCH v6 04/13] migration: Export ram_transferred_ram(), Juan Quintela, 2022/05/10
- [PATCH v6 08/13] multifd: Prepare to send a packet without the mutex held, Juan Quintela, 2022/05/10
- [PATCH v6 09/13] multifd: Add property to enable/disable zero_page, Juan Quintela, 2022/05/10
- [PATCH v6 10/13] migration: Export ram_release_page(), Juan Quintela, 2022/05/10
- [PATCH v6 06/13] migration: Make ram_save_target_page() a pointer, Juan Quintela, 2022/05/10
- [PATCH v6 11/13] multifd: Support for zero pages transmission, Juan Quintela, 2022/05/10
- [PATCH v6 02/13] multifd: Create page_size fields into both MultiFD{Recv, Send}Params, Juan Quintela, 2022/05/10
- [PATCH v6 13/13] migration: Use multifd before we check for the zero page,
Juan Quintela <=
- [PATCH v6 12/13] multifd: Zero pages transmission, Juan Quintela, 2022/05/10
- [PATCH v6 07/13] multifd: Make flags field thread local, Juan Quintela, 2022/05/10
- Re: [PATCH v6 00/13] Migration: Transmit and detect zero pages in the multifd threads, Dr. David Alan Gilbert, 2022/05/12