[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 11/11] So we use multifd to transmit zero pages.
From: |
Juan Quintela |
Subject: |
[PATCH v2 11/11] So we use multifd to transmit zero pages. |
Date: |
Mon, 30 Jan 2023 09:09:56 +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 ab86c6601d..6293dee983 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -2608,8 +2608,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 c70cc25169..d375f2ccde 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2421,6 +2421,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
*
@@ -3223,7 +3248,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.39.1
- [PATCH v2 04/11] multifd: Count the number of bytes sent correctly, (continued)
- [PATCH v2 04/11] multifd: Count the number of bytes sent correctly, Juan Quintela, 2023/01/30
- [PATCH v2 05/11] migration: Make ram_save_target_page() a pointer, Juan Quintela, 2023/01/30
- [PATCH v2 06/11] multifd: Make flags field thread local, Juan Quintela, 2023/01/30
- [PATCH v2 07/11] multifd: Prepare to send a packet without the mutex held, Juan Quintela, 2023/01/30
- [PATCH v2 08/11] multifd: Add capability to enable/disable zero_page, Juan Quintela, 2023/01/30
- [PATCH v2 10/11] multifd: Zero pages transmission, Juan Quintela, 2023/01/30
- [PATCH v2 09/11] multifd: Support for zero pages transmission, Juan Quintela, 2023/01/30
- [PATCH v2 11/11] So we use multifd to transmit zero pages.,
Juan Quintela <=