From nobody Mon May 13 12:33:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1711124104; cv=none; d=zohomail.com; s=zohoarc; b=bZtblpmtCPweSWf+cqCIICq/kGeRXUgzer64WcwyC4rr8s4iX1dd3QAz7vPaouw22rBJJdAme5irBGC1gr3ydW7POppkuq0mWYFxbSU99RvT9HrsyW7yFnanaxREDV3vXJAAuSrnN1xCvlaCZtwOwuMcBEWn0rim5nbBMUi9iJ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711124104; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ptE4Jzsb6riHNpWnGjngqsuwWnV2Uk4JwkkRsTQX1vE=; b=hfnegTi8G+P5oGRTE9qZF+N0pkkma83dUrk5wTNylGFq0k44USfbjGbR/Zw7fL1y+pyNTrbRU3EbLzRVePGO25evlm4YD8aVTgFy0DySvSEawDa307e5wSSEsEA0CyY4ssK6c/p+SqldNAA1aZPmp5vyWPja8PMKoWtvTqbmsTQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1711124104869341.32718347131095; Fri, 22 Mar 2024 09:15:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnhXM-0000bm-8n; Fri, 22 Mar 2024 12:14:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rnhXK-0000b3-8J for qemu-devel@nongnu.org; Fri, 22 Mar 2024 12:14:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rnhXE-0000kx-N1 for qemu-devel@nongnu.org; Fri, 22 Mar 2024 12:14:29 -0400 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-19-30cA5LeINLiqDgpfjfoMQA-1; Fri, 22 Mar 2024 12:14:21 -0400 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-69672754479so962466d6.1 for ; Fri, 22 Mar 2024 09:14:21 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id 6-20020a05621420e600b006904c34d5basm1202708qvk.64.2024.03.22.09.14.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 09:14:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711124062; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ptE4Jzsb6riHNpWnGjngqsuwWnV2Uk4JwkkRsTQX1vE=; b=arvADdJzHhvo2bKTj9D7k00kU5fNOSbttuW/G3k09gG6NRN8FHcgN5+VwPZolJFXlRtpYM IFLkZ/fRdZtlZNGzQM4ByiLOAyKQitrhBSSqHqZV6qPbrG7PTYhPWHqK3+4xqCCasaqsIx 71eIevGC8RLxHRsX9mTS7SGZJSxT3+4= X-MC-Unique: 30cA5LeINLiqDgpfjfoMQA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711124060; x=1711728860; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ptE4Jzsb6riHNpWnGjngqsuwWnV2Uk4JwkkRsTQX1vE=; b=Nr19U65FB3ZTnjVRn3Bukvj7XofTF0moS4Nfp/LNFx9HJj0VuJBkycuWfzqiQxuHMO Q9LiZqSkYXK39vhOgFYiq88T9In/+wM/NHj0d1YK/oADmsyljKXjXGg055IU7y3/9iRf 3sbGg/vV73TzSke1uAkvXLv/ganM0YyRZcR64B5Q5+ejhm7brQFSu3PdUGJiew1rwqIH 40ZoNQdJEu7HaVLNHVVMnTBSpgG0rEb0fX5u2enfQIogioydaE/dxglo5JedcXyT6VXA UbBYAi+258u8bPrH8CC/OeyIRZz2k/8TQ2QIGNAR0YU7wG8GqjA8x3B5wsuU/Q1Ncfqn 7gPg== X-Gm-Message-State: AOJu0Yx+7DOhWzlgDFAjg65OLiYPHjHpdXdFPJihqrwULAYIliF4gQrY DXSEkm6aBFQGLUd9r/cYJpZeijsoCnMxGRxR5V2mzEBgC7/m+zNRA35CksGHaIyl6fW6iwPlBfH 7sKRswi1b79IHjolO5LiLDdXBGOBnUPPgA7pHnufVy1c6VkiXjvsrh1xHOJeYIc0fTxO8lms/1b t6+KoKw6XsXdN+gsJpZrlSidleuX7s4R84Dg== X-Received: by 2002:a05:6214:2b86:b0:696:732f:41ce with SMTP id kr6-20020a0562142b8600b00696732f41cemr1095441qvb.0.1711124060341; Fri, 22 Mar 2024 09:14:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFWUgrR6fTWAZ0ERhLxo3L5ZTfZB8uXoKbcHzgiAZwvw70ZVw+hJC8YB1KsxVM86UUp0np3HA== X-Received: by 2002:a05:6214:2b86:b0:696:732f:41ce with SMTP id kr6-20020a0562142b8600b00696732f41cemr1095408qvb.0.1711124059681; Fri, 22 Mar 2024 09:14:19 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org Cc: Fabiano Rosas , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , peterx@redhat.com Subject: [PULL 1/3] migration: Revert mapped-ram multifd support to fd: URI Date: Fri, 22 Mar 2024 12:14:15 -0400 Message-ID: <20240322161417.759586-2-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240322161417.759586-1-peterx@redhat.com> References: <20240322161417.759586-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.222, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1711124106405100009 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas This reverts commit decdc76772c453ff1444612e910caa0d45cd8eac in full and also the relevant migration-tests from 7a09f092834641b7a793d50a3a261073bbb404a6. After the addition of the new QAPI-based migration address API in 8.2 we've been converting an "fd:" URI into a SocketAddress, missing the fact that the "fd:" syntax could also be used for a plain file instead of a socket. This is a problem because the SocketAddress is part of the API, so we're effectively asking users to create a "socket" channel to pass in a plain file. The easiest way to fix this situation is to deprecate the usage of both SocketAddress and "fd:" when used with a plain file for migration. Since this has been possible since 8.2, we can wait until 9.1 to deprecate it. For 9.0, however, we should avoid adding further support to migration to a plain file using the old "fd:" syntax or the new SocketAddress API, and instead require the usage of either the old-style "file:" URI or the FileMigrationArgs::filename field of the new API with the "/dev/fdset/NN" syntax, both of which are already supported. Signed-off-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240319210941.1907-1-farosas@suse.de Signed-off-by: Peter Xu --- migration/fd.h | 2 -- migration/fd.c | 56 ++++-------------------------------- migration/file.c | 19 ++---------- migration/migration.c | 13 --------- migration/multifd.c | 2 -- tests/qtest/migration-test.c | 43 --------------------------- 6 files changed, 8 insertions(+), 127 deletions(-) diff --git a/migration/fd.h b/migration/fd.h index 0c0a18d9e7..b901bc014e 100644 --- a/migration/fd.h +++ b/migration/fd.h @@ -20,6 +20,4 @@ void fd_start_incoming_migration(const char *fdname, Erro= r **errp); =20 void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp); -void fd_cleanup_outgoing_migration(void); -int fd_args_get_fd(void); #endif diff --git a/migration/fd.c b/migration/fd.c index fe0d096abd..449adaa2de 100644 --- a/migration/fd.c +++ b/migration/fd.c @@ -15,42 +15,19 @@ */ =20 #include "qemu/osdep.h" -#include "qapi/error.h" #include "channel.h" #include "fd.h" #include "file.h" #include "migration.h" #include "monitor/monitor.h" -#include "io/channel-file.h" -#include "io/channel-socket.h" #include "io/channel-util.h" -#include "options.h" #include "trace.h" =20 =20 -static struct FdOutgoingArgs { - int fd; -} outgoing_args; - -int fd_args_get_fd(void) -{ - return outgoing_args.fd; -} - -void fd_cleanup_outgoing_migration(void) -{ - if (outgoing_args.fd > 0) { - close(outgoing_args.fd); - outgoing_args.fd =3D -1; - } -} - void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Er= ror **errp) { QIOChannel *ioc; int fd =3D monitor_get_fd(monitor_cur(), fdname, errp); - int newfd; - if (fd =3D=3D -1) { return; } @@ -62,18 +39,6 @@ void fd_start_outgoing_migration(MigrationState *s, cons= t char *fdname, Error ** return; } =20 - /* - * This is dup()ed just to avoid referencing an fd that might - * be already closed by the iochannel. - */ - newfd =3D dup(fd); - if (newfd =3D=3D -1) { - error_setg_errno(errp, errno, "Could not dup FD %d", fd); - object_unref(ioc); - return; - } - outgoing_args.fd =3D newfd; - qio_channel_set_name(ioc, "migration-fd-outgoing"); migration_channel_connect(s, ioc, NULL, NULL); object_unref(OBJECT(ioc)); @@ -104,20 +69,9 @@ void fd_start_incoming_migration(const char *fdname, Er= ror **errp) return; } =20 - if (migrate_multifd()) { - if (fd_is_socket(fd)) { - error_setg(errp, - "Multifd migration to a socket FD is not supported"= ); - object_unref(ioc); - return; - } - - file_create_incoming_channels(ioc, errp); - } else { - qio_channel_set_name(ioc, "migration-fd-incoming"); - qio_channel_add_watch_full(ioc, G_IO_IN, - fd_accept_incoming_migration, - NULL, NULL, - g_main_context_get_thread_default()); - } + qio_channel_set_name(ioc, "migration-fd-incoming"); + qio_channel_add_watch_full(ioc, G_IO_IN, + fd_accept_incoming_migration, + NULL, NULL, + g_main_context_get_thread_default()); } diff --git a/migration/file.c b/migration/file.c index b6e8ba13f2..ab18ba505a 100644 --- a/migration/file.c +++ b/migration/file.c @@ -11,7 +11,6 @@ #include "qemu/error-report.h" #include "qapi/error.h" #include "channel.h" -#include "fd.h" #include "file.h" #include "migration.h" #include "io/channel-file.h" @@ -55,27 +54,15 @@ bool file_send_channel_create(gpointer opaque, Error **= errp) { QIOChannelFile *ioc; int flags =3D O_WRONLY; - bool ret =3D false; - int fd =3D fd_args_get_fd(); - - if (fd && fd !=3D -1) { - if (fd_is_socket(fd)) { - error_setg(errp, - "Multifd migration to a socket FD is not supported"= ); - goto out; - } - - ioc =3D qio_channel_file_new_dupfd(fd, errp); - } else { - ioc =3D qio_channel_file_new_path(outgoing_args.fname, flags, 0, e= rrp); - } + bool ret =3D true; =20 + ioc =3D qio_channel_file_new_path(outgoing_args.fname, flags, 0, errp); if (!ioc) { + ret =3D false; goto out; } =20 multifd_channel_connect(opaque, QIO_CHANNEL(ioc)); - ret =3D true; =20 out: /* diff --git a/migration/migration.c b/migration/migration.c index f60bd371e3..047b6b49cf 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -140,10 +140,6 @@ static bool transport_supports_multi_channels(Migratio= nAddress *addr) if (addr->transport =3D=3D MIGRATION_ADDRESS_TYPE_SOCKET) { SocketAddress *saddr =3D &addr->u.socket; =20 - if (saddr->type =3D=3D SOCKET_ADDRESS_TYPE_FD) { - return migrate_mapped_ram(); - } - return (saddr->type =3D=3D SOCKET_ADDRESS_TYPE_INET || saddr->type =3D=3D SOCKET_ADDRESS_TYPE_UNIX || saddr->type =3D=3D SOCKET_ADDRESS_TYPE_VSOCK); @@ -165,15 +161,6 @@ static bool transport_supports_seeking(MigrationAddres= s *addr) return true; } =20 - /* - * At this point QEMU has not yet fetched the fd passed in by the - * user, so we cannot know for sure whether it refers to a plain - * file or a socket. Let it through anyway and check at fd.c. - */ - if (addr->transport =3D=3D MIGRATION_ADDRESS_TYPE_SOCKET) { - return addr->u.socket.type =3D=3D SOCKET_ADDRESS_TYPE_FD; - } - return false; } =20 diff --git a/migration/multifd.c b/migration/multifd.c index 0179422f6d..d2f0238f70 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -18,7 +18,6 @@ #include "exec/ramblock.h" #include "qemu/error-report.h" #include "qapi/error.h" -#include "fd.h" #include "file.h" #include "migration.h" #include "migration-stats.h" @@ -794,7 +793,6 @@ static bool multifd_send_cleanup_channel(MultiFDSendPar= ams *p, Error **errp) static void multifd_send_cleanup_state(void) { file_cleanup_outgoing_migration(); - fd_cleanup_outgoing_migration(); socket_cleanup_outgoing_migration(); qemu_sem_destroy(&multifd_send_state->channels_created); qemu_sem_destroy(&multifd_send_state->channels_ready); diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 71895abb7f..1d2cee87ea 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -2536,13 +2536,6 @@ static void *migrate_precopy_fd_file_start(QTestStat= e *from, QTestState *to) return NULL; } =20 -static void *migrate_fd_file_mapped_ram_start(QTestState *from, QTestState= *to) -{ - migrate_mapped_ram_start(from, to); - - return migrate_precopy_fd_file_start(from, to); -} - static void test_migrate_precopy_fd_file(void) { MigrateCommon args =3D { @@ -2553,36 +2546,6 @@ static void test_migrate_precopy_fd_file(void) }; test_file_common(&args, true); } - -static void test_migrate_precopy_fd_file_mapped_ram(void) -{ - MigrateCommon args =3D { - .listen_uri =3D "defer", - .connect_uri =3D "fd:fd-mig", - .start_hook =3D migrate_fd_file_mapped_ram_start, - .finish_hook =3D test_migrate_fd_finish_hook - }; - test_file_common(&args, true); -} - -static void *migrate_multifd_fd_mapped_ram_start(QTestState *from, - QTestState *to) -{ - migrate_multifd_mapped_ram_start(from, to); - return migrate_precopy_fd_file_start(from, to); -} - -static void test_multifd_fd_mapped_ram(void) -{ - MigrateCommon args =3D { - .connect_uri =3D "fd:fd-mig", - .listen_uri =3D "defer", - .start_hook =3D migrate_multifd_fd_mapped_ram_start, - .finish_hook =3D test_migrate_fd_finish_hook - }; - - test_file_common(&args, true); -} #endif /* _WIN32 */ =20 static void do_test_validate_uuid(MigrateStart *args, bool should_fail) @@ -3687,10 +3650,6 @@ int main(int argc, char **argv) test_multifd_file_mapped_ram); migration_test_add("/migration/multifd/file/mapped-ram/live", test_multifd_file_mapped_ram_live); -#ifndef _WIN32 - migration_test_add("/migration/multifd/fd/mapped-ram", - test_multifd_fd_mapped_ram); -#endif =20 #ifdef CONFIG_GNUTLS migration_test_add("/migration/precopy/unix/tls/psk", @@ -3753,8 +3712,6 @@ int main(int argc, char **argv) test_migrate_precopy_fd_socket); migration_test_add("/migration/precopy/fd/file", test_migrate_precopy_fd_file); - migration_test_add("/migration/precopy/fd/file/mapped-ram", - test_migrate_precopy_fd_file_mapped_ram); #endif migration_test_add("/migration/validate_uuid", test_validate_uuid); migration_test_add("/migration/validate_uuid_error", --=20 2.44.0 From nobody Mon May 13 12:33:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1711124105; cv=none; d=zohomail.com; s=zohoarc; b=aHunXoMt+oDAY08q5i+it3oEgE0pv7prmEOz7CRbTMpakyWQJCySsEn5aItagZHGucphEWXMjawXlef6rQAnbXZuvJECzH0nE9LBNM1XQKWm8tWLbT2sBWW6T7Zc6SKjyEIBCSJ4p40xbkiXeMkIxHsGMsjEOYsXx93wAXha03g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711124105; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gfy5PVe/pn7+K0AvkkvST5u05icXsEXIGf7OvW4k9Lo=; b=FKKmCs6vmxFnUpbhAvGCRh+OF4WhsPfMhozLjJLZ2xbp3aB/qPEnrYiZflTV+yg1xY45/WQLi/A+KiqtszXihjV2Fe69CPUr0xWcGz7hz+u/XGNEeYumFOmbOminy4Y1hknWHLQifn9UlHph2mWtSiB9gwKuKG3deQEzm18cTRw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1711124105087713.8492824795595; Fri, 22 Mar 2024 09:15:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnhXO-0000c2-NL; Fri, 22 Mar 2024 12:14:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rnhXL-0000bW-AF for qemu-devel@nongnu.org; Fri, 22 Mar 2024 12:14:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rnhXI-0000l2-2l for qemu-devel@nongnu.org; Fri, 22 Mar 2024 12:14:31 -0400 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-518-MYvwUjkRN7OR-WUrAdAw7w-1; Fri, 22 Mar 2024 12:14:22 -0400 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-69672754479so962796d6.1 for ; Fri, 22 Mar 2024 09:14:22 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id 6-20020a05621420e600b006904c34d5basm1202708qvk.64.2024.03.22.09.14.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 09:14:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711124063; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gfy5PVe/pn7+K0AvkkvST5u05icXsEXIGf7OvW4k9Lo=; b=feLQFiy6ZG9VfeCTyW2iPLe6nkpNAncxb+EHaXEgvjNuaMpfnbK2EdtqMiXjMqHAxRBCdj gNDhmIMYDdW266n1f1cTmkBiN1XFrQJmObFeaONwu+coG/88GWYASBkwQRP82ZB+BJ1rrt zEiBy8tDcROoDDUiRJuZ5zPGMHLM+1E= X-MC-Unique: MYvwUjkRN7OR-WUrAdAw7w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711124061; x=1711728861; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gfy5PVe/pn7+K0AvkkvST5u05icXsEXIGf7OvW4k9Lo=; b=KmiA5IpiEN6c0WyO3THkqkTLtsi4W27p8PKvzDSyZ7mvM3AJUZH/z+3HTNrLY0QhGP /xW1NH8lx5JFNDeYsZNiVdpf2tV8cxVws+tEKeDN2QPVgw3O8fPO/Y/kWT+mr9Bqd3dE jIbi1czwzaH8n96wI47zbPM/p5BK/UoaEdvs9dIbNwFvQlihVGAh8ujaw8XCtI5J/GFb mQF5Pf5zA0u4X2Ql8XbkGn3wMRKDi3bcFgdlVwBh7SlhKNcVH+4mek2XJ5pO19/A93Fa pnbmbmvs6dYCT/1gcWnQkI3RO2b2YJuCi06lBaAL0WZvMeEnQYlWoYSsWBDCUFcZCv1b KRow== X-Gm-Message-State: AOJu0Yxlv8OweVtDWALuQVXo1hcXZPYR3Z6SdqhNEzMePJX+MMO3D70Z NWtBbhKHuHnLNKg6JEdAF4CK+cgj7hV/KUDhXZnBlDtncAM041OukfGVKAHFkfvjGwbYBvs3HhG hkBBlZouT5QZrMm+av/tMSQttt9IchSt0Za/dXkDaAupg9hcf5+e89ZftvAsu45/SenluSi2oJq 8GINuC4EeGpN0AC5dURzq9BLrgmisCOZRi6w== X-Received: by 2002:a05:6214:2b86:b0:696:732f:41ce with SMTP id kr6-20020a0562142b8600b00696732f41cemr1095490qvb.0.1711124061305; Fri, 22 Mar 2024 09:14:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7o24OBMh7+Cs7R5tAiwutJEevu5TT10pinaUevCszhMSiOxLLaeKISC1zoW3XaB33xNIosg== X-Received: by 2002:a05:6214:2b86:b0:696:732f:41ce with SMTP id kr6-20020a0562142b8600b00696732f41cemr1095462qvb.0.1711124060692; Fri, 22 Mar 2024 09:14:20 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org Cc: Fabiano Rosas , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , peterx@redhat.com, Nina Schoetterl-Glausch Subject: [PULL 2/3] migration/postcopy: Fix high frequency sync Date: Fri, 22 Mar 2024 12:14:16 -0400 Message-ID: <20240322161417.759586-3-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240322161417.759586-1-peterx@redhat.com> References: <20240322161417.759586-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.222, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1711124106376100008 Content-Type: text/plain; charset="utf-8" From: Peter Xu With current code base I can observe extremely high sync count during precopy, as long as one enables postcopy-ram=3Don before switchover to postcopy. To provide some context of when QEMU decides to do a full sync: it checks must_precopy (which implies "data must be sent during precopy phase"), and as long as it is lower than the threshold size we calculated (out of bandwidth and expected downtime) QEMU will kick off the slow/exact sync. However, when postcopy is enabled (even if still during precopy phase), RAM only reports all pages as can_postcopy, and report must_precopy=3D=3D0. Th= en "must_precopy <=3D threshold_size" mostly always triggers and enforces a sl= ow sync for every call to migration_iteration_run() when postcopy is enabled even if not used. That is insane. It turns out it was a regress bug introduced in the previous refactoring in 8.0 as reported by Nina [1]: (a) c8df4a7aef ("migration: Split save_live_pending() into state_pending_= *") Then a workaround patch is applied at the end of release (8.0-rc4) to fix i= t: (b) 28ef5339c3 ("migration: fix ram_state_pending_exact()") However that "workaround" was overlooked when during the cleanup in this 9.0 release in this commit.. (c) b0504edd40 ("migration: Drop unnecessary check in ram's pending_exact= ()") Then the issue was re-exposed as reported by Nina [1]. The problem with (b) is that it only fixed the case for RAM, rather than all the rest of iterators. Here a slow sync should only be required if all dirty data (precopy+postcopy) is less than the threshold_size that QEMU calculated. It is even debatable whether a sync is needed when switched to postcopy. Currently ram_state_pending_exact() will be mostly noop if switched to postcopy, and that logic seems to apply too for all the rest of iterators, as sync dirty bitmap during a postcopy doesn't make much sense. However let's leave such change for later, as we're in rc phase. So rather than reusing commit (b), this patch provides the complete fix for all iterators. When at it, cleanup a little bit on the lines around. [1] https://gitlab.com/qemu-project/qemu/-/issues/1565 Reported-by: Nina Schoetterl-Glausch Fixes: b0504edd40 ("migration: Drop unnecessary check in ram's pending_exac= t()") Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240320214453.584374-1-peterx@redhat.com Signed-off-by: Peter Xu --- migration/migration.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 047b6b49cf..9fe8fd2afd 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3199,17 +3199,16 @@ typedef enum { */ static MigIterateState migration_iteration_run(MigrationState *s) { - uint64_t must_precopy, can_postcopy; + uint64_t must_precopy, can_postcopy, pending_size; Error *local_err =3D NULL; bool in_postcopy =3D s->state =3D=3D MIGRATION_STATUS_POSTCOPY_ACTIVE; bool can_switchover =3D migration_can_switchover(s); =20 qemu_savevm_state_pending_estimate(&must_precopy, &can_postcopy); - uint64_t pending_size =3D must_precopy + can_postcopy; - + pending_size =3D must_precopy + can_postcopy; trace_migrate_pending_estimate(pending_size, must_precopy, can_postcop= y); =20 - if (must_precopy <=3D s->threshold_size) { + if (pending_size < s->threshold_size) { qemu_savevm_state_pending_exact(&must_precopy, &can_postcopy); pending_size =3D must_precopy + can_postcopy; trace_migrate_pending_exact(pending_size, must_precopy, can_postco= py); --=20 2.44.0 From nobody Mon May 13 12:33:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1711124184; cv=none; d=zohomail.com; s=zohoarc; b=cTfzmH6XnntpaoN/2vzujY1ky2O/oWqF0/zCCX9nW3G7Duw4/9KH6PZMalSzJxdWKPOS7E0hiaLecKOg0+MUkLo0SbpoDWW3bcHkUjhA3t5E7oLQhn1eys4HhaeL5iVRihpqG5drtTGUh9YK1GEJGhWXb2MYd3pw+E2DknBvMSY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711124184; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9o8qzy6L7mwSEPINx1G7qpKCDuh+yBwE7mJu/Ztnqvk=; b=WnBjXZve6Jq1bo6IUFQRXcrp3OKJ7OaXI429nNH3vNctdvvY/qMy2MVvvaUi+RjPcGYePmATIRH/Sltlj/deWgEkRP0AD53UMRZo5oQaV/Y7LJgR7N8quj1yPSxzGSk9HbuvjpZh4JYZ+d8AvY2LTXnRSoBTbzir7b3ImvPlO5Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1711124184268595.1150618804677; Fri, 22 Mar 2024 09:16:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnhXP-0000cL-QG; Fri, 22 Mar 2024 12:14:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rnhXL-0000bV-92 for qemu-devel@nongnu.org; Fri, 22 Mar 2024 12:14:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rnhXI-0000l8-4y for qemu-devel@nongnu.org; Fri, 22 Mar 2024 12:14:31 -0400 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-41-uiWowjy1OoWn1FpjQ5FSRA-1; Fri, 22 Mar 2024 12:14:23 -0400 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-69120b349c9so5357616d6.1 for ; Fri, 22 Mar 2024 09:14:23 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id 6-20020a05621420e600b006904c34d5basm1202708qvk.64.2024.03.22.09.14.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 09:14:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711124064; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9o8qzy6L7mwSEPINx1G7qpKCDuh+yBwE7mJu/Ztnqvk=; b=WeLXKko/accZgI42V/iziScogYh5P/PcSfEZqlN2oGhF/vIENbAK+eNdxcO5LdI9ikuTls GNnXghrpFX8Wwbpgqj9drFjLzE30S9aiauqkKCGDqEFpC4A/xrAm3ZieWWV5pxEoISkdRL 8fyQouZj20cRh0yudgtaidbllukSFh0= X-MC-Unique: uiWowjy1OoWn1FpjQ5FSRA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711124062; x=1711728862; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9o8qzy6L7mwSEPINx1G7qpKCDuh+yBwE7mJu/Ztnqvk=; b=mV6I3oFP2+ugjd2OLAgxRHE6I0OhTdyuWYF4iu3pGgyt+g8xlZxokl0vquEkzLs/mx UVNB8Vr2QqWx3xupjaAA1qntrLVYGEAft/ayg/KnbirjlwnLtmzcdNhtTq7YAlyFnzRp xwt59EUZSZcxq21YaNYr7ESrGuh+YcCYCtCLMFhe8hDmiAGQ2jnQ7qWySLHe9DSCIdzP 82Oj2vlaFWo2nazeE9MXip/xrOOhqOK8nJxyhaQLeXCOODISD5eBwwMgdGcQi0knYkLA Z843c913JRcPUi8o3YYTlDPE4rlsxt0N69tNzVOPnRkXhDbTmJj/jgYH9e8zequN7Nh0 mv0Q== X-Gm-Message-State: AOJu0YxMXypJKTFzUogWPlYZHULH4ZEtelwTLx9LgYFknSneeNAYdR3T HinTSAW4mPYj00SuFu+rR+3xsWS5dHo9hBVgdoq1XFprZuWIaxnmyZ9hr3kqrcffQ7Jd9tLecDb 9+UTbN7wmTMiqZH75wuxCsNyRvgADGEQvore7V+DX7q3YiV87uS2JOncGK/kYUzHU2B/HCdjrLj S5n5anLnmMUV0cC4LvnAmXD2ZXVOVHBQuVhw== X-Received: by 2002:a05:6214:5991:b0:690:cdd5:ea47 with SMTP id qp17-20020a056214599100b00690cdd5ea47mr2611173qvb.4.1711124062143; Fri, 22 Mar 2024 09:14:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAQsVQqHWuYmOH382S3+7bJqvTSCyBm0+br+Avs+Coz2F4enGf4SOn0x7zlc0x2UzEbvVqsw== X-Received: by 2002:a05:6214:5991:b0:690:cdd5:ea47 with SMTP id qp17-20020a056214599100b00690cdd5ea47mr2611143qvb.4.1711124061591; Fri, 22 Mar 2024 09:14:21 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org Cc: Fabiano Rosas , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , peterx@redhat.com Subject: [PULL 3/3] migration/multifd: Fix clearing of mapped-ram zero pages Date: Fri, 22 Mar 2024 12:14:17 -0400 Message-ID: <20240322161417.759586-4-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240322161417.759586-1-peterx@redhat.com> References: <20240322161417.759586-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.222, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1711124184549100001 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas When the zero page detection is done in the multifd threads, we need to iterate the second part of the pages->offset array and clear the file bitmap for each zero page. The piece of code we merged to do that is wrong. The reason this has passed all the tests is because the bitmap is initialized with zeroes already, so clearing the bits only really has an effect during live migration and when a data page goes from having data to no data. Fixes: 303e6f54f9 ("migration/multifd: Implement zero page transmission on = the multifd thread.") Signed-off-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240321201242.6009-1-farosas@suse.de Signed-off-by: Peter Xu --- migration/multifd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/migration/multifd.c b/migration/multifd.c index d2f0238f70..2802afe79d 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -111,7 +111,6 @@ void multifd_send_channel_created(void) static void multifd_set_file_bitmap(MultiFDSendParams *p) { MultiFDPages_t *pages =3D p->pages; - uint32_t zero_num =3D p->pages->num - p->pages->normal_num; =20 assert(pages->block); =20 @@ -119,7 +118,7 @@ static void multifd_set_file_bitmap(MultiFDSendParams *= p) ramblock_set_file_bmap_atomic(pages->block, pages->offset[i], true= ); } =20 - for (int i =3D p->pages->num; i < zero_num; i++) { + for (int i =3D p->pages->normal_num; i < p->pages->num; i++) { ramblock_set_file_bmap_atomic(pages->block, pages->offset[i], fals= e); } } --=20 2.44.0