qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: Fabiano Rosas <farosas@suse.de>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	peterx@redhat.com, Prasad Pandit <pjp@fedoraproject.org>
Subject: [PULL 07/12] migration: write zero pages when postcopy enabled
Date: Tue, 20 May 2025 13:07:46 -0400	[thread overview]
Message-ID: <20250520170751.786787-8-peterx@redhat.com> (raw)
In-Reply-To: <20250520170751.786787-1-peterx@redhat.com>

From: Prasad Pandit <pjp@fedoraproject.org>

During multifd migration, zero pages are written if
they are migrated more than once.

This may result in a migration thread hang issue when
multifd and postcopy are enabled together.

When postcopy is enabled, always write zero pages as and
when they are migrated.

Signed-off-by: Prasad Pandit <pjp@fedoraproject.org>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20250512125124.147064-2-ppandit@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
---
 migration/multifd-zero-page.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/migration/multifd-zero-page.c b/migration/multifd-zero-page.c
index dbc1184921..4cde868159 100644
--- a/migration/multifd-zero-page.c
+++ b/migration/multifd-zero-page.c
@@ -85,9 +85,27 @@ void multifd_recv_zero_page_process(MultiFDRecvParams *p)
 {
     for (int i = 0; i < p->zero_num; i++) {
         void *page = p->host + p->zero[i];
-        if (ramblock_recv_bitmap_test_byte_offset(p->block, p->zero[i])) {
+        bool received =
+                ramblock_recv_bitmap_test_byte_offset(p->block, p->zero[i]);
+
+        /*
+         * During multifd migration zero page is written to the memory
+         * only if it is migrated more than once.
+         *
+         * It becomes a problem when both multifd & postcopy options are
+         * enabled. If the zero page which was skipped during multifd phase,
+         * is accessed during the postcopy phase of the migration, a page
+         * fault occurs. But this page fault is not served because the
+         * 'receivedmap' says the zero page is already received. Thus the
+         * thread accessing that page may hang.
+         *
+         * When postcopy is enabled, always write the zero page as and when
+         * it is migrated.
+         */
+        if (migrate_postcopy_ram() || received) {
             memset(page, 0, multifd_ram_page_size());
-        } else {
+        }
+        if (!received) {
             ramblock_recv_bitmap_set_offset(p->block, p->zero[i]);
         }
     }
-- 
2.49.0



  parent reply	other threads:[~2025-05-20 17:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-20 17:07 [PULL 00/12] Migration 20250520 patches Peter Xu
2025-05-20 17:07 ` [PULL 01/12] scripts/vmstate-static-checker.py: Add new hpet entry for num_timers Peter Xu
2025-05-20 17:07 ` [PULL 02/12] qtest/migration/rdma: Enforce RLIMIT_MEMLOCK >= 128MB requirement Peter Xu
2025-05-20 17:07 ` [PULL 03/12] qtest/migration/rdma: Add test for rdma migration with ipv6 Peter Xu
2025-05-20 17:07 ` [PULL 04/12] ci: Re-enable python subtests in qtest migration suite Peter Xu
2025-05-20 17:07 ` [PULL 05/12] ci: Fix build-previous-qemu when the version tag is absent Peter Xu
2025-05-20 17:07 ` [PULL 06/12] ci: Reduce the size of artifacts for build-previous-qemu Peter Xu
2025-05-20 17:07 ` Peter Xu [this message]
2025-05-20 17:07 ` [PULL 08/12] migration: enable multifd and postcopy together Peter Xu
2025-05-20 17:07 ` [PULL 09/12] tests/qtest/migration: add postcopy tests with multifd Peter Xu
2025-05-20 17:07 ` [PULL 10/12] migration/multifd: Don't send device state packets with zerocopy flag Peter Xu
2025-05-20 17:07 ` [PULL 11/12] migration: Allow caps to be set when preempt or multifd cap enabled Peter Xu
2025-05-20 17:07 ` [PULL 12/12] migration/hmp: Add "info migrate -a", reorg the dump Peter Xu
2025-05-22 18:47 ` [PULL 00/12] Migration 20250520 patches Stefan Hajnoczi

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=20250520170751.786787-8-peterx@redhat.com \
    --to=peterx@redhat.com \
    --cc=farosas@suse.de \
    --cc=pjp@fedoraproject.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.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).