From patchwork Fri Mar 22 16:14:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1915001 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=arvADdJz; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V1S8q1Lftz23r9 for ; Sat, 23 Mar 2024 03:15:06 +1100 (AEDT) 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 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= 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 X-MC-Unique: 30cA5LeINLiqDgpfjfoMQA-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-69672754479so962466d6.1 for ; Fri, 22 Mar 2024 09:14:21 -0700 (PDT) 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) 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) From: peterx@redhat.com To: qemu-devel@nongnu.org Cc: Fabiano Rosas , =?utf-8?q?Daniel_P_=2E_Berrang=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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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, Error **errp); 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 @@ */ #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" -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 = -1; - } -} - void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp) { QIOChannel *ioc; int fd = monitor_get_fd(monitor_cur(), fdname, errp); - int newfd; - if (fd == -1) { return; } @@ -62,18 +39,6 @@ void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error ** return; } - /* - * This is dup()ed just to avoid referencing an fd that might - * be already closed by the iochannel. - */ - newfd = dup(fd); - if (newfd == -1) { - error_setg_errno(errp, errno, "Could not dup FD %d", fd); - object_unref(ioc); - return; - } - outgoing_args.fd = 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, Error **errp) return; } - 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 = O_WRONLY; - bool ret = false; - int fd = fd_args_get_fd(); - - if (fd && fd != -1) { - if (fd_is_socket(fd)) { - error_setg(errp, - "Multifd migration to a socket FD is not supported"); - goto out; - } - - ioc = qio_channel_file_new_dupfd(fd, errp); - } else { - ioc = qio_channel_file_new_path(outgoing_args.fname, flags, 0, errp); - } + bool ret = true; + ioc = qio_channel_file_new_path(outgoing_args.fname, flags, 0, errp); if (!ioc) { + ret = false; goto out; } multifd_channel_connect(opaque, QIO_CHANNEL(ioc)); - ret = true; 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(MigrationAddress *addr) if (addr->transport == MIGRATION_ADDRESS_TYPE_SOCKET) { SocketAddress *saddr = &addr->u.socket; - if (saddr->type == SOCKET_ADDRESS_TYPE_FD) { - return migrate_mapped_ram(); - } - return (saddr->type == SOCKET_ADDRESS_TYPE_INET || saddr->type == SOCKET_ADDRESS_TYPE_UNIX || saddr->type == SOCKET_ADDRESS_TYPE_VSOCK); @@ -165,15 +161,6 @@ static bool transport_supports_seeking(MigrationAddress *addr) return true; } - /* - * 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 == MIGRATION_ADDRESS_TYPE_SOCKET) { - return addr->u.socket.type == SOCKET_ADDRESS_TYPE_FD; - } - return false; } 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(MultiFDSendParams *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(QTestState *from, QTestState *to) return NULL; } -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 = { @@ -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 = { - .listen_uri = "defer", - .connect_uri = "fd:fd-mig", - .start_hook = migrate_fd_file_mapped_ram_start, - .finish_hook = 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 = { - .connect_uri = "fd:fd-mig", - .listen_uri = "defer", - .start_hook = migrate_multifd_fd_mapped_ram_start, - .finish_hook = test_migrate_fd_finish_hook - }; - - test_file_common(&args, true); -} #endif /* _WIN32 */ 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 #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", From patchwork Fri Mar 22 16:14:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1914999 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=feLQFiy6; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V1S8q278Tz23ry for ; Sat, 23 Mar 2024 03:15:06 +1100 (AEDT) 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 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= 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 X-MC-Unique: MYvwUjkRN7OR-WUrAdAw7w-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-69672754479so962796d6.1 for ; Fri, 22 Mar 2024 09:14:22 -0700 (PDT) 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) 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) From: peterx@redhat.com To: qemu-devel@nongnu.org Cc: Fabiano Rosas , =?utf-8?q?Daniel_P_=2E_Berrang=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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Peter Xu With current code base I can observe extremely high sync count during precopy, as long as one enables postcopy-ram=on 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==0. Then "must_precopy <= threshold_size" mostly always triggers and enforces a slow 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 it: (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_exact()") 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 = NULL; bool in_postcopy = s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE; bool can_switchover = migration_can_switchover(s); qemu_savevm_state_pending_estimate(&must_precopy, &can_postcopy); - uint64_t pending_size = must_precopy + can_postcopy; - + pending_size = must_precopy + can_postcopy; trace_migrate_pending_estimate(pending_size, must_precopy, can_postcopy); - if (must_precopy <= s->threshold_size) { + if (pending_size < s->threshold_size) { qemu_savevm_state_pending_exact(&must_precopy, &can_postcopy); pending_size = must_precopy + can_postcopy; trace_migrate_pending_exact(pending_size, must_precopy, can_postcopy); From patchwork Fri Mar 22 16:14:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1915005 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=WeLXKko/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V1SBK0yM9z1yWp for ; Sat, 23 Mar 2024 03:16:25 +1100 (AEDT) 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 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= 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 X-MC-Unique: uiWowjy1OoWn1FpjQ5FSRA-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-69120b349c9so5357616d6.1 for ; Fri, 22 Mar 2024 09:14:23 -0700 (PDT) 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) 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) From: peterx@redhat.com To: qemu-devel@nongnu.org Cc: Fabiano Rosas , =?utf-8?q?Daniel_P_=2E_Berrang=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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 = p->pages; - uint32_t zero_num = p->pages->num - p->pages->normal_num; assert(pages->block); @@ -119,7 +118,7 @@ static void multifd_set_file_bitmap(MultiFDSendParams *p) ramblock_set_file_bmap_atomic(pages->block, pages->offset[i], true); } - for (int i = p->pages->num; i < zero_num; i++) { + for (int i = p->pages->normal_num; i < p->pages->num; i++) { ramblock_set_file_bmap_atomic(pages->block, pages->offset[i], false); } }