From nobody Mon Feb 9 10:57:45 2026 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=1675863078; cv=none; d=zohomail.com; s=zohoarc; b=RA2KPs6+ccwIYfAyQlXWsYC4qO7zD4tJjyFBSJq/d3NnHaUfL4jwq574ELhwH2SHh60a1xo3M15d3rWygN+S8SXe71FXMX5oIaj3YzZYSysDObh+NAoXEbMSYKeYiRkwlttL9qfadRHlewKYzC0cp0pLx3j5L1u6W7jIAJCGE3A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675863078; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XlP/ohMSeGs4TE1kY9MxU7wRPvGA7FiOgpHSooDUSKg=; b=QThwwsCxpc+thgC9g+z5VB7T9RxpMjGlGPKpLbhH/1tF19tLhejX04lD7HmgqrmY64Sv8VDAITDwhgZHTwjCl/ILJzrP/jTeznHonKIVdHQLSrnrFyjBH472XJOLDphjZREWd4zeN7HTWPOkXPa1DXKXoeO/cn5wfzI2K7wkBGI= 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 1675863078086209.47159614679788; Wed, 8 Feb 2023 05:31:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pPkX0-0000W3-5N; Wed, 08 Feb 2023 08:30:40 -0500 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 1pPkWm-0000TM-9h for qemu-devel@nongnu.org; Wed, 08 Feb 2023 08:30:24 -0500 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 1pPkWk-00075I-DO for qemu-devel@nongnu.org; Wed, 08 Feb 2023 08:30:23 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-451-7UGvwDHwN2CeEeeSc5LPeg-1; Wed, 08 Feb 2023 08:30:17 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 96E36811E9C; Wed, 8 Feb 2023 13:30:16 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 74D7BC15BA0; Wed, 8 Feb 2023 13:30:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675863021; 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=XlP/ohMSeGs4TE1kY9MxU7wRPvGA7FiOgpHSooDUSKg=; b=hZjfuhXm6UJ43kS1d2E6r0g9VadpXLKuYe85AGOeHvxrMcYgrUZAZ+ed3K41E273suGJL2 vyFXpaDYQvvyQsODREm/poRKwt3qulW+IcCioS/ZmIvzwI/4M/FBPKotS6guIhPpxLIeAk zgAc0zNDKY4iRVqDYSGO9j2xufp2HzU= X-MC-Unique: 7UGvwDHwN2CeEeeSc5LPeg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: "Dr. David Alan Gilbert" , Markus Armbruster , Juan Quintela , Marcel Apfelbaum , Yanan Wang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Eric Blake Subject: [PATCH v3 1/6] multifd: Create property multifd-sync-after-each-section Date: Wed, 8 Feb 2023 14:30:05 +0100 Message-Id: <20230208133010.17323-2-quintela@redhat.com> In-Reply-To: <20230208133010.17323-1-quintela@redhat.com> References: <20230208133010.17323-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-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: 1675863078759100003 Content-Type: text/plain; charset="utf-8" We used to synchronize all channels at the end of each RAM section sent. That is not needed, so preparing to only synchronize once every full round in latests patches. Notice that we initialize the property as true. We will change the default when we introduce the new mechanism. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Juan Quintela --- Rename each-iteration to after-each-section Signed-off-by: Juan Quintela --- qapi/migration.json | 9 ++++++++- migration/migration.h | 1 + hw/core/machine.c | 1 + migration/migration.c | 15 +++++++++++++-- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/qapi/migration.json b/qapi/migration.json index c84fa10e86..d712b082c8 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -478,6 +478,12 @@ # should not affect the correctness of postcopy migrati= on. # (since 7.1) # +# @multifd-sync-after-each-section: Synchronize channels after each +# section is sent. We used to do +# that on the past, but it is +# suboptimal. +# (since 7.1) +# # Features: # @unstable: Members @x-colo and @x-ignore-shared are experimental. # @@ -492,7 +498,8 @@ 'dirty-bitmaps', 'postcopy-blocktime', 'late-block-activate', { 'name': 'x-ignore-shared', 'features': [ 'unstable' ] }, 'validate-uuid', 'background-snapshot', - 'zero-copy-send', 'postcopy-preempt'] } + 'zero-copy-send', 'postcopy-preempt', + 'multifd-sync-after-each-section'] } =20 ## # @MigrationCapabilityStatus: diff --git a/migration/migration.h b/migration/migration.h index 66511ce532..4dde1faa68 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -412,6 +412,7 @@ int migrate_multifd_channels(void); MultiFDCompression migrate_multifd_compression(void); int migrate_multifd_zlib_level(void); int migrate_multifd_zstd_level(void); +bool migrate_multifd_sync_after_each_section(void); =20 #ifdef CONFIG_LINUX bool migrate_use_zero_copy_send(void); diff --git a/hw/core/machine.c b/hw/core/machine.c index b5cd42cd8c..224469cee4 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -55,6 +55,7 @@ const size_t hw_compat_7_1_len =3D G_N_ELEMENTS(hw_compat= _7_1); GlobalProperty hw_compat_7_0[] =3D { { "arm-gicv3-common", "force-8-bit-prio", "on" }, { "nvme-ns", "eui64-default", "on"}, + { "migration", "multifd-sync-after-each-section", "on"}, }; const size_t hw_compat_7_0_len =3D G_N_ELEMENTS(hw_compat_7_0); =20 diff --git a/migration/migration.c b/migration/migration.c index 7a14aa98d8..cf02295765 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -167,7 +167,8 @@ INITIALIZE_MIGRATE_CAPS_SET(check_caps_background_snaps= hot, MIGRATION_CAPABILITY_XBZRLE, MIGRATION_CAPABILITY_X_COLO, MIGRATION_CAPABILITY_VALIDATE_UUID, - MIGRATION_CAPABILITY_ZERO_COPY_SEND); + MIGRATION_CAPABILITY_ZERO_COPY_SEND, + MIGRATION_CAPABILITY_MULTIFD_SYNC_AFTER_EACH_SECTION); =20 /* When we add fault tolerance, we could have several migrations at once. For now we don't need to add @@ -2675,6 +2676,15 @@ bool migrate_use_multifd(void) return s->enabled_capabilities[MIGRATION_CAPABILITY_MULTIFD]; } =20 +bool migrate_multifd_sync_after_each_section(void) +{ + MigrationState *s =3D migrate_get_current(); + + return true; + // We will change this when code gets in. + return s->enabled_capabilities[MIGRATION_CAPABILITY_MULTIFD_SYNC_AFTER= _EACH_SECTION]; +} + bool migrate_pause_before_switchover(void) { MigrationState *s; @@ -4501,7 +4511,8 @@ static Property migration_properties[] =3D { DEFINE_PROP_MIG_CAP("x-zero-copy-send", MIGRATION_CAPABILITY_ZERO_COPY_SEND), #endif - + DEFINE_PROP_MIG_CAP("multifd-sync-after-each-section", + MIGRATION_CAPABILITY_MULTIFD_SYNC_AFTER_EACH_SECTI= ON), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 2.39.1 From nobody Mon Feb 9 10:57:45 2026 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=1675863121; cv=none; d=zohomail.com; s=zohoarc; b=lc+lAaxnyUVrQY5UaeHq66hhU5/9tK1/4a0IXj4vILwXLfKzfcNY7B73g1yS30tAo2Gkwbu4CgvSORrf9+MiQGugU5hbOYrg8oqt03gRH4zXmbc97q+NNC8VnNpMWOaIhgeQykdGOouKgR/nee2ZtxYAXc/E9aesSpZWCbgPyik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675863121; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KrkF6Evvslyb699wK/97JmnRE7geMlSfLtpM4sgvx48=; b=hyl4L0uz1C6tKdQTI8VOH3SkmwpY/XDTJb7rBsUHq/64vSJr3lURPTO3LgRVamr41va4FG98Bj46Ye/hx/X4P/n+U4J3co8BBc6zJ1yjGVW48s2o32fDFJoqBNJ6Vyxe7K7yZ5S46wjXvlQpyWHlGZ8Hi9Qj/TSb5lSULFAHqPE= 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 1675863121648506.2179862597543; Wed, 8 Feb 2023 05:32:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pPkX6-0000eL-6n; Wed, 08 Feb 2023 08:30:44 -0500 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 1pPkWm-0000U8-Pg for qemu-devel@nongnu.org; Wed, 08 Feb 2023 08:30:24 -0500 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 1pPkWl-00076P-7W for qemu-devel@nongnu.org; Wed, 08 Feb 2023 08:30:24 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-650-Sias0M2JPwCHtreOEMBeYA-1; Wed, 08 Feb 2023 08:30:19 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0CF3188904E; Wed, 8 Feb 2023 13:30:19 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C901C15BA0; Wed, 8 Feb 2023 13:30:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675863022; 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=KrkF6Evvslyb699wK/97JmnRE7geMlSfLtpM4sgvx48=; b=Hh1cryHidKXndFKKysIelfs2ayfK9pd9KIJJLa76hVlQqWDEbjRuecDYwYUsoWN5GVIxD0 9K9Cqn556LMxCCRdkDAYw0HT6x+wV3yWO2wpUqbYBh5s/DmNhjCR1HYDiqb7GilKjYUUgi xl1DGiPArVpy+PrHKWNspGW+mC6rE7M= X-MC-Unique: Sias0M2JPwCHtreOEMBeYA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: "Dr. David Alan Gilbert" , Markus Armbruster , Juan Quintela , Marcel Apfelbaum , Yanan Wang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Eric Blake Subject: [PATCH v3 2/6] multifd: Protect multifd_send_sync_main() calls Date: Wed, 8 Feb 2023 14:30:06 +0100 Message-Id: <20230208133010.17323-3-quintela@redhat.com> In-Reply-To: <20230208133010.17323-1-quintela@redhat.com> References: <20230208133010.17323-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-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: 1675863122890100003 Content-Type: text/plain; charset="utf-8" We only need to do that on the ram_save_iterate() call on sending and on destination when we get a RAM_SAVE_FLAG_EOS. In setup() and complete() we need to synch in both new and old cases, so don't add a check there. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Juan Quintela --- Remove the wrappers that we take out on patch 5. --- migration/ram.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index b966e148c2..0f0fd5c36a 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3354,9 +3354,12 @@ static int ram_save_iterate(QEMUFile *f, void *opaqu= e) out: if (ret >=3D 0 && migration_is_setup_or_active(migrate_get_current()->state)) { - ret =3D multifd_send_sync_main(rs->pss[RAM_CHANNEL_PRECOPY].pss_ch= annel); - if (ret < 0) { - return ret; + if (migrate_multifd_sync_after_each_section()) { + ret =3D multifd_send_sync_main( + rs->pss[RAM_CHANNEL_PRECOPY].pss_channel); + if (ret < 0) { + return ret; + } } =20 qemu_put_be64(f, RAM_SAVE_FLAG_EOS); @@ -4116,7 +4119,9 @@ int ram_load_postcopy(QEMUFile *f, int channel) =20 case RAM_SAVE_FLAG_EOS: /* normal exit */ - multifd_recv_sync_main(); + if (migrate_multifd_sync_after_each_section()) { + multifd_recv_sync_main(); + } break; default: error_report("Unknown combination of migration flags: 0x%x" @@ -4387,7 +4392,9 @@ static int ram_load_precopy(QEMUFile *f) break; case RAM_SAVE_FLAG_EOS: /* normal exit */ - multifd_recv_sync_main(); + if (migrate_multifd_sync_after_each_section()) { + multifd_recv_sync_main(); + } break; default: if (flags & RAM_SAVE_FLAG_HOOK) { --=20 2.39.1 From nobody Mon Feb 9 10:57:45 2026 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=1675863124; cv=none; d=zohomail.com; s=zohoarc; b=m0NllJVHayItpO7bcIDLkUrHYL7wpHUMBpSO8bVjWd72vaK7YkANFc8DnbPePh/CXWY1ryRwTn2c8p6Jwx64XRmrdcD/KZQmvlRpt4u1lNFsIZpG68YP+vCKrIRCjcCOkxnMtQHxaK4VStJ0zghoz4n5ClEoJnmuiGjpvk1RNjg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675863124; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aBOPUfcJWVwmgQ09J+Sr8M4g+/Ln6cFlGFlcEe57tcs=; b=AdtCOvhpcH4NwTOhLelSCAAdaEr71UGaMwK1jnM22tGotmx9z4lB3Gmr6J0IkcS640uw2x83DtdyeOAd+xx37MxouA6X2wOqYw+IpSxDfkwWIJaBHA11gOFKE/JZ5aj4qcfvuqlV2eFECnH9uoufdz6zCTncY401t9wZd8LHarA= 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 1675863124315333.66027489365274; Wed, 8 Feb 2023 05:32:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pPkX6-0000eH-5y; Wed, 08 Feb 2023 08:30:44 -0500 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 1pPkWq-0000Wz-GE for qemu-devel@nongnu.org; Wed, 08 Feb 2023 08:30:36 -0500 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 1pPkWo-0007Ai-1E for qemu-devel@nongnu.org; Wed, 08 Feb 2023 08:30:27 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-28-UiC0DHn9Pg2gTQLiVAfQdw-1; Wed, 08 Feb 2023 08:30:21 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7923388904E; Wed, 8 Feb 2023 13:30:21 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 78B3DC15BA0; Wed, 8 Feb 2023 13:30:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675863025; 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=aBOPUfcJWVwmgQ09J+Sr8M4g+/Ln6cFlGFlcEe57tcs=; b=dnQrDIFZiDWVGzpCAQ5zHbqkcmJvWbv9bYHS9HD048eDwkUgdQy17+vtwiECWTQVagz0+T DltbtFr+04bzowrJQz+XtBI4v7QQCAlsz6av6SJ+a5hoXWeb3uFhshVPn5JyE8PxNN+uri oyNIkd//U8pTFeWN6sHlkpeVoVxscXY= X-MC-Unique: UiC0DHn9Pg2gTQLiVAfQdw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: "Dr. David Alan Gilbert" , Markus Armbruster , Juan Quintela , Marcel Apfelbaum , Yanan Wang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Eric Blake Subject: [PATCH v3 3/6] migration: Simplify ram_find_and_save_block() Date: Wed, 8 Feb 2023 14:30:07 +0100 Message-Id: <20230208133010.17323-4-quintela@redhat.com> In-Reply-To: <20230208133010.17323-1-quintela@redhat.com> References: <20230208133010.17323-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-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: 1675863124967100001 Content-Type: text/plain; charset="utf-8" We will need later that find_dirty_block() return errors, so simplify the loop. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Juan Quintela --- migration/ram.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 0f0fd5c36a..5c406f2c1d 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2542,7 +2542,6 @@ static int ram_find_and_save_block(RAMState *rs) { PageSearchStatus *pss =3D &rs->pss[RAM_CHANNEL_PRECOPY]; int pages =3D 0; - bool again, found; =20 /* No dirty page as there is zero RAM */ if (!ram_bytes_total()) { @@ -2564,18 +2563,17 @@ static int ram_find_and_save_block(RAMState *rs) pss_init(pss, rs->last_seen_block, rs->last_page); =20 do { - again =3D true; - found =3D get_queued_page(rs, pss); - - if (!found) { + if (!get_queued_page(rs, pss)) { /* priority queue empty, so just search for something dirty */ - found =3D find_dirty_block(rs, pss, &again); - } - - if (found) { + bool again =3D true; + if (!find_dirty_block(rs, pss, &again)) { + if (!again) { + break; + } + } pages =3D ram_save_host_page(rs, pss); } - } while (!pages && again); + } while (!pages); =20 rs->last_seen_block =3D pss->block; rs->last_page =3D pss->page; --=20 2.39.1 From nobody Mon Feb 9 10:57:45 2026 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=1675863117; cv=none; d=zohomail.com; s=zohoarc; b=P5YhLZHJpPBnrQNL7Px3K9QGz1HQNlhxykdjc9kRQQNWKavQO2rKA+wgbW1tvG6XyKCarMOD1NqYTwpMTZ51jHLvv98KE4hGqMJz7q471pO0xyR1oDM8J/FDd0Ka0yfulsfpZplFH0cuorBJItjyrXKzc51c3gvbJ7PxqL8ui2w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675863117; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Mpjm3IOLHer8tTbqLY5zE094uFjhgILkHfh5FdAnZVk=; b=LV/TOIxFG48eEJrCZ4eNqxcM7bEPpK10ikNy5pNCs+GTTCHwUde0YDMzl4IpAqb1BhzSQWLHXVBzKVIH0sr6JJW4KLCyZXrCbQOLWX/ZZQr4QDieEGQmwl+OMrXzeHk2NjDTCn5G8vYfTs0J/Stj3HJnwqt22WlX7rzxCECjRv4= 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 1675863117431959.2728244669031; Wed, 8 Feb 2023 05:31:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pPkX8-0000gn-EL; Wed, 08 Feb 2023 08:30:46 -0500 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 1pPkWs-0000YV-K3 for qemu-devel@nongnu.org; Wed, 08 Feb 2023 08:30:36 -0500 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 1pPkWq-0007DH-BT for qemu-devel@nongnu.org; Wed, 08 Feb 2023 08:30:29 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-417-1n9Z85pvMKiv7H8-Awqc3g-1; Wed, 08 Feb 2023 08:30:24 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D581118E5280; Wed, 8 Feb 2023 13:30:23 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFC01C15BAD; Wed, 8 Feb 2023 13:30:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675863027; 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=Mpjm3IOLHer8tTbqLY5zE094uFjhgILkHfh5FdAnZVk=; b=GBWMZaSH4LKIkzLtXoY4cEl2NPvbsfk18Ii4GgQsJ4TlpAv0YMLU3zTMDWjMHfMStMEHp6 HQd01IqUP8Bgu66gSHuSI0BEw3Jf+x03LTJ1itgRutpwS05gGph98k4BXBBNk/VTg6tury u15dn33F2SSP15dwlWdnKBIS/vfXgMY= X-MC-Unique: 1n9Z85pvMKiv7H8-Awqc3g-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: "Dr. David Alan Gilbert" , Markus Armbruster , Juan Quintela , Marcel Apfelbaum , Yanan Wang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Eric Blake Subject: [PATCH v3 4/6] migration: Make find_dirty_block() return a single parameter Date: Wed, 8 Feb 2023 14:30:08 +0100 Message-Id: <20230208133010.17323-5-quintela@redhat.com> In-Reply-To: <20230208133010.17323-1-quintela@redhat.com> References: <20230208133010.17323-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-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: 1675863118886100003 Content-Type: text/plain; charset="utf-8" We used to return two bools, just return a single int with the following meaning: old return / again / new return false false PAGE_ALL_CLEAN false true PAGE_TRY_AGAIN true true PAGE_DIRTY_FOUND /* We don't care about again at all = */ Signed-off-by: Juan Quintela --- migration/ram.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 5c406f2c1d..e05503f825 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1546,17 +1546,23 @@ retry: return pages; } =20 +#define PAGE_ALL_CLEAN 0 +#define PAGE_TRY_AGAIN 1 +#define PAGE_DIRTY_FOUND 2 /** * find_dirty_block: find the next dirty page and update any state * associated with the search process. * - * Returns true if a page is found + * Returns: + * PAGE_ALL_CLEAN: no dirty page found, give up + * PAGE_TRY_AGAIN: no dirty page found, retry for next block + * PAGE_DIRTY_FOUND: dirty page found * * @rs: current RAM state * @pss: data about the state of the current dirty page scan * @again: set to false if the search has scanned the whole of RAM */ -static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, bool *ag= ain) +static int find_dirty_block(RAMState *rs, PageSearchStatus *pss) { /* Update pss->page for the next dirty bit in ramblock */ pss_find_next_dirty(pss); @@ -1567,8 +1573,7 @@ static bool find_dirty_block(RAMState *rs, PageSearch= Status *pss, bool *again) * We've been once around the RAM and haven't found anything. * Give up. */ - *again =3D false; - return false; + return PAGE_ALL_CLEAN; } if (!offset_in_ramblock(pss->block, ((ram_addr_t)pss->page) << TARGET_PAGE_BITS)) { @@ -1597,13 +1602,10 @@ static bool find_dirty_block(RAMState *rs, PageSear= chStatus *pss, bool *again) } } /* Didn't find anything this time, but try again on the new block = */ - *again =3D true; - return false; + return PAGE_TRY_AGAIN; } else { - /* Can go around again, but... */ - *again =3D true; - /* We've found something so probably don't need to */ - return true; + /* We've found something */ + return PAGE_DIRTY_FOUND; } } =20 @@ -2562,19 +2564,23 @@ static int ram_find_and_save_block(RAMState *rs) =20 pss_init(pss, rs->last_seen_block, rs->last_page); =20 - do { + while (true) { if (!get_queued_page(rs, pss)) { /* priority queue empty, so just search for something dirty */ - bool again =3D true; - if (!find_dirty_block(rs, pss, &again)) { - if (!again) { + int res =3D find_dirty_block(rs, pss); + if (res !=3D PAGE_DIRTY_FOUND) { + if (res =3D=3D PAGE_ALL_CLEAN) { break; + } else if (res =3D=3D PAGE_TRY_AGAIN) { + continue; } } - pages =3D ram_save_host_page(rs, pss); } - } while (!pages); - + pages =3D ram_save_host_page(rs, pss); + if (pages) { + break; + } + } rs->last_seen_block =3D pss->block; rs->last_page =3D pss->page; =20 --=20 2.39.1 From nobody Mon Feb 9 10:57:45 2026 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=1675863084; cv=none; d=zohomail.com; s=zohoarc; b=SIvdq4Io+DxBUMoNyCVT1yQ4XpBepQePIwQtp/taDGmQ7I+spK0fuVMFKx4ARQbWfjMJNO+32iewaTIcgxjdQ1rFEEamqOnBkrUGK9Mk6GHuvM1LHHZ8BgvN04rSFjIQ2sZD5oY8ZHvsNcQuJRaiIbluGHZ3ZhQjCWfdjVxM1hc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675863084; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=m/9pYm8MfxHu9zrfNbeJYEzl/R1JQaYzxF7tVs+YzhQ=; b=DzhUGgHqDtsPmN+Ds+jPMBEpaxNEaqMgxIq93An83hbdK61HQVWsDaUYdMumFpyWxEHP80WczSXsN/Jo9plfOZ1T6Cv80UlRYzE36s6xK72KZHkvzEDCUylK/3zx5+/WP7KZdqcteJa4ouDnIUMGznNjEKlUyTr3UfxAGzNzcr4= 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 1675863084539479.6482191122194; Wed, 8 Feb 2023 05:31:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pPkX9-0000mM-ML; Wed, 08 Feb 2023 08:30:47 -0500 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 1pPkWs-0000YW-Ke for qemu-devel@nongnu.org; Wed, 08 Feb 2023 08:30:36 -0500 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 1pPkWq-0007DI-80 for qemu-devel@nongnu.org; Wed, 08 Feb 2023 08:30:29 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-458-98HmpsyUOCKCbqi52viDSg-1; Wed, 08 Feb 2023 08:30:26 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F156C38173C5; Wed, 8 Feb 2023 13:30:25 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 420AEC15BA0; Wed, 8 Feb 2023 13:30:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675863027; 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=m/9pYm8MfxHu9zrfNbeJYEzl/R1JQaYzxF7tVs+YzhQ=; b=Unkd+nk523pq9VCdp07BBTOY2pXw+593vNeN1HAJR7jtXlVYtwxBtsihINR2Ou0PJ8uGa5 g2u2IL9UfuOcpgPUhb8C42atnmbvTsWteNdnX0MWNuDntQXacJ9mF25vVZEYwNx50LHoaZ YOTHUcsAEtzfBJLBs8/K2r/T4z+8zdU= X-MC-Unique: 98HmpsyUOCKCbqi52viDSg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: "Dr. David Alan Gilbert" , Markus Armbruster , Juan Quintela , Marcel Apfelbaum , Yanan Wang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Eric Blake Subject: [PATCH v3 5/6] multifd: Only sync once each full round of memory Date: Wed, 8 Feb 2023 14:30:09 +0100 Message-Id: <20230208133010.17323-6-quintela@redhat.com> In-Reply-To: <20230208133010.17323-1-quintela@redhat.com> References: <20230208133010.17323-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-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: 1675863086762100003 Content-Type: text/plain; charset="utf-8" We need to add a new flag to mean to sync at that point. Notice that we still synchronize at the end of setup and at the end of complete stages. Signed-off-by: Juan Quintela --- Add missing qemu_fflush(), now it passes all tests always. --- migration/migration.c | 2 -- migration/ram.c | 28 +++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index cf02295765..cf4dfb0072 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2680,8 +2680,6 @@ bool migrate_multifd_sync_after_each_section(void) { MigrationState *s =3D migrate_get_current(); =20 - return true; - // We will change this when code gets in. return s->enabled_capabilities[MIGRATION_CAPABILITY_MULTIFD_SYNC_AFTER= _EACH_SECTION]; } =20 diff --git a/migration/ram.c b/migration/ram.c index e05503f825..7952d5f01c 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -82,6 +82,7 @@ #define RAM_SAVE_FLAG_XBZRLE 0x40 /* 0x80 is reserved in migration.h start with 0x100 next */ #define RAM_SAVE_FLAG_COMPRESS_PAGE 0x100 +#define RAM_SAVE_FLAG_MULTIFD_SYNC 0x200 =20 XBZRLECacheStats xbzrle_counters; =20 @@ -1554,6 +1555,7 @@ retry: * associated with the search process. * * Returns: + * <0: An error happened * PAGE_ALL_CLEAN: no dirty page found, give up * PAGE_TRY_AGAIN: no dirty page found, retry for next block * PAGE_DIRTY_FOUND: dirty page found @@ -1581,6 +1583,15 @@ static int find_dirty_block(RAMState *rs, PageSearch= Status *pss) pss->page =3D 0; pss->block =3D QLIST_NEXT_RCU(pss->block, next); if (!pss->block) { + if (!migrate_multifd_sync_after_each_section()) { + QEMUFile *f =3D rs->pss[RAM_CHANNEL_PRECOPY].pss_channel; + int ret =3D multifd_send_sync_main(f); + if (ret < 0) { + return ret; + } + qemu_put_be64(f, RAM_SAVE_FLAG_MULTIFD_SYNC); + qemu_fflush(f); + } /* * If memory migration starts over, we will meet a dirtied page * which may still exists in compression threads's ring, so we @@ -2573,6 +2584,9 @@ static int ram_find_and_save_block(RAMState *rs) break; } else if (res =3D=3D PAGE_TRY_AGAIN) { continue; + } else if (res < 0) { + pages =3D res; + break; } } } @@ -3250,6 +3264,10 @@ static int ram_save_setup(QEMUFile *f, void *opaque) return ret; } =20 + if (!migrate_multifd_sync_after_each_section()) { + qemu_put_be64(f, RAM_SAVE_FLAG_MULTIFD_SYNC); + } + qemu_put_be64(f, RAM_SAVE_FLAG_EOS); qemu_fflush(f); =20 @@ -3436,6 +3454,9 @@ static int ram_save_complete(QEMUFile *f, void *opaqu= e) return ret; } =20 + if (!migrate_multifd_sync_after_each_section()) { + qemu_put_be64(f, RAM_SAVE_FLAG_MULTIFD_SYNC); + } qemu_put_be64(f, RAM_SAVE_FLAG_EOS); qemu_fflush(f); =20 @@ -4120,7 +4141,9 @@ int ram_load_postcopy(QEMUFile *f, int channel) } decompress_data_with_multi_threads(f, page_buffer, len); break; - + case RAM_SAVE_FLAG_MULTIFD_SYNC: + multifd_recv_sync_main(); + break; case RAM_SAVE_FLAG_EOS: /* normal exit */ if (migrate_multifd_sync_after_each_section()) { @@ -4394,6 +4417,9 @@ static int ram_load_precopy(QEMUFile *f) break; } break; + case RAM_SAVE_FLAG_MULTIFD_SYNC: + multifd_recv_sync_main(); + break; case RAM_SAVE_FLAG_EOS: /* normal exit */ if (migrate_multifd_sync_after_each_section()) { --=20 2.39.1 From nobody Mon Feb 9 10:57:45 2026 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=1675863093; cv=none; d=zohomail.com; s=zohoarc; b=gNEgLVkcmIwQrKMwV5hnQs/tvGls+nVNPE3WYDpv7JvzluIMENnrudeiv9ft4V0cAWi6EuApr2mvbnlHksdH6JgTw8bgZzBNWTFfozIM96BtFyKBiL6UZb0NVuH0thUSdc2+aodbGEUlWkaYTaGYNi0gnr3jPOL/24/CttyWv/g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675863093; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fVP5OCL1JriUJOVFBPGrdNwJArBCNe35xENl0MQMYnI=; b=UXnEU8oGOtUv318DgQJygfBwuhREXmJac5z2jm9XF3ChWx5Hpf/kKlopIcRIqxNs9i0lP1nshOLgdsrSEktNgNVVKRFYI0NZ3PALDGXV4JU4l73ZUpxS5JfXikHoxAPGwBr9QEkcYJFteKT/DT9ALRakApitZKpyk2FqsMXbK+g= 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 1675863093925799.3794683227552; Wed, 8 Feb 2023 05:31:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pPkXB-0000p6-16; Wed, 08 Feb 2023 08:30:49 -0500 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 1pPkWv-0000Ys-TZ for qemu-devel@nongnu.org; Wed, 08 Feb 2023 08:30:36 -0500 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 1pPkWu-0007HD-11 for qemu-devel@nongnu.org; Wed, 08 Feb 2023 08:30:33 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-92-ZOv_bdYKMRKUQ2hzaCBy1A-1; Wed, 08 Feb 2023 08:30:28 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1C75A803503; Wed, 8 Feb 2023 13:30:28 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 49F73C15BA0; Wed, 8 Feb 2023 13:30:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675863031; 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=fVP5OCL1JriUJOVFBPGrdNwJArBCNe35xENl0MQMYnI=; b=H9VoQbfDGXfm18ACESyZhoQY/Ixz5xHLNBa5nMCm6XGiPd5QOH+l273anC50Hs2T779onK oVMXc1exf5TKZhcKUpNw4kxDlYZoCYoUH32m4cqQjCk2o+nYV7IHxl35rkW4Zfw1iNP0dC NCPCS73GpQlTkAyXbi6jzllhfn/XdO0= X-MC-Unique: ZOv_bdYKMRKUQ2hzaCBy1A-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: "Dr. David Alan Gilbert" , Markus Armbruster , Juan Quintela , Marcel Apfelbaum , Yanan Wang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Eric Blake Subject: [PATCH v3 6/6] ram: Document migration ram flags Date: Wed, 8 Feb 2023 14:30:10 +0100 Message-Id: <20230208133010.17323-7-quintela@redhat.com> In-Reply-To: <20230208133010.17323-1-quintela@redhat.com> References: <20230208133010.17323-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-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: 1675863094758100003 Content-Type: text/plain; charset="utf-8" 0x80 is RAM_SAVE_FLAG_HOOK, it is in qemu-file now. Bigger usable flag is 0x200, noticing that. We can reuse RAM_SAVE_FLAG_FULL. Signed-off-by: Juan Quintela --- migration/ram.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 7952d5f01c..d95e26c03c 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -73,16 +73,19 @@ * RAM_SSAVE_FLAG_COMPRESS_PAGE just rename it. */ =20 -#define RAM_SAVE_FLAG_FULL 0x01 /* Obsolete, not used anymore */ +/* RAM_SAVE_FLAG_FULL has been obsoleted since at least 2009, we can + * reuse it */ +#define RAM_SAVE_FLAG_FULL 0x01 #define RAM_SAVE_FLAG_ZERO 0x02 #define RAM_SAVE_FLAG_MEM_SIZE 0x04 #define RAM_SAVE_FLAG_PAGE 0x08 #define RAM_SAVE_FLAG_EOS 0x10 #define RAM_SAVE_FLAG_CONTINUE 0x20 #define RAM_SAVE_FLAG_XBZRLE 0x40 -/* 0x80 is reserved in migration.h start with 0x100 next */ +/* 0x80 is reserved in qemu-file.h for RAM_SAVE_FLAG_HOOK */ #define RAM_SAVE_FLAG_COMPRESS_PAGE 0x100 #define RAM_SAVE_FLAG_MULTIFD_SYNC 0x200 +/* We can't use any flag that is bigger that 0x200 */ =20 XBZRLECacheStats xbzrle_counters; =20 --=20 2.39.1