From nobody Sat May 18 13:36:43 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=1659009860; cv=none; d=zohomail.com; s=zohoarc; b=I4wbnL4SeHAApMUfQ8aTPy/yYF88VpPaF1gnD+BBXlBT2ck9kV0PH80bc5xrxo8HIcndjp0JYD1seoFbRIkQTHsZu1RtrqIp2oWWilkYWicuQ2YwEj+VWIVktmpzNKonDUvuRfe+bw+n+gXhnVdoWey/dPaI+2qW+kiNLFn8V1s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659009860; 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=EDNsgNORhf5MUfZCXD5Dgxbpg5HCOhY3hdxecTLw2cA=; b=DqN+yBH8uKXl/kQ4tnmS8pPrrIcqeGB5yiM1CtoVtJ2SI4sJMLwww3LxIzyE6MuoSuJGE8uMxB5XfPth3ti04GjadOTdpfsA/VKB6d1mi0c8yaZcnv8OAIcJJC/RvObpox0xtF7qCwPvwokxBVh+G3g0sAZ7he3rA/0Us78y4A8= 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 1659009860450601.7869574460492; Thu, 28 Jul 2022 05:04:20 -0700 (PDT) Received: from localhost ([::1]:50048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oH2FW-0004O9-W7 for importer@patchew.org; Thu, 28 Jul 2022 08:04:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40084) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH2Ba-0001Mi-4v for qemu-devel@nongnu.org; Thu, 28 Jul 2022 08:00:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51046) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH2BT-0001ig-Lj for qemu-devel@nongnu.org; Thu, 28 Jul 2022 08:00:11 -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-132-4RCJgOFFMG6ywvFr9K1pwg-1; Thu, 28 Jul 2022 08:00:03 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 092C7185A7A4; Thu, 28 Jul 2022 12:00:03 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5DB5D90A11; Thu, 28 Jul 2022 12:00:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659009606; 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=EDNsgNORhf5MUfZCXD5Dgxbpg5HCOhY3hdxecTLw2cA=; b=ZoJzAsk/ugeuaTepgpiq4ZsFV7U5JsxdEb+YANIi08DxJFVRbAeSgCgsmgiRjONXA9dKCm Y6S04Z7kEZyzgsQt1j/+Tp9JWOTOfY/BPpAdMaNjKF7UIGGAZC1s9gSToBEGNw2SVoH2nC lpGtDNxDby/BrjluKqGpmMF5AbPWtdw= X-MC-Unique: 4RCJgOFFMG6ywvFr9K1pwg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Juan Quintela , "Dr. David Alan Gilbert" , Eduardo Habkost , Yanan Wang Subject: [PATCH v2 1/6] multifd: Create property multifd-sync-after-each-section Date: Thu, 28 Jul 2022 13:59:52 +0200 Message-Id: <20220728115957.5554-2-quintela@redhat.com> In-Reply-To: <20220728115957.5554-1-quintela@redhat.com> References: <20220728115957.5554-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1659009861868100003 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 --- Rename each-iteration to after-each-section Signed-off-by: Juan Quintela --- migration/migration.h | 6 ++++++ hw/core/machine.c | 1 + migration/migration.c | 11 ++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/migration/migration.h b/migration/migration.h index cdad8aceaa..6abd2a51f5 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -373,6 +373,11 @@ struct MigrationState { * This save hostname when out-going migration starts */ char *hostname; + /* + * Synchronize channels after each section is sent. + * We used to do that on the past, but it is suboptimal. + */ + bool multifd_sync_after_each_section; }; =20 void migrate_set_state(int *state, int old_state, int new_state); @@ -415,6 +420,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 a673302cce..9645a25f8f 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -43,6 +43,7 @@ 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 e03f698a3c..ebca4f2d8a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2592,6 +2592,13 @@ 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 s->multifd_sync_after_each_section; +} + bool migrate_pause_before_switchover(void) { MigrationState *s; @@ -4384,7 +4391,9 @@ static Property migration_properties[] =3D { DEFINE_PROP_STRING("tls-creds", MigrationState, parameters.tls_creds), DEFINE_PROP_STRING("tls-hostname", MigrationState, parameters.tls_host= name), DEFINE_PROP_STRING("tls-authz", MigrationState, parameters.tls_authz), - + /* We will change to false when we introduce the new mechanism */ + DEFINE_PROP_BOOL("multifd-sync-after-each-section", MigrationState, + multifd_sync_after_each_section, true), /* Migration capabilities */ DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE), DEFINE_PROP_MIG_CAP("x-rdma-pin-all", MIGRATION_CAPABILITY_RDMA_PIN_AL= L), --=20 2.37.1 From nobody Sat May 18 13:36:43 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=1659010104; cv=none; d=zohomail.com; s=zohoarc; b=J39NS54QRzrWkTaMhlvdE4SFNf9w5GPf9xC/231zLbM/If7uV4esTSdvpYNR8HlBds5hAysdh2S169CrSa/Sb8lKaJXyjO5cjwuqExRHFC/a1NHoA3rDeGV6Tg4TMEFnKyqFTRLCzPCc6eC1EJHAwoWo7J1UxSybtjmGk888YNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659010104; 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=5qdRb6gqRIKnblEV7C9qQdk26wiQGLGm8w/a6dGQnj0=; b=ekv7aXCsoJm3+8E7Yy3vXQTHb4eN7FQLqbSbAw93unSypH01BCXmijMb5XBYZUee3lyici0h3/S5o5HhdNRsZRM9pMA0V7zh5KRB+pwCng1ivz1Vgt5HNKs79cu/o5bveNHe5d25UuFh5QICc7OKrXuaYiKf3ivEeYEFJlVclD0= 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 165901010395791.03546084298398; Thu, 28 Jul 2022 05:08:23 -0700 (PDT) Received: from localhost ([::1]:57866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oH2JT-0001KT-7B for importer@patchew.org; Thu, 28 Jul 2022 08:08:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH2Bc-0001Tc-CG for qemu-devel@nongnu.org; Thu, 28 Jul 2022 08:00:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58328) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH2BX-0001uU-4R for qemu-devel@nongnu.org; Thu, 28 Jul 2022 08:00:15 -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-442-7X370mTLPh2inPykRuCqvw-1; Thu, 28 Jul 2022 08:00:05 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 234BA380115C; Thu, 28 Jul 2022 12:00:05 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 549C018EB5; Thu, 28 Jul 2022 12:00:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659009609; 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=5qdRb6gqRIKnblEV7C9qQdk26wiQGLGm8w/a6dGQnj0=; b=N7er+QXfQFm3RDGMLJai79WJXrG6qKoEPlWUyhjuBiG8+RsDZpQq0zqHLcxUDGCXnlQqMM kqjFgX/hAfq142pDo4QzQCS0AUE9AOzx0qm9cV3q91HKE2dDsRH+xG667ZEJjm1EsuyWTi +64IrDG0hkHIMMlSn2kmwbcDPqsm2w0= X-MC-Unique: 7X370mTLPh2inPykRuCqvw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Juan Quintela , "Dr. David Alan Gilbert" , Eduardo Habkost , Yanan Wang Subject: [PATCH v2 2/6] multifd: Protect multifd_send_sync_main() calls Date: Thu, 28 Jul 2022 13:59:53 +0200 Message-Id: <20220728115957.5554-3-quintela@redhat.com> In-Reply-To: <20220728115957.5554-1-quintela@redhat.com> References: <20220728115957.5554-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=0.01 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" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1659010132582100001 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 --- 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 b94669ba5d..6b71ce74f6 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3338,9 +3338,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->f); - if (ret < 0) { - return ret; + if (migrate_multifd_sync_after_each_section()) { + ret =3D multifd_send_sync_main(rs->f); + if (ret < 0) { + return ret; + } } =20 qemu_put_be64(f, RAM_SAVE_FLAG_EOS); @@ -4084,7 +4086,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" @@ -4361,7 +4365,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.37.1 From nobody Sat May 18 13:36:43 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=1659009860; cv=none; d=zohomail.com; s=zohoarc; b=V/UOt08lgJTPxhJfpIXdIzhV4TS2wW7NTE6ZgCb4pFybVtGW7Z8trK7ikjtYpNtBQznDKfgKS9IWdj8mqXd81CB18LUyPix47ZJUiTY8bbFQJ50glKzT4Mz+UgA8Rhv4SN1JEqpEjcfqrMjJS82qw1/hMms26X1wYRwV5a2JmuE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659009860; 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=9eQXzjiIYrGn1Mps/yU0K3o9rMppIzKMyUPjXLAgpqQ=; b=X0lKouiRh1zfQqf7g2Fa3tiE7uwZO1AOlRh8Hy6h5H09f/kbnhntbW0DlfuaCa3JibcaSOHidRAjG0oG4WChzAkKXfaYe8rFzGE+knPKfOhumQ+js5mX6Hk4AumL0dzY75U1H35/Zo7FV0B+SKnF9h4rO0Tilp0mJzFe5I3KwFA= 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 165900986025769.17279943175936; Thu, 28 Jul 2022 05:04:20 -0700 (PDT) Received: from localhost ([::1]:50124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oH2FW-0004Ql-FJ for importer@patchew.org; Thu, 28 Jul 2022 08:04:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH2Ba-0001Od-Sn for qemu-devel@nongnu.org; Thu, 28 Jul 2022 08:00:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30040) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH2BX-0001vS-88 for qemu-devel@nongnu.org; Thu, 28 Jul 2022 08:00:13 -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-88-Hjzye1uRM5SYLVh21JOHrw-1; Thu, 28 Jul 2022 08:00:07 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E627F3C0CD53; Thu, 28 Jul 2022 12:00:06 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 729C790A04; Thu, 28 Jul 2022 12:00:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659009610; 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=9eQXzjiIYrGn1Mps/yU0K3o9rMppIzKMyUPjXLAgpqQ=; b=gHmiXRx43TjhiE5jSiFsYvBoPiNTwP5947dMV9qIRIHZtHoZ29RU4eVlChxA+BQ3u7gNMU ISuhpinIPBVd2U2yCVTRasrMdQJQ8Z5l9KHgDFr1CHGw6d4GT7vyjbcEf5Qj/vYz0Ou3aC dUqbbxxVNVs+xxPGjGy1CguLTt7ZxSg= X-MC-Unique: Hjzye1uRM5SYLVh21JOHrw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Juan Quintela , "Dr. David Alan Gilbert" , Eduardo Habkost , Yanan Wang Subject: [PATCH v2 3/6] migration: Simplify ram_find_and_save_block() Date: Thu, 28 Jul 2022 13:59:54 +0200 Message-Id: <20220728115957.5554-4-quintela@redhat.com> In-Reply-To: <20220728115957.5554-1-quintela@redhat.com> References: <20220728115957.5554-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1659009861848100002 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 --- migration/ram.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 6b71ce74f6..c2c939ee03 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2524,7 +2524,6 @@ static int ram_find_and_save_block(RAMState *rs) { PageSearchStatus pss; int pages =3D 0; - bool again, found; =20 /* No dirty page as there is zero RAM */ if (!ram_bytes_total()) { @@ -2540,27 +2539,25 @@ static int ram_find_and_save_block(RAMState *rs) } =20 do { - again =3D true; - found =3D get_queued_page(rs, &pss); - - if (!found) { + if (!get_queued_page(rs, &pss)) { /* * Recover previous precopy ramblock/offset if postcopy has * preempted precopy. Otherwise find the next dirty bit. */ if (postcopy_preempt_triggered(rs)) { postcopy_preempt_restore(rs, &pss, false); - found =3D true; } else { /* priority queue empty, so just search for something dirt= y */ - found =3D find_dirty_block(rs, &pss, &again); + bool again =3D true; + if (!find_dirty_block(rs, &pss, &again)) { + if (!again) { + break; + } + } } } - - if (found) { - pages =3D ram_save_host_page(rs, &pss); - } - } while (!pages && again); + pages =3D ram_save_host_page(rs, &pss); + } while (!pages); =20 rs->last_seen_block =3D pss.block; rs->last_page =3D pss.page; --=20 2.37.1 From nobody Sat May 18 13:36:43 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=1659010101; cv=none; d=zohomail.com; s=zohoarc; b=ZjYh4cFdEbhMUa8xWaZPQXzwt3ygPY8JEgdBfk6I7ndgixX4msI6YnFhDmacLG1WkwS/mcpvSMzEiL3Hwpf6oZOCvRhq55M+n/njZU9HpjMj/0/HPtZBsxrMMBTGYjehS6i2Ltvqn2b2rLTxqtMAD0Fu8UQvVTmobb63hOWzw+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659010101; 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=ZlPntIRJj9BXF9pQct0SK0auD/ClxUCDfmxA47cebgo=; b=FI8lxiwGz9ZSFZsCSVxkRLDSJu8VchRZpjMOxQ7uS6U6AAfvYrVA9Wj8hu3vqLq+SkTOVEPip9gZ4rRnVp++hr6MuuAMhz/grlsUYRr8Ja0U8yrPhq6mkjiWTJ2K0nifXkzYQa/GTakPlQ58aoLEZ7wJ/nOl26Gvd446q0ZwkqA= 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 1659010101794295.7333560563628; Thu, 28 Jul 2022 05:08:21 -0700 (PDT) Received: from localhost ([::1]:57620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oH2JQ-00019k-QN for importer@patchew.org; Thu, 28 Jul 2022 08:08:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH2Bf-0001bg-PN for qemu-devel@nongnu.org; Thu, 28 Jul 2022 08:00:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29103) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH2BZ-0001vo-3M for qemu-devel@nongnu.org; Thu, 28 Jul 2022 08:00:19 -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-551-jNkz-ik-PymEg-LUZcWOwg-1; Thu, 28 Jul 2022 08:00:09 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A34B4811E75; Thu, 28 Jul 2022 12:00:08 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 459EC18EB5; Thu, 28 Jul 2022 12:00:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659009612; 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=ZlPntIRJj9BXF9pQct0SK0auD/ClxUCDfmxA47cebgo=; b=hMEnW7OK506phxxb99M2TwYWVkJiPZx1huAoJW739fk3S+uBC/RKdJvIWhNR2kMKmXYWPA M85X15bnHLLRaL+0kAW1ouHNifFhaiaYIx3gq2ptvh3YY6/C7le981BemHGFthefnHV6iA 75WdM7ly0HO0mi3HRy85YGCZzVKKpKA= X-MC-Unique: jNkz-ik-PymEg-LUZcWOwg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Juan Quintela , "Dr. David Alan Gilbert" , Eduardo Habkost , Yanan Wang Subject: [PATCH v2 4/6] migration: Make find_dirty_block() return a single parameter Date: Thu, 28 Jul 2022 13:59:55 +0200 Message-Id: <20220728115957.5554-5-quintela@redhat.com> In-Reply-To: <20220728115957.5554-1-quintela@redhat.com> References: <20220728115957.5554-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1659010104571100001 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 | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index c2c939ee03..1507ba1991 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1532,17 +1532,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) { /* * This is not a postcopy requested page, mark it "not urgent", and use @@ -1558,8 +1564,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)) { @@ -1588,13 +1593,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 @@ -2538,7 +2540,7 @@ static int ram_find_and_save_block(RAMState *rs) pss.block =3D QLIST_FIRST_RCU(&ram_list.blocks); } =20 - do { + while (true){ if (!get_queued_page(rs, &pss)) { /* * Recover previous precopy ramblock/offset if postcopy has @@ -2548,16 +2550,21 @@ static int ram_find_and_save_block(RAMState *rs) postcopy_preempt_restore(rs, &pss, false); } else { /* priority queue empty, so just search for something dirt= y */ - 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); + if (pages) { + break; + } + } =20 rs->last_seen_block =3D pss.block; rs->last_page =3D pss.page; --=20 2.37.1 From nobody Sat May 18 13:36:43 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=1659010108; cv=none; d=zohomail.com; s=zohoarc; b=VxHV32QDR+jbPlJkiUkvSATPVRGWUm686/m7AYBWx5VcjFXhLrPq/cfH4u3lp9kuvdj9Y94ITXRCVanTxLRRZ0kmtzPP6hdy0LeR+QTC1q9jVSRzQlaMgAKsajyOrbYLK3Bwy1crBxiD+E5St2jqmzIo/fAQWwCaWoCwid8aoxg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659010108; 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=fuYKXod9meK5/3kuBVMs3EAPF/cb5AdSc/xEpwKg5J0=; b=RA9AdrkVK9S8IzWBtu/Bpkm9MHSW2X5gqBZRwiqCJEz+IgjK5HCmlb+07kT+G922zppD8jeTWYdAVD+gjRGGzt2qQArqx2zOLXIzrlzEfcA3/PbuAJxBHcGH/0ZBm86bChJMKtmIFkvKToQ2n6uzEuVhiVspntmyB345FAGXRzY= 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 1659010108765977.2012288958751; Thu, 28 Jul 2022 05:08:28 -0700 (PDT) Received: from localhost ([::1]:57848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oH2JX-0001JV-6o for importer@patchew.org; Thu, 28 Jul 2022 08:08:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH2Be-0001Yi-L6 for qemu-devel@nongnu.org; Thu, 28 Jul 2022 08:00:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:23138) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH2Bc-0001xl-R6 for qemu-devel@nongnu.org; Thu, 28 Jul 2022 08:00:18 -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-665-6E4Jy28mNCSdoVZ_IESdOw-1; Thu, 28 Jul 2022 08:00:11 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7DECF811E76; Thu, 28 Jul 2022 12:00:10 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1BF594561; Thu, 28 Jul 2022 12:00:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659009616; 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=fuYKXod9meK5/3kuBVMs3EAPF/cb5AdSc/xEpwKg5J0=; b=OlHOykj+Nwiv61g5N7cc6fKJ1fzw9WYFZhxohIHgD49h77eP8K1XRV1RTDVVq1Ac2T1Dz6 V+7tqkBx6lnEroZ+6S3dkD7bhOs/AMgz7oorKz7fK6/TzWXWkethYJTDFkNvaMg/WXABiO WGnZTTB2kRxjaqDfSnt/xPt8fwotxoU= X-MC-Unique: 6E4Jy28mNCSdoVZ_IESdOw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Juan Quintela , "Dr. David Alan Gilbert" , Eduardo Habkost , Yanan Wang Subject: [PATCH v2 5/6] multifd: Only sync once each full round of memory Date: Thu, 28 Jul 2022 13:59:56 +0200 Message-Id: <20220728115957.5554-6-quintela@redhat.com> In-Reply-To: <20220728115957.5554-1-quintela@redhat.com> References: <20220728115957.5554-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1659010110659100001 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 | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index ebca4f2d8a..7905145d7d 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -4393,7 +4393,7 @@ static Property migration_properties[] =3D { DEFINE_PROP_STRING("tls-authz", MigrationState, parameters.tls_authz), /* We will change to false when we introduce the new mechanism */ DEFINE_PROP_BOOL("multifd-sync-after-each-section", MigrationState, - multifd_sync_after_each_section, true), + multifd_sync_after_each_section, false), /* Migration capabilities */ DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE), DEFINE_PROP_MIG_CAP("x-rdma-pin-all", MIGRATION_CAPABILITY_RDMA_PIN_AL= L), diff --git a/migration/ram.c b/migration/ram.c index 1507ba1991..234603ee4f 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 @@ -1540,6 +1541,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 @@ -1572,6 +1574,14 @@ 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()) { + int ret =3D multifd_send_sync_main(rs->f); + if (ret < 0) { + return ret; + } + qemu_put_be64(rs->f, RAM_SAVE_FLAG_MULTIFD_SYNC); + qemu_fflush(rs->f); + } /* * If memory migration starts over, we will meet a dirtied page * which may still exists in compression threads's ring, so we @@ -2556,6 +2566,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; } } } @@ -3232,6 +3245,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 @@ -3419,6 +3436,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 @@ -4087,7 +4107,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()) { @@ -4367,6 +4389,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.37.1 From nobody Sat May 18 13:36:43 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=1659009866; cv=none; d=zohomail.com; s=zohoarc; b=N2Oih6LZ6xRaH6IZ4UPqiCnHSHThTs7el3u9kd3EQUaFOPLSnN5REgVtG3WGXiK5lVkjO+A6Jn0WonGjATAXovnNNO+VD0FHucWDP4xqraTbkWblVeDBKIrnccQTYaCXX5tG2Wcgn/+rtvp4kMvBuPXmWq4+qBJr+cIOL+F+nkc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659009866; 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=UXb1utX6d/dWs0SXVyXsGugRaFi8XCeLP+OgLPZtVpQ=; b=KYv0ZkKf9HS59vjZUdSedEm114aQwG1yydYk0Gkjp246qf08nQXVIINMwxakUCjfiXjXbDfgwpoMoVKA9J9CXj49hC9KJgjPMbm/5IGbI6IHpztvw7Rj417Axu2aQCdEUO6jlXGo/zaFgzsFxK5YyQAP7hfc+mdaA/06eVP6ZUU= 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 1659009866624613.3604928009547; Thu, 28 Jul 2022 05:04:26 -0700 (PDT) Received: from localhost ([::1]:50468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oH2Fd-0004hj-Jn for importer@patchew.org; Thu, 28 Jul 2022 08:04:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH2Bd-0001Wq-V4 for qemu-devel@nongnu.org; Thu, 28 Jul 2022 08:00:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:41940) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH2Bc-0001xI-Bl for qemu-devel@nongnu.org; Thu, 28 Jul 2022 08:00:17 -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-241-66PMlBp4N4aTkDvXi2qKmw-1; Thu, 28 Jul 2022 08:00:12 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 187EC8032F1; Thu, 28 Jul 2022 12:00:12 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE33F18EB5; Thu, 28 Jul 2022 12:00:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659009615; 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=UXb1utX6d/dWs0SXVyXsGugRaFi8XCeLP+OgLPZtVpQ=; b=FvwzO7hvmmn7Xl/wbOsUYhoeNCyr2DtC5FqQjdcW/HQ9eSmN7fKLD6jsREGuZuC83j3znl vNX2vJ6GLoL3iepDTkhV1RitipM8CW2UOouDNsC39pW6IhEA1yFcrvi/rcG/Zn7w/fne9p Wq5FSaS/kEsonDrbzVA9ws2p9FUFQV8= X-MC-Unique: 66PMlBp4N4aTkDvXi2qKmw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Juan Quintela , "Dr. David Alan Gilbert" , Eduardo Habkost , Yanan Wang Subject: [PATCH v2 6/6] ram: Document migration ram flags Date: Thu, 28 Jul 2022 13:59:57 +0200 Message-Id: <20220728115957.5554-7-quintela@redhat.com> In-Reply-To: <20220728115957.5554-1-quintela@redhat.com> References: <20220728115957.5554-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1659009867889100001 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 234603ee4f..83a48e3889 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.37.1