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,
	"Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>
Subject: [PULL 10/12] migration/multifd: Don't send device state packets with zerocopy flag
Date: Tue, 20 May 2025 13:07:49 -0400	[thread overview]
Message-ID: <20250520170751.786787-11-peterx@redhat.com> (raw)
In-Reply-To: <20250520170751.786787-1-peterx@redhat.com>

From: "Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>

If zerocopy is enabled for multifd then QIO_CHANNEL_WRITE_FLAG_ZERO_COPY
flag is forced into all multifd channel write calls via p->write_flags
that was setup in multifd_nocomp_send_setup().

However, device state packets aren't compatible with zerocopy - the data
buffer isn't getting kept pinned until multifd channel flush.

Make sure to mask that QIO_CHANNEL_WRITE_FLAG_ZERO_COPY flag in a multifd
send thread if the data being sent is device state.

Fixes: 0525b91a0b99 ("migration/multifd: Device state transfer support - send side")
Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/3bd5f48578e29f3a78f41b1e4fbea3d4b2d9b136.1747403393.git.maciej.szmigiero@oracle.com
Signed-off-by: Peter Xu <peterx@redhat.com>
---
 migration/multifd.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/migration/multifd.c b/migration/multifd.c
index f18b166bcf..b255778855 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -690,6 +690,7 @@ static void *multifd_send_thread(void *opaque)
         if (qatomic_load_acquire(&p->pending_job)) {
             bool is_device_state = multifd_payload_device_state(p->data);
             size_t total_size;
+            int write_flags_masked = 0;
 
             p->flags = 0;
             p->iovs_num = 0;
@@ -697,6 +698,9 @@ static void *multifd_send_thread(void *opaque)
 
             if (is_device_state) {
                 multifd_device_state_send_prepare(p);
+
+                /* Device state packets cannot be sent via zerocopy */
+                write_flags_masked |= QIO_CHANNEL_WRITE_FLAG_ZERO_COPY;
             } else {
                 ret = multifd_send_state->ops->send_prepare(p, &local_err);
                 if (ret != 0) {
@@ -718,7 +722,8 @@ static void *multifd_send_thread(void *opaque)
                                               &p->data->u.ram, &local_err);
             } else {
                 ret = qio_channel_writev_full_all(p->c, p->iov, p->iovs_num,
-                                                  NULL, 0, p->write_flags,
+                                                  NULL, 0,
+                                                  p->write_flags & ~write_flags_masked,
                                                   &local_err);
             }
 
-- 
2.49.0



  parent reply	other threads:[~2025-05-20 17:08 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 ` [PULL 07/12] migration: write zero pages when postcopy enabled Peter Xu
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 ` Peter Xu [this message]
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-11-peterx@redhat.com \
    --to=peterx@redhat.com \
    --cc=farosas@suse.de \
    --cc=maciej.szmigiero@oracle.com \
    --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).