[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 13/13] migration: Use multifd before we check for the zero pag
From: |
Juan Quintela |
Subject: |
[PATCH v7 13/13] migration: Use multifd before we check for the zero page |
Date: |
Tue, 31 May 2022 12:43:18 +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 | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/migration/ram.c b/migration/ram.c
index 7ceef7976b..f9959262fa 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
*
@@ -2945,7 +2971,12 @@ 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;
+ }
+
ret = multifd_send_sync_main(f);
if (ret < 0) {
return ret;
--
2.35.3
- [PATCH v7 03/13] multifd: Create page_count fields into both MultiFD{Recv, Send}Params, (continued)
- [PATCH v7 03/13] multifd: Create page_count fields into both MultiFD{Recv, Send}Params, Juan Quintela, 2022/05/31
- [PATCH v7 04/13] migration: Export ram_transferred_ram(), Juan Quintela, 2022/05/31
- [PATCH v7 05/13] multifd: Count the number of bytes sent correctly, Juan Quintela, 2022/05/31
- [PATCH v7 06/13] migration: Make ram_save_target_page() a pointer, Juan Quintela, 2022/05/31
- [PATCH v7 07/13] multifd: Make flags field thread local, Juan Quintela, 2022/05/31
- [PATCH v7 08/13] multifd: Prepare to send a packet without the mutex held, Juan Quintela, 2022/05/31
- [PATCH v7 09/13] multifd: Add property to enable/disable zero_page, Juan Quintela, 2022/05/31
- [PATCH v7 10/13] migration: Export ram_release_page(), Juan Quintela, 2022/05/31
- [PATCH v7 12/13] multifd: Zero pages transmission, Juan Quintela, 2022/05/31
- [PATCH v7 11/13] multifd: Support for zero pages transmission, Juan Quintela, 2022/05/31
- [PATCH v7 13/13] migration: Use multifd before we check for the zero page,
Juan Quintela <=