[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 11/11] So we use multifd to transmit zero pages.
From: |
Juan Quintela |
Subject: |
[PATCH 11/11] So we use multifd to transmit zero pages. |
Date: |
Mon, 28 Nov 2022 11:04:22 +0100 |
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
- Check zero_page property before using new code (Dave)
---
migration/migration.c | 3 +--
migration/ram.c | 32 +++++++++++++++++++++++++++++++-
2 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index 2a828764ed..1cdeeb19b8 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -2616,8 +2616,7 @@ bool migrate_use_main_zero_page(void)
{
MigrationState *s = migrate_get_current();
- /* We will enable this when we add the right code. */
- return true ||
s->enabled_capabilities[MIGRATION_CAPABILITY_MAIN_ZERO_PAGE];
+ return s->enabled_capabilities[MIGRATION_CAPABILITY_MAIN_ZERO_PAGE];
}
bool migrate_pause_before_switchover(void)
diff --git a/migration/ram.c b/migration/ram.c
index f23a01719b..f14ee63728 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2404,6 +2404,31 @@ out:
return ret;
}
+/**
+ * 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;
+
+ if (!migration_in_postcopy()) {
+ return ram_save_multifd_page(pss->pss_channel, block, offset);
+ }
+
+ int res = save_zero_page(pss, block, offset);
+ if (res > 0) {
+ return res;
+ }
+
+ return ram_save_page(rs, pss);
+}
+
/**
* ram_save_host_page: save a whole host page
*
@@ -3206,7 +3231,12 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
ram_control_after_iterate(f, RAM_CONTROL_SETUP);
migration_ops = g_malloc0(sizeof(MigrationOps));
- migration_ops->ram_save_target_page = ram_save_target_page_legacy;
+ if (migrate_use_multifd() && !migrate_use_main_zero_page()) {
+ migration_ops->ram_save_target_page = ram_save_target_page_multifd;
+ } else {
+ migration_ops->ram_save_target_page = ram_save_target_page_legacy;
+ }
+
ret = multifd_send_sync_main(f);
if (ret < 0) {
return ret;
--
2.38.1
- [PATCH 01/11] migration: Update atomic stats out of the mutex, (continued)
- [PATCH 01/11] migration: Update atomic stats out of the mutex, Juan Quintela, 2022/11/28
- [PATCH 03/11] multifd: We already account for this packet on the multifd thread, Juan Quintela, 2022/11/28
- [PATCH 02/11] migration: Make multifd_bytes atomic, Juan Quintela, 2022/11/28
- [PATCH 05/11] migration: Make ram_save_target_page() a pointer, Juan Quintela, 2022/11/28
- [PATCH 04/11] multifd: Count the number of bytes sent correctly, Juan Quintela, 2022/11/28
- [PATCH 07/11] multifd: Prepare to send a packet without the mutex held, Juan Quintela, 2022/11/28
- [PATCH 06/11] multifd: Make flags field thread local, Juan Quintela, 2022/11/28
- [PATCH 08/11] multifd: Add capability to enable/disable zero_page, Juan Quintela, 2022/11/28
- [PATCH 09/11] multifd: Support for zero pages transmission, Juan Quintela, 2022/11/28
- [PATCH 10/11] multifd: Zero pages transmission, Juan Quintela, 2022/11/28
- [PATCH 11/11] So we use multifd to transmit zero pages.,
Juan Quintela <=