From nobody Fri May 17 02:41:44 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=1681208888; cv=none; d=zohomail.com; s=zohoarc; b=XigSXu9fjgPOHuEKNeplGOKZII9RtykZXthU1PIt+LHnFRbNPobND7Bdr29bZesvbFS7i/2WdErGHNNofY7mY29OiEqYHWuC8Cejq34RlKZqqZV2eXPaXR6/c2HisvMZOsvmeRS3a96YpUiPYNYj3vTt59KGS2dxafwOQMRfxMA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681208888; 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=M4u7A5nkBh1LB4S+cRSFvPOmiBIud4ywqNddiDIhciM=; b=eMvp3mu4J45rz6TLO5YF0t2xMFOl7rAYtHiVqB3aG/BEMtWlh9//qZy34YRvSXI0pciV128l+BhYhE3YDpXg8DFq7hHzEbqRRWNKPcs3lBXrB+2Bc7b7zCcvcuEDxhq3IEILzoIL6qy2WV2LPacIsQcN3hkf5ReCpO4DU5+vSpM= 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 1681208888348300.8127881811456; Tue, 11 Apr 2023 03:28:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pmBD6-0001rA-Dh; Tue, 11 Apr 2023 06:26:48 -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 1pmBCw-0001n3-CW for qemu-devel@nongnu.org; Tue, 11 Apr 2023 06:26:38 -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 1pmBCt-000775-9A for qemu-devel@nongnu.org; Tue, 11 Apr 2023 06:26:36 -0400 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-556-FtAZ6DTeO7e6orjIpjsf9w-1; Tue, 11 Apr 2023 06:26:24 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6CAF03801FE8; Tue, 11 Apr 2023 10:26:24 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id E02752027041; Tue, 11 Apr 2023 10:26:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681208793; 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=M4u7A5nkBh1LB4S+cRSFvPOmiBIud4ywqNddiDIhciM=; b=e28LnM6YjWdt/9hMxyxAdCJ2dJyY5uH+gMJYG6Gc0ARfHC5c9XcjJF3bXGWGCp4/iJv/Nn CBqwzjFZWgy995cVFJZz2LTtv4AkUpduudHAVgRaRCV1s0AUeQvD3x4pwA9JjK/8wz0Fc6 aqBr0UclGk48qqGjy8sbY72QzIvKHM0= X-MC-Unique: FtAZ6DTeO7e6orjIpjsf9w-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , Eduardo Habkost , Juan Quintela , Yanan Wang , "Dr . David Alan Gilbert" Subject: [PATCH v7 1/3] multifd: Create property multifd-flush-after-each-section Date: Tue, 11 Apr 2023 12:26:17 +0200 Message-Id: <20230411102619.8291-2-quintela@redhat.com> In-Reply-To: <20230411102619.8291-1-quintela@redhat.com> References: <20230411102619.8291-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1681208890068100003 Content-Type: text/plain; charset="utf-8" We used to flush all channels at the end of each RAM section sent. That is not needed, so preparing to only flush after a full iteration through all the RAM. Default value of the property is false. But we return "true" in migrate_multifd_flush_after_each_section() until we implement the code in following patches. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Juan Quintela --- Rename each-iteration to after-each-section Rename multifd-sync-after-each-section to multifd-flush-after-each-section --- migration/migration.h | 13 +++++++++++++ hw/core/machine.c | 1 + migration/migration.c | 13 +++++++++++++ 3 files changed, 27 insertions(+) diff --git a/migration/migration.h b/migration/migration.h index 2da2f8a164..d0d89411e2 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -365,6 +365,18 @@ struct MigrationState { */ bool decompress_error_check; =20 + /* + * flush every channel after each section sent. + * + * This assures that we can't mix pages from one iteration through + * ram pages with pages for the following iteration. We really + * only need to do this flush after we have go through all the + * dirty pages. For historical reasons, we do that after each + * section. This is suboptimal (we flush too many times). + * Default value is false. Setting this property has no effect + * until the patch that removes this comment. (since 8.1) + */ + bool multifd_flush_after_each_section; /* * This decides the size of guest memory chunk that will be used * to track dirty bitmap clearing. The size of memory chunk will @@ -424,6 +436,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_flush_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 45e3d24fdc..3bd92a25b5 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -56,6 +56,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-flush-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 ae2025d9d8..ca773d00fc 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2701,6 +2701,17 @@ bool migrate_use_multifd(void) return s->enabled_capabilities[MIGRATION_CAPABILITY_MULTIFD]; } =20 +bool migrate_multifd_flush_after_each_section(void) +{ + MigrationState *s =3D migrate_get_current(); + + /* + * Until the patch that remove this comment, we always return that + * the property is enabled. + */ + return true || s->multifd_flush_after_each_section; +} + bool migrate_pause_before_switchover(void) { MigrationState *s; @@ -4441,6 +4452,8 @@ static Property migration_properties[] =3D { send_section_footer, true), DEFINE_PROP_BOOL("decompress-error-check", MigrationState, decompress_error_check, true), + DEFINE_PROP_BOOL("multifd-flush-after-each-section", MigrationState, + multifd_flush_after_each_section, true), DEFINE_PROP_UINT8("x-clear-bitmap-shift", MigrationState, clear_bitmap_shift, CLEAR_BITMAP_SHIFT_DEFAULT), =20 --=20 2.39.2 From nobody Fri May 17 02:41:44 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=1681208872; cv=none; d=zohomail.com; s=zohoarc; b=oB5eeO5nJpfkdlJ++PkD54qt9v5BiOAN5dimSwHpkTD3egnEkfxPaRXumvvxVlprbT2ZK6k2ID36w//FlVApzOtVFEHy6djBVs5XTKF+fLmBNqHdx7buDSAcWe1FEWv9yiPJ6PheM+yh2npHO87rhRWKVGTldymmUQwmO0Dp8AM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681208872; 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=DEXZluKZgScDpHRYFlwzuO5jgIvkm7M/3BFMkSrt4oc=; b=IS3zMwqENkik8AirLvGisiEhIi+M0DOFtKRfmKhI5JBOPYjsUfyAuJfn7TS7R5/E1/gzrqlXPYDaXUd/+Rbjal6+QMDUVUDb3ex4hd5PNgGgrQ3Q9qHRcYCd258EaJlgOxBQFZmudn3G+w+1NfGiNCPvzZeQwGPNI2Fr5KsSKuo= 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 1681208872530811.1037840346906; Tue, 11 Apr 2023 03:27:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pmBD5-0001qY-Rh; Tue, 11 Apr 2023 06:26:47 -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 1pmBCz-0001nh-Ed for qemu-devel@nongnu.org; Tue, 11 Apr 2023 06:26:41 -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 1pmBCw-00077z-1o for qemu-devel@nongnu.org; Tue, 11 Apr 2023 06:26:39 -0400 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-589-FB2b0plHMf-ozC4l_6ranA-1; Tue, 11 Apr 2023 06:26:26 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3CAA1185A791; Tue, 11 Apr 2023 10:26:26 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id B731B2027040; Tue, 11 Apr 2023 10:26:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681208797; 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=DEXZluKZgScDpHRYFlwzuO5jgIvkm7M/3BFMkSrt4oc=; b=SxE2eSPjQoWURdYB8t/91Jmn60FTXwg5Gn8ALSwoLx71JrqHTknWJCR5XJ96r0s8N15S8c 3IXIj0Sbih0oaBQ9lZFwBODJcxa0/P1iiU+GXYFfA76Kmt5QfW1f7d8fGCWvIO7OfKZeYz Esed7VHIQ0BxMJLGk1o2pv9BF4Q3FA0= X-MC-Unique: FB2b0plHMf-ozC4l_6ranA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , Eduardo Habkost , Juan Quintela , Yanan Wang , "Dr . David Alan Gilbert" Subject: [PATCH v7 2/3] multifd: Protect multifd_send_sync_main() calls Date: Tue, 11 Apr 2023 12:26:18 +0200 Message-Id: <20230411102619.8291-3-quintela@redhat.com> In-Reply-To: <20230411102619.8291-1-quintela@redhat.com> References: <20230411102619.8291-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1681208874351100001 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 | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 96e8a19a58..f019b77808 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3408,9 +3408,11 @@ 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_flush_after_each_section()) { + ret =3D multifd_send_sync_main(rs->pss[RAM_CHANNEL_PRECOPY].ps= s_channel); + if (ret < 0) { + return ret; + } } =20 qemu_put_be64(f, RAM_SAVE_FLAG_EOS); @@ -4166,7 +4168,9 @@ int ram_load_postcopy(QEMUFile *f, int channel) =20 case RAM_SAVE_FLAG_EOS: /* normal exit */ - multifd_recv_sync_main(); + if (migrate_multifd_flush_after_each_section()) { + multifd_recv_sync_main(); + } break; default: error_report("Unknown combination of migration flags: 0x%x" @@ -4437,7 +4441,9 @@ static int ram_load_precopy(QEMUFile *f) break; case RAM_SAVE_FLAG_EOS: /* normal exit */ - multifd_recv_sync_main(); + if (migrate_multifd_flush_after_each_section()) { + multifd_recv_sync_main(); + } break; default: if (flags & RAM_SAVE_FLAG_HOOK) { --=20 2.39.2 From nobody Fri May 17 02:41:44 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=1681208875; cv=none; d=zohomail.com; s=zohoarc; b=g5uf6JXo38+9ihAVWGmrdXF4QljpC7spsiD8OiZZmv41AIQp5NS4vLQOxb1g9Dzg+b08NUp0CPQZg3vQqnQMA48bXsiF56eNfEXnw7K1GDz//BPAEWAk3bIn2Aimgl0aF4OfpT1gGv2ShsjC8SpzRLWqhGxZggtokY4Hj3EFWrY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681208875; 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=2lZEKB9mtIl51uBU9jDgamP/4q9I/dcwaJYy/tGPQSY=; b=L2eT4mxhOoKs4xjI9okT+mZS4RdokX1HNjgWNunIzzUa4JMyPPo3lvVE2bST/0bwttJGFTcG3fpBdquWNcJ00od+GikHkNjxxO1gwACaMGlpG1TSwTvSRwh3n0a6Pj4cAy7YrYiSV/Yb/FeZxLYw/kIwUBSd11G+KPaTHgY30r4= 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 1681208875665672.0609123421585; Tue, 11 Apr 2023 03:27:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pmBD1-0001pV-Lo; Tue, 11 Apr 2023 06:26:43 -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 1pmBCw-0001n4-9N for qemu-devel@nongnu.org; Tue, 11 Apr 2023 06:26:39 -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 1pmBCt-00076u-3g for qemu-devel@nongnu.org; Tue, 11 Apr 2023 06:26:37 -0400 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-185-tTY8xB-zNp-pYsAo57OpKw-1; Tue, 11 Apr 2023 06:26:28 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 27DAF85A588; Tue, 11 Apr 2023 10:26:28 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 94E2C202701E; Tue, 11 Apr 2023 10:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681208791; 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=2lZEKB9mtIl51uBU9jDgamP/4q9I/dcwaJYy/tGPQSY=; b=h/A4viEHb96wyHUuV7W4t+RrOzVRP9HKjDqunqB67LmkFFl9t209qIrxgzi5M3hVzZGN1A 6LM2xKMVNCP+4IlxzkvNk3e0RDkTCErlD7zlpiCmeoTGjhsDSNbpAuJUk9/Ve5FbUOxxXt EYGhz+MxVOb4s2rtFIVTj09h1aZ2dSE= X-MC-Unique: tTY8xB-zNp-pYsAo57OpKw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , Eduardo Habkost , Juan Quintela , Yanan Wang Subject: [PATCH v7 3/3] multifd: Only flush once each full round of memory Date: Tue, 11 Apr 2023 12:26:19 +0200 Message-Id: <20230411102619.8291-4-quintela@redhat.com> In-Reply-To: <20230411102619.8291-1-quintela@redhat.com> References: <20230411102619.8291-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1681208876041100005 Content-Type: text/plain; charset="utf-8" We need to add a new flag to mean to flush at that point. Notice that we still flush 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.h | 3 +-- migration/migration.c | 6 +----- migration/ram.c | 28 +++++++++++++++++++++++++++- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/migration/migration.h b/migration/migration.h index d0d89411e2..816814a24e 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -373,8 +373,7 @@ struct MigrationState { * only need to do this flush after we have go through all the * dirty pages. For historical reasons, we do that after each * section. This is suboptimal (we flush too many times). - * Default value is false. Setting this property has no effect - * until the patch that removes this comment. (since 8.1) + * Default value is false. (since 8.1) */ bool multifd_flush_after_each_section; /* diff --git a/migration/migration.c b/migration/migration.c index ca773d00fc..353359b0d2 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2705,11 +2705,7 @@ bool migrate_multifd_flush_after_each_section(void) { MigrationState *s =3D migrate_get_current(); =20 - /* - * Until the patch that remove this comment, we always return that - * the property is enabled. - */ - return true || s->multifd_flush_after_each_section; + return s->multifd_flush_after_each_section; } =20 bool migrate_pause_before_switchover(void) diff --git a/migration/ram.c b/migration/ram.c index f019b77808..977ab25351 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -85,6 +85,7 @@ #define RAM_SAVE_FLAG_XBZRLE 0x40 /* 0x80 is reserved in qemu-file.h for RAM_SAVE_FLAG_HOOK */ #define RAM_SAVE_FLAG_COMPRESS_PAGE 0x100 +#define RAM_SAVE_FLAG_MULTIFD_FLUSH 0x200 /* We can't use any flag that is bigger than 0x200 */ =20 int (*xbzrle_encode_buffer_func)(uint8_t *, uint8_t *, int, @@ -1595,6 +1596,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 @@ -1622,6 +1624,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_flush_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_FLUSH); + 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 @@ -2614,6 +2625,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; } } } @@ -3300,6 +3314,10 @@ static int ram_save_setup(QEMUFile *f, void *opaque) return ret; } =20 + if (!migrate_multifd_flush_after_each_section()) { + qemu_put_be64(f, RAM_SAVE_FLAG_MULTIFD_FLUSH); + } + qemu_put_be64(f, RAM_SAVE_FLAG_EOS); qemu_fflush(f); =20 @@ -3485,6 +3503,9 @@ static int ram_save_complete(QEMUFile *f, void *opaqu= e) return ret; } =20 + if (!migrate_multifd_flush_after_each_section()) { + qemu_put_be64(f, RAM_SAVE_FLAG_MULTIFD_FLUSH); + } qemu_put_be64(f, RAM_SAVE_FLAG_EOS); qemu_fflush(f); =20 @@ -4165,7 +4186,9 @@ int ram_load_postcopy(QEMUFile *f, int channel) } decompress_data_with_multi_threads(f, page_buffer, len); break; - + case RAM_SAVE_FLAG_MULTIFD_FLUSH: + multifd_recv_sync_main(); + break; case RAM_SAVE_FLAG_EOS: /* normal exit */ if (migrate_multifd_flush_after_each_section()) { @@ -4439,6 +4462,9 @@ static int ram_load_precopy(QEMUFile *f) break; } break; + case RAM_SAVE_FLAG_MULTIFD_FLUSH: + multifd_recv_sync_main(); + break; case RAM_SAVE_FLAG_EOS: /* normal exit */ if (migrate_multifd_flush_after_each_section()) { --=20 2.39.2