[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 32/34] migration/multifd: Implement ram_save_target_page_multifd t
From: |
peterx |
Subject: |
[PULL 32/34] migration/multifd: Implement ram_save_target_page_multifd to handle multifd version of MigrationOps::ram_save_target_page. |
Date: |
Mon, 11 Mar 2024 17:59:23 -0400 |
From: Hao Xiang <hao.xiang@bytedance.com>
1. Add a dedicated handler for MigrationOps::ram_save_target_page in
multifd live migration.
2. Refactor ram_save_target_page_legacy so that the legacy and multifd
handlers don't have internal functions calling into each other.
Signed-off-by: Hao Xiang <hao.xiang@bytedance.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Message-Id: <20240226195654.934709-4-hao.xiang@bytedance.com>
Link: 20240311180015.3359271-6-hao.xiang@linux.dev">https://lore.kernel.org/r/20240311180015.3359271-6-hao.xiang@linux.dev
Signed-off-by: Peter Xu <peterx@redhat.com>
---
migration/ram.c | 38 +++++++++++++++++++++++++++++---------
1 file changed, 29 insertions(+), 9 deletions(-)
diff --git a/migration/ram.c b/migration/ram.c
index c26435adc7..8deb84984f 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2079,7 +2079,6 @@ static bool save_compress_page(RAMState *rs,
PageSearchStatus *pss,
*/
static int ram_save_target_page_legacy(RAMState *rs, PageSearchStatus *pss)
{
- RAMBlock *block = pss->block;
ram_addr_t offset = ((ram_addr_t)pss->page) << TARGET_PAGE_BITS;
int res;
@@ -2095,17 +2094,33 @@ static int ram_save_target_page_legacy(RAMState *rs,
PageSearchStatus *pss)
return 1;
}
+ return ram_save_page(rs, pss);
+}
+
+/**
+ * ram_save_target_page_multifd: send one target page to multifd workers
+ *
+ * Returns 1 if the page was queued, -1 otherwise.
+ *
+ * @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;
+
/*
- * Do not use multifd in postcopy as one whole host page should be
- * placed. Meanwhile postcopy requires atomic update of pages, so even
- * if host page size == guest page size the dest guest during run may
- * still see partially copied pages which is data corruption.
+ * While using multifd live migration, we still need to handle zero
+ * page checking on the migration main thread.
*/
- if (migrate_multifd() && !migration_in_postcopy()) {
- return ram_save_multifd_page(block, offset);
+ if (migrate_zero_page_detection() == ZERO_PAGE_DETECTION_LEGACY) {
+ if (save_zero_page(rs, pss, offset)) {
+ return 1;
+ }
}
- return ram_save_page(rs, pss);
+ return ram_save_multifd_page(block, offset);
}
/* Should be called before sending a host page */
@@ -3112,7 +3127,12 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
}
migration_ops = g_malloc0(sizeof(MigrationOps));
- migration_ops->ram_save_target_page = ram_save_target_page_legacy;
+
+ if (migrate_multifd()) {
+ migration_ops->ram_save_target_page = ram_save_target_page_multifd;
+ } else {
+ migration_ops->ram_save_target_page = ram_save_target_page_legacy;
+ }
bql_unlock();
ret = multifd_send_sync_main();
--
2.44.0
- [PULL 15/34] migration: Fix format in error message, (continued)
- [PULL 15/34] migration: Fix format in error message, peterx, 2024/03/11
- [PULL 19/34] migration: export migration_is_active, peterx, 2024/03/11
- [PULL 20/34] migration: export migration_is_running, peterx, 2024/03/11
- [PULL 23/34] migration: migration_is_device, peterx, 2024/03/11
- [PULL 22/34] migration: migration_thread_is_self, peterx, 2024/03/11
- [PULL 25/34] migration: privatize colo interfaces, peterx, 2024/03/11
- [PULL 26/34] migration: delete unused accessors, peterx, 2024/03/11
- [PULL 28/34] migration/multifd: Allow zero pages in file migration, peterx, 2024/03/11
- [PULL 24/34] migration: migration_file_set_error, peterx, 2024/03/11
- [PULL 30/34] migration/multifd: Add new migration option zero-page-detection., peterx, 2024/03/11
- [PULL 32/34] migration/multifd: Implement ram_save_target_page_multifd to handle multifd version of MigrationOps::ram_save_target_page.,
peterx <=
- [PULL 33/34] migration/multifd: Enable multifd zero page checking by default., peterx, 2024/03/11
- [PULL 31/34] migration/multifd: Implement zero page transmission on the multifd thread., peterx, 2024/03/11
- Re: [PULL 00/34] Migration 20240311 patches, Peter Maydell, 2024/03/12