From: Hao Xiang <hao.xiang@linux.dev>
To: pbonzini@redhat.com, berrange@redhat.com, eduardo@habkost.net,
peterx@redhat.com, farosas@suse.de, eblake@redhat.com,
armbru@redhat.com, thuth@redhat.com, lvivier@redhat.com,
jdenemar@redhat.com, marcel.apfelbaum@gmail.com,
philmd@linaro.org, wangyanan55@huawei.com, qemu-devel@nongnu.org
Cc: Hao Xiang <hao.xiang@bytedance.com>
Subject: [PATCH v6 5/7] migration/multifd: Implement ram_save_target_page_multifd to handle multifd version of MigrationOps::ram_save_target_page.
Date: Mon, 11 Mar 2024 18:00:13 +0000 [thread overview]
Message-ID: <20240311180015.3359271-6-hao.xiang@linux.dev> (raw)
In-Reply-To: <20240311180015.3359271-1-hao.xiang@linux.dev>
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>
---
migration/ram.c | 38 +++++++++++++++++++++++++++++---------
1 file changed, 29 insertions(+), 9 deletions(-)
diff --git a/migration/ram.c b/migration/ram.c
index d1f97cf862..1d52b5c37f 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 */
@@ -3113,7 +3128,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.30.2
next prev parent reply other threads:[~2024-03-11 18:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-11 18:00 [PATCH v6 0/7] Introduce multifd zero page checking Hao Xiang
2024-03-11 18:00 ` [PATCH v6 1/7] migration/multifd: Allow zero pages in file migration Hao Xiang
2024-03-11 18:00 ` [PATCH v6 2/7] migration/multifd: Allow clearing of the file_bmap from multifd Hao Xiang
2024-03-11 18:00 ` [PATCH v6 3/7] migration/multifd: Add new migration option zero-page-detection Hao Xiang
2024-03-11 18:00 ` [PATCH v6 4/7] migration/multifd: Implement zero page transmission on the multifd thread Hao Xiang
2024-03-11 20:18 ` Fabiano Rosas
2024-03-11 18:00 ` Hao Xiang [this message]
2024-03-11 18:00 ` [PATCH v6 6/7] migration/multifd: Enable multifd zero page checking by default Hao Xiang
2024-03-11 20:41 ` Peter Xu
2024-03-11 20:44 ` Fabiano Rosas
2024-03-11 18:00 ` [PATCH v6 7/7] migration/multifd: Add new migration test cases for legacy zero page checking Hao Xiang
2024-03-11 20:59 ` Peter Xu
2024-03-11 20:43 ` [PATCH v6 0/7] Introduce multifd " Peter Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240311180015.3359271-6-hao.xiang@linux.dev \
--to=hao.xiang@linux.dev \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=eblake@redhat.com \
--cc=eduardo@habkost.net \
--cc=farosas@suse.de \
--cc=hao.xiang@bytedance.com \
--cc=jdenemar@redhat.com \
--cc=lvivier@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
--cc=wangyanan55@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).