From nobody Wed May 15 07:48:54 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=1675065912; cv=none; d=zohomail.com; s=zohoarc; b=Jx9b9xj/1twhM3w39MRAD7+nRCk7p+yyW87QGibeXfEyQka4MzVz5r/Cb279uyPDdegrzwtYZSpGeyxVYIqvGbPTzHaZ46g+AOHiy8L3XC6KczYuo4I7uMg2we5tCII7X8dMzQM4WpzRzJMQCyXq6ZFhCVciOilqGHEr8slkN/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675065912; 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=4tyAthjyAJfKR2wxZiLS098ns/1BTHiWpLuviegbRVQ=; b=hKqckBFPIdAkkq9kE3Y71fSlAt/y9k4C3Bg2ByrGDfQy0dl4rlQ352teIdZXpL0y5PZdblGhb4KIlWl20wcL3k/zMvOn90K8+EqxzrDvrDqeMxyVu9gcT2qdUiIaj6sPKqx+JIT10fIFtAHDSaSe+6khEBuTgCziAO6uFyO77mI= 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 1675065912260973.9078123327628; Mon, 30 Jan 2023 00:05:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMP8c-0001zT-Tp; Mon, 30 Jan 2023 03:03:38 -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 1pMP8V-0001v0-T7 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 03:03:35 -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 1pMP8S-0000zd-T5 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 03:03:31 -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-244-gYtDPhBUN9SHgDG6LCXfmQ-1; Mon, 30 Jan 2023 03:03:16 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C33EA381458C; Mon, 30 Jan 2023 08:03:15 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0299492B01; Mon, 30 Jan 2023 08:03:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675065808; 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=4tyAthjyAJfKR2wxZiLS098ns/1BTHiWpLuviegbRVQ=; b=IwXtxiNXunALCe6SVl3BofNcL7hhpIkQm8J1k2LtxJqwaJ4HJhqIkb/xAgPl5BUv6V48AI QVmpQBACeC1fTW8/hsr5O2oZTpip4TxI1R2WW0cgDKiE5gWLbHi1OWDwctVR5Vz/ukG/ep ANeDHWVmTbb6R/toHGoFsa9o2p4lGno= X-MC-Unique: gYtDPhBUN9SHgDG6LCXfmQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Eric Blake , John Snow , Richard Henderson , Fam Zheng , Christian Borntraeger , Thomas Huth , Alex Williamson , "Dr. David Alan Gilbert" , Stefan Hajnoczi , qemu-s390x@nongnu.org, Halil Pasic , Eric Farman , qemu-block@nongnu.org, Vladimir Sementsov-Ogievskiy , David Hildenbrand , Juan Quintela , Ilya Leoshkevich , Peter Xu , qemu-stable@nongnu.org Subject: [PULL 1/5] migration: Fix migration crash when target psize larger than host Date: Mon, 30 Jan 2023 09:03:03 +0100 Message-Id: <20230130080307.1792-2-quintela@redhat.com> In-Reply-To: <20230130080307.1792-1-quintela@redhat.com> References: <20230130080307.1792-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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=unavailable 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: 1675065912720100005 Content-Type: text/plain; charset="utf-8" From: Peter Xu Commit d9e474ea56 overlooked the case where the target psize is even larger than the host psize. One example is Alpha has 8K page size and migration will start to crash the source QEMU when running Alpha migration on x86. Fix it by detecting that case and set host start/end just to cover the single page to be migrated. This will slightly optimize the common case where host psize equals to guest psize so we don't even need to do the roundups, but that's trivial. Cc: qemu-stable@nongnu.org Reported-by: Thomas Huth Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1456 Fixes: d9e474ea56 ("migration: Teach PSS about host page") Signed-off-by: Peter Xu Reviewed-by: Thomas Huth Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/ram.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 334309f1c6..68a45338e3 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2319,8 +2319,25 @@ static void pss_host_page_prepare(PageSearchStatus *= pss) size_t guest_pfns =3D qemu_ram_pagesize(pss->block) >> TARGET_PAGE_BIT= S; =20 pss->host_page_sending =3D true; - pss->host_page_start =3D ROUND_DOWN(pss->page, guest_pfns); - pss->host_page_end =3D ROUND_UP(pss->page + 1, guest_pfns); + if (guest_pfns <=3D 1) { + /* + * This covers both when guest psize =3D=3D host psize, or when gu= est + * has larger psize than the host (guest_pfns=3D=3D0). + * + * For the latter, we always send one whole guest page per + * iteration of the host page (example: an Alpha VM on x86 host + * will have guest psize 8K while host psize 4K). + */ + pss->host_page_start =3D pss->page; + pss->host_page_end =3D pss->page + 1; + } else { + /* + * The host page spans over multiple guest pages, we send them + * within the same host page iteration. + */ + pss->host_page_start =3D ROUND_DOWN(pss->page, guest_pfns); + pss->host_page_end =3D ROUND_UP(pss->page + 1, guest_pfns); + } } =20 /* --=20 2.39.1 From nobody Wed May 15 07:48:54 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=1675065862; cv=none; d=zohomail.com; s=zohoarc; b=JCuqLyt7mVZU2zMycQSQUo+298Y2j/ivVo9AmwUKHzyvl1p4yN/mOLucDBsY3HK21+26OvYnp85NWMeapTX/urdYXyRvnbz3NFC+crvRhmcGuHRfZjBXBZ165SwLO2i9sxmFrEIg8+T2rtUg+eNj25iwo+l8yB9hyJgBaLfOmW8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675065862; 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=D82YH7IV7mm4QcL5So3Ps3ec5BwP8+Covqtg5oVgVr4=; b=dJsJBxGcWjuxF6+qf3n2eYy2bFz+s1328NRCQxMcqjuq3zIbehr9+WHqh1UkmMpeRtu8zJHaB7G5nVqFNlDAEem9EP13P3Ql1irlg0efzmi+4fYZ3n7YNNI+v4b7NLwFclnGGN8szT6CWBxaflSflMwLVQv6igHjZa9rB8CTXAs= 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 1675065862611626.7349793214282; Mon, 30 Jan 2023 00:04:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMP8b-0001wg-CD; Mon, 30 Jan 2023 03:03:37 -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 1pMP8R-0001sS-Gg for qemu-devel@nongnu.org; Mon, 30 Jan 2023 03:03:29 -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 1pMP8P-0000ye-MN for qemu-devel@nongnu.org; Mon, 30 Jan 2023 03:03:27 -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-277-jY1AD7aQPm-gPHyMruTjjA-1; Mon, 30 Jan 2023 03:03:19 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E78693C0DDBA; Mon, 30 Jan 2023 08:03:18 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 214A2492B01; Mon, 30 Jan 2023 08:03:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675065805; 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=D82YH7IV7mm4QcL5So3Ps3ec5BwP8+Covqtg5oVgVr4=; b=TPFx+P1g5vWiql14ZisxQfzsdXIPlx2ClhnRF09ud+fn8EFZGXOVd2juL8wlQ7Qtyb0g79 v+MaKeyPZGZSU0tSHRdANbNg8NY/yzMUKCuu75fVZoj1UeA4fB2JabfkXtHWWaY4WkjfTk OBMwxGdE7W2ujgKlYyRNKX329siqOfI= X-MC-Unique: jY1AD7aQPm-gPHyMruTjjA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Eric Blake , John Snow , Richard Henderson , Fam Zheng , Christian Borntraeger , Thomas Huth , Alex Williamson , "Dr. David Alan Gilbert" , Stefan Hajnoczi , qemu-s390x@nongnu.org, Halil Pasic , Eric Farman , qemu-block@nongnu.org, Vladimir Sementsov-Ogievskiy , David Hildenbrand , Juan Quintela , Ilya Leoshkevich Subject: [PULL 2/5] migration: No save_live_pending() method uses the QEMUFile parameter Date: Mon, 30 Jan 2023 09:03:04 +0100 Message-Id: <20230130080307.1792-3-quintela@redhat.com> In-Reply-To: <20230130080307.1792-1-quintela@redhat.com> References: <20230130080307.1792-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: 1675065864006100001 Content-Type: text/plain; charset="utf-8" So remove it everywhere. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- include/migration/register.h | 2 +- migration/savevm.h | 2 +- hw/s390x/s390-stattrib.c | 3 +-- hw/vfio/migration.c | 2 +- migration/block-dirty-bitmap.c | 2 +- migration/block.c | 2 +- migration/migration.c | 2 +- migration/ram.c | 2 +- migration/savevm.c | 4 ++-- 9 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/migration/register.h b/include/migration/register.h index c1dcff0f90..6ca71367af 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -46,7 +46,7 @@ typedef struct SaveVMHandlers { =20 /* This runs outside the iothread lock! */ int (*save_setup)(QEMUFile *f, void *opaque); - void (*save_live_pending)(QEMUFile *f, void *opaque, + void (*save_live_pending)(void *opaque, uint64_t threshold_size, uint64_t *res_precopy_only, uint64_t *res_compatible, diff --git a/migration/savevm.h b/migration/savevm.h index 6461342cb4..524cf12f25 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -40,7 +40,7 @@ void qemu_savevm_state_cleanup(void); void qemu_savevm_state_complete_postcopy(QEMUFile *f); int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only, bool inactivate_disks); -void qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size, +void qemu_savevm_state_pending(uint64_t max_size, uint64_t *res_precopy_only, uint64_t *res_compatible, uint64_t *res_postcopy_only); diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c index 9eda1c3b2a..b7f12ec4e2 100644 --- a/hw/s390x/s390-stattrib.c +++ b/hw/s390x/s390-stattrib.c @@ -182,8 +182,7 @@ static int cmma_save_setup(QEMUFile *f, void *opaque) return 0; } =20 -static void cmma_save_pending(QEMUFile *f, void *opaque, uint64_t max_size, - uint64_t *res_precopy_only, +static void cmma_save_pending(uint64_t *res_precopy_only, uint64_t *res_compatible, uint64_t *res_postcopy_only) { diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index c74453e0b5..b2125c7607 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -456,7 +456,7 @@ static void vfio_save_cleanup(void *opaque) trace_vfio_save_cleanup(vbasedev->name); } =20 -static void vfio_save_pending(QEMUFile *f, void *opaque, +static void vfio_save_pending(void *opaque, uint64_t threshold_size, uint64_t *res_precopy_only, uint64_t *res_compatible, diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index 15127d489a..c27ef9b033 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -762,7 +762,7 @@ static int dirty_bitmap_save_complete(QEMUFile *f, void= *opaque) return 0; } =20 -static void dirty_bitmap_save_pending(QEMUFile *f, void *opaque, +static void dirty_bitmap_save_pending(void *opaque, uint64_t max_size, uint64_t *res_precopy_only, uint64_t *res_compatible, diff --git a/migration/block.c b/migration/block.c index 5da15a62de..47852b8d58 100644 --- a/migration/block.c +++ b/migration/block.c @@ -863,7 +863,7 @@ static int block_save_complete(QEMUFile *f, void *opaqu= e) return 0; } =20 -static void block_save_pending(QEMUFile *f, void *opaque, uint64_t max_siz= e, +static void block_save_pending(void *opaque, uint64_t max_size, uint64_t *res_precopy_only, uint64_t *res_compatible, uint64_t *res_postcopy_only) diff --git a/migration/migration.c b/migration/migration.c index 52b5d39244..76524cc56e 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3751,7 +3751,7 @@ static MigIterateState migration_iteration_run(Migrat= ionState *s) uint64_t pending_size, pend_pre, pend_compat, pend_post; bool in_postcopy =3D s->state =3D=3D MIGRATION_STATUS_POSTCOPY_ACTIVE; =20 - qemu_savevm_state_pending(s->to_dst_file, s->threshold_size, &pend_pre, + qemu_savevm_state_pending(s->threshold_size, &pend_pre, &pend_compat, &pend_post); pending_size =3D pend_pre + pend_compat + pend_post; =20 diff --git a/migration/ram.c b/migration/ram.c index 68a45338e3..389739f162 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3409,7 +3409,7 @@ static int ram_save_complete(QEMUFile *f, void *opaqu= e) return 0; } =20 -static void ram_save_pending(QEMUFile *f, void *opaque, uint64_t max_size, +static void ram_save_pending(void *opaque, uint64_t max_size, uint64_t *res_precopy_only, uint64_t *res_compatible, uint64_t *res_postcopy_only) diff --git a/migration/savevm.c b/migration/savevm.c index a783789430..5e4bccb966 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1472,7 +1472,7 @@ flush: * the result is split into the amount for units that can and * for units that can't do postcopy. */ -void qemu_savevm_state_pending(QEMUFile *f, uint64_t threshold_size, +void qemu_savevm_state_pending(uint64_t threshold_size, uint64_t *res_precopy_only, uint64_t *res_compatible, uint64_t *res_postcopy_only) @@ -1493,7 +1493,7 @@ void qemu_savevm_state_pending(QEMUFile *f, uint64_t = threshold_size, continue; } } - se->ops->save_live_pending(f, se->opaque, threshold_size, + se->ops->save_live_pending(se->opaque, threshold_size, res_precopy_only, res_compatible, res_postcopy_only); } --=20 2.39.1 From nobody Wed May 15 07:48:54 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=1675065908; cv=none; d=zohomail.com; s=zohoarc; b=Q582XsNyFJV+5dDNWWigdVLAfmbaeSHjjdwo698eP2EEU/qsbVN9YEq9GR9Z+PyubjcwCA/r2lc0N1lJU5srcT4o2wlIJMGFw9c1Qx7qAp9IDv9S9O0vErJWcFN0m3t6yBFCQeG9bwJWPp6eU854xc8WuqZVWwihay4aLVmh5vQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675065908; 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=62zkcMFsgmrzsDVuYQzgZU31yC++L8jcMb99+M0XW/Q=; b=EGp66Z1FDfk1iuirgg/35EOYQohAvIh6jlOQN9xfmeXNhn0bwcgWKnhqs+Aa3vZnNxKW44lCD1WvAwok4CWJTtSBicGQyfWT20aaPupIedTDYwLEBQWaLewDTS8MnkD/Op5KaZQHCszzdI8xQZNM7L9KXGcwnVkHABjskoQfbMo= 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 1675065908610362.2180299521468; Mon, 30 Jan 2023 00:05:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMP8c-0001yG-65; Mon, 30 Jan 2023 03:03:38 -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 1pMP8T-0001uC-VF for qemu-devel@nongnu.org; Mon, 30 Jan 2023 03:03:30 -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 1pMP8R-0000yy-88 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 03:03: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-460-LlJm-PycMSy53hemCTEyug-1; Mon, 30 Jan 2023 03:03:22 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3A451802D2A; Mon, 30 Jan 2023 08:03:22 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C71A492B01; Mon, 30 Jan 2023 08:03:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675065806; 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=62zkcMFsgmrzsDVuYQzgZU31yC++L8jcMb99+M0XW/Q=; b=D1lWoREhoZCKe0WirvTvfPTzAPyrHDsxMUqWKx+lcAPjkF5KdG7Fovl1N/49tc28+fzKZI MOECW7G6uPJ3PMLneAmmI/DNf0puK+x5u/e80cdOn4RI0zJt+bWah8LvCyRjuWn2eoO2R7 ZQtszwh1uZ2M+LEtmZx3vnlm0w99UGk= X-MC-Unique: LlJm-PycMSy53hemCTEyug-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Eric Blake , John Snow , Richard Henderson , Fam Zheng , Christian Borntraeger , Thomas Huth , Alex Williamson , "Dr. David Alan Gilbert" , Stefan Hajnoczi , qemu-s390x@nongnu.org, Halil Pasic , Eric Farman , qemu-block@nongnu.org, Vladimir Sementsov-Ogievskiy , David Hildenbrand , Juan Quintela , Ilya Leoshkevich Subject: [PULL 3/5] migration: Split save_live_pending() into state_pending_* Date: Mon, 30 Jan 2023 09:03:05 +0100 Message-Id: <20230130080307.1792-4-quintela@redhat.com> In-Reply-To: <20230130080307.1792-1-quintela@redhat.com> References: <20230130080307.1792-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: 1675065910787100002 Content-Type: text/plain; charset="utf-8" We split the function into to: - state_pending_estimate: We estimate the remaining state size without stopping the machine. - state pending_exact: We calculate the exact amount of remaining state. The only "device" that implements different functions for _estimate() and _exact() is ram. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- docs/devel/migration.rst | 18 ++++++++------- docs/devel/vfio-migration.rst | 4 ++-- include/migration/register.h | 19 +++++++++------ migration/savevm.h | 12 ++++++---- hw/s390x/s390-stattrib.c | 10 ++++---- hw/vfio/migration.c | 21 +++++++++-------- migration/block-dirty-bitmap.c | 15 ++++++------ migration/block.c | 13 ++++++----- migration/migration.c | 20 +++++++++++----- migration/ram.c | 35 ++++++++++++++++++++-------- migration/savevm.c | 42 +++++++++++++++++++++++++++------- hw/vfio/trace-events | 2 +- migration/trace-events | 7 +++--- 13 files changed, 143 insertions(+), 75 deletions(-) diff --git a/docs/devel/migration.rst b/docs/devel/migration.rst index 3e9656d8e0..6f65c23b47 100644 --- a/docs/devel/migration.rst +++ b/docs/devel/migration.rst @@ -482,15 +482,17 @@ An iterative device must provide: - A ``load_setup`` function that initialises the data structures on the destination. =20 - - A ``save_live_pending`` function that is called repeatedly and must - indicate how much more data the iterative data must save. The core - migration code will use this to determine when to pause the CPUs - and complete the migration. + - A ``state_pending_exact`` function that indicates how much more + data we must save. The core migration code will use this to + determine when to pause the CPUs and complete the migration. =20 - - A ``save_live_iterate`` function (called after ``save_live_pending`` - when there is significant data still to be sent). It should send - a chunk of data until the point that stream bandwidth limits tell it - to stop. Each call generates one section. + - A ``state_pending_estimate`` function that indicates how much more + data we must save. When the estimated amount is smaller than the + threshold, we call ``state_pending_exact``. + + - A ``save_live_iterate`` function should send a chunk of data until + the point that stream bandwidth limits tell it to stop. Each call + generates one section. =20 - A ``save_live_complete_precopy`` function that must transmit the last section for the device containing any remaining data. diff --git a/docs/devel/vfio-migration.rst b/docs/devel/vfio-migration.rst index 9ff6163c88..673057c90d 100644 --- a/docs/devel/vfio-migration.rst +++ b/docs/devel/vfio-migration.rst @@ -28,7 +28,7 @@ VFIO implements the device hooks for the iterative approa= ch as follows: * A ``load_setup`` function that sets up the migration region on the destination and sets _RESUMING flag in the VFIO device state. =20 -* A ``save_live_pending`` function that reads pending_bytes from the vendor +* A ``state_pending_exact`` function that reads pending_bytes from the ven= dor driver, which indicates the amount of data that the vendor driver has ye= t to save for the VFIO device. =20 @@ -114,7 +114,7 @@ Live migration save path (RUNNING, _SETUP, _RUNNING|_SAVING) | (RUNNING, _ACTIVE, _RUNNING|_SAVING) - If device is active, get pending_bytes by .save_live_pending() + If device is active, get pending_bytes by .state_pending_exac= t() If total pending_bytes >=3D threshold_size, call .save_live_iter= ate() Data of VFIO device for pre-copy phase is copied Iterate till total pending bytes converge and are less than thresh= old diff --git a/include/migration/register.h b/include/migration/register.h index 6ca71367af..15cf32994d 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -46,11 +46,6 @@ typedef struct SaveVMHandlers { =20 /* This runs outside the iothread lock! */ int (*save_setup)(QEMUFile *f, void *opaque); - void (*save_live_pending)(void *opaque, - uint64_t threshold_size, - uint64_t *res_precopy_only, - uint64_t *res_compatible, - uint64_t *res_postcopy_only); /* Note for save_live_pending: * - res_precopy_only is for data which must be migrated in precopy ph= ase * or in stopped state, in other words - before target vm start @@ -61,8 +56,18 @@ typedef struct SaveVMHandlers { * Sum of res_postcopy_only, res_compatible and res_postcopy_only is t= he * whole amount of pending data. */ - - + /* This estimates the remaining data to transfer */ + void (*state_pending_estimate)(void *opaque, + uint64_t threshold_size, + uint64_t *res_precopy_only, + uint64_t *res_compatible, + uint64_t *res_postcopy_only); + /* This calculate the exact remaining data to transfer */ + void (*state_pending_exact)(void *opaque, + uint64_t threshold_size, + uint64_t *res_precopy_only, + uint64_t *res_compatible, + uint64_t *res_postcopy_only); LoadStateHandler *load_state; int (*load_setup)(QEMUFile *f, void *opaque); int (*load_cleanup)(void *opaque); diff --git a/migration/savevm.h b/migration/savevm.h index 524cf12f25..5d2cff4411 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -40,10 +40,14 @@ void qemu_savevm_state_cleanup(void); void qemu_savevm_state_complete_postcopy(QEMUFile *f); int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only, bool inactivate_disks); -void qemu_savevm_state_pending(uint64_t max_size, - uint64_t *res_precopy_only, - uint64_t *res_compatible, - uint64_t *res_postcopy_only); +void qemu_savevm_state_pending_exact(uint64_t threshold_size, + uint64_t *res_precopy_only, + uint64_t *res_compatible, + uint64_t *res_postcopy_only); +void qemu_savevm_state_pending_estimate(uint64_t thershold_size, + uint64_t *res_precopy_only, + uint64_t *res_compatible, + uint64_t *res_postcopy_only); void qemu_savevm_send_ping(QEMUFile *f, uint32_t value); void qemu_savevm_send_open_return_path(QEMUFile *f); int qemu_savevm_send_packaged(QEMUFile *f, const uint8_t *buf, size_t len); diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c index b7f12ec4e2..f1ee2c65bb 100644 --- a/hw/s390x/s390-stattrib.c +++ b/hw/s390x/s390-stattrib.c @@ -182,9 +182,10 @@ static int cmma_save_setup(QEMUFile *f, void *opaque) return 0; } =20 -static void cmma_save_pending(uint64_t *res_precopy_only, - uint64_t *res_compatible, - uint64_t *res_postcopy_only) +static void cmma_state_pending(void * opaque, + uint64_t *res_precopy_only, + uint64_t *res_compatible, + uint64_t *res_postcopy_only) { S390StAttribState *sas =3D S390_STATTRIB(opaque); S390StAttribClass *sac =3D S390_STATTRIB_GET_CLASS(sas); @@ -370,7 +371,8 @@ static SaveVMHandlers savevm_s390_stattrib_handlers =3D= { .save_setup =3D cmma_save_setup, .save_live_iterate =3D cmma_save_iterate, .save_live_complete_precopy =3D cmma_save_complete, - .save_live_pending =3D cmma_save_pending, + .state_pending_exact =3D cmma_state_pending, + .state_pending_estimate =3D cmma_state_pending, .save_cleanup =3D cmma_save_cleanup, .load_state =3D cmma_load, .is_active =3D cmma_active, diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index b2125c7607..c49ca466d4 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -456,11 +456,11 @@ static void vfio_save_cleanup(void *opaque) trace_vfio_save_cleanup(vbasedev->name); } =20 -static void vfio_save_pending(void *opaque, - uint64_t threshold_size, - uint64_t *res_precopy_only, - uint64_t *res_compatible, - uint64_t *res_postcopy_only) +static void vfio_state_pending(void *opaque, + uint64_t threshold_size, + uint64_t *res_precopy_only, + uint64_t *res_compatible, + uint64_t *res_postcopy_only) { VFIODevice *vbasedev =3D opaque; VFIOMigration *migration =3D vbasedev->migration; @@ -473,7 +473,7 @@ static void vfio_save_pending(void *opaque, =20 *res_precopy_only +=3D migration->pending_bytes; =20 - trace_vfio_save_pending(vbasedev->name, *res_precopy_only, + trace_vfio_state_pending(vbasedev->name, *res_precopy_only, *res_postcopy_only, *res_compatible); } =20 @@ -515,9 +515,9 @@ static int vfio_save_iterate(QEMUFile *f, void *opaque) } =20 /* - * Reset pending_bytes as .save_live_pending is not called during save= vm or - * snapshot case, in such case vfio_update_pending() at the start of t= his - * function updates pending_bytes. + * Reset pending_bytes as state_pending* are not called during + * savevm or snapshot case, in such case vfio_update_pending() at + * the start of this function updates pending_bytes. */ migration->pending_bytes =3D 0; trace_vfio_save_iterate(vbasedev->name, data_size); @@ -685,7 +685,8 @@ static int vfio_load_state(QEMUFile *f, void *opaque, i= nt version_id) static SaveVMHandlers savevm_vfio_handlers =3D { .save_setup =3D vfio_save_setup, .save_cleanup =3D vfio_save_cleanup, - .save_live_pending =3D vfio_save_pending, + .state_pending_exact =3D vfio_state_pending, + .state_pending_estimate =3D vfio_state_pending, .save_live_iterate =3D vfio_save_iterate, .save_live_complete_precopy =3D vfio_save_complete_precopy, .save_state =3D vfio_save_state, diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index c27ef9b033..6fac9fb34f 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -762,11 +762,11 @@ static int dirty_bitmap_save_complete(QEMUFile *f, vo= id *opaque) return 0; } =20 -static void dirty_bitmap_save_pending(void *opaque, - uint64_t max_size, - uint64_t *res_precopy_only, - uint64_t *res_compatible, - uint64_t *res_postcopy_only) +static void dirty_bitmap_state_pending(void *opaque, + uint64_t max_size, + uint64_t *res_precopy_only, + uint64_t *res_compatible, + uint64_t *res_postcopy_only) { DBMSaveState *s =3D &((DBMState *)opaque)->save; SaveBitmapState *dbms; @@ -784,7 +784,7 @@ static void dirty_bitmap_save_pending(void *opaque, =20 qemu_mutex_unlock_iothread(); =20 - trace_dirty_bitmap_save_pending(pending, max_size); + trace_dirty_bitmap_state_pending(pending); =20 *res_postcopy_only +=3D pending; } @@ -1253,7 +1253,8 @@ static SaveVMHandlers savevm_dirty_bitmap_handlers = =3D { .save_live_complete_postcopy =3D dirty_bitmap_save_complete, .save_live_complete_precopy =3D dirty_bitmap_save_complete, .has_postcopy =3D dirty_bitmap_has_postcopy, - .save_live_pending =3D dirty_bitmap_save_pending, + .state_pending_exact =3D dirty_bitmap_state_pending, + .state_pending_estimate =3D dirty_bitmap_state_pending, .save_live_iterate =3D dirty_bitmap_save_iterate, .is_active_iterate =3D dirty_bitmap_is_active_iterate, .load_state =3D dirty_bitmap_load, diff --git a/migration/block.c b/migration/block.c index 47852b8d58..544e74e9c5 100644 --- a/migration/block.c +++ b/migration/block.c @@ -863,10 +863,10 @@ static int block_save_complete(QEMUFile *f, void *opa= que) return 0; } =20 -static void block_save_pending(void *opaque, uint64_t max_size, - uint64_t *res_precopy_only, - uint64_t *res_compatible, - uint64_t *res_postcopy_only) +static void block_state_pending(void *opaque, uint64_t max_size, + uint64_t *res_precopy_only, + uint64_t *res_compatible, + uint64_t *res_postcopy_only) { /* Estimate pending number of bytes to send */ uint64_t pending; @@ -885,7 +885,7 @@ static void block_save_pending(void *opaque, uint64_t m= ax_size, pending =3D BLK_MIG_BLOCK_SIZE; } =20 - trace_migration_block_save_pending(pending); + trace_migration_block_state_pending(pending); /* We don't do postcopy */ *res_precopy_only +=3D pending; } @@ -1020,7 +1020,8 @@ static SaveVMHandlers savevm_block_handlers =3D { .save_setup =3D block_save_setup, .save_live_iterate =3D block_save_iterate, .save_live_complete_precopy =3D block_save_complete, - .save_live_pending =3D block_save_pending, + .state_pending_exact =3D block_state_pending, + .state_pending_estimate =3D block_state_pending, .load_state =3D block_load, .save_cleanup =3D block_migration_cleanup, .is_active =3D block_is_active, diff --git a/migration/migration.c b/migration/migration.c index 76524cc56e..e7b4b94348 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3748,15 +3748,23 @@ typedef enum { */ static MigIterateState migration_iteration_run(MigrationState *s) { - uint64_t pending_size, pend_pre, pend_compat, pend_post; + uint64_t pend_pre, pend_compat, pend_post; bool in_postcopy =3D s->state =3D=3D MIGRATION_STATUS_POSTCOPY_ACTIVE; =20 - qemu_savevm_state_pending(s->threshold_size, &pend_pre, - &pend_compat, &pend_post); - pending_size =3D pend_pre + pend_compat + pend_post; + qemu_savevm_state_pending_estimate(s->threshold_size, &pend_pre, + &pend_compat, &pend_post); + uint64_t pending_size =3D pend_pre + pend_compat + pend_post; =20 - trace_migrate_pending(pending_size, s->threshold_size, - pend_pre, pend_compat, pend_post); + trace_migrate_pending_estimate(pending_size, s->threshold_size, + pend_pre, pend_compat, pend_post); + + if (pend_pre + pend_compat <=3D s->threshold_size) { + qemu_savevm_state_pending_exact(s->threshold_size, &pend_pre, + &pend_compat, &pend_post); + pending_size =3D pend_pre + pend_compat + pend_post; + trace_migrate_pending_exact(pending_size, s->threshold_size, + pend_pre, pend_compat, pend_post); + } =20 if (pending_size && pending_size >=3D s->threshold_size) { /* Still a significant amount to transfer */ diff --git a/migration/ram.c b/migration/ram.c index 389739f162..56ff9cd29d 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3409,19 +3409,35 @@ static int ram_save_complete(QEMUFile *f, void *opa= que) return 0; } =20 -static void ram_save_pending(void *opaque, uint64_t max_size, - uint64_t *res_precopy_only, - uint64_t *res_compatible, - uint64_t *res_postcopy_only) +static void ram_state_pending_estimate(void *opaque, uint64_t max_size, + uint64_t *res_precopy_only, + uint64_t *res_compatible, + uint64_t *res_postcopy_only) { RAMState **temp =3D opaque; RAMState *rs =3D *temp; - uint64_t remaining_size; =20 - remaining_size =3D rs->migration_dirty_pages * TARGET_PAGE_SIZE; + uint64_t remaining_size =3D rs->migration_dirty_pages * TARGET_PAGE_SI= ZE; =20 - if (!migration_in_postcopy() && - remaining_size < max_size) { + if (migrate_postcopy_ram()) { + /* We can do postcopy, and all the data is postcopiable */ + *res_postcopy_only +=3D remaining_size; + } else { + *res_precopy_only +=3D remaining_size; + } +} + +static void ram_state_pending_exact(void *opaque, uint64_t max_size, + uint64_t *res_precopy_only, + uint64_t *res_compatible, + uint64_t *res_postcopy_only) +{ + RAMState **temp =3D opaque; + RAMState *rs =3D *temp; + + uint64_t remaining_size =3D rs->migration_dirty_pages * TARGET_PAGE_SI= ZE; + + if (!migration_in_postcopy()) { qemu_mutex_lock_iothread(); WITH_RCU_READ_LOCK_GUARD() { migration_bitmap_sync_precopy(rs); @@ -4577,7 +4593,8 @@ static SaveVMHandlers savevm_ram_handlers =3D { .save_live_complete_postcopy =3D ram_save_complete, .save_live_complete_precopy =3D ram_save_complete, .has_postcopy =3D ram_has_postcopy, - .save_live_pending =3D ram_save_pending, + .state_pending_exact =3D ram_state_pending_exact, + .state_pending_estimate =3D ram_state_pending_estimate, .load_state =3D ram_load, .save_cleanup =3D ram_save_cleanup, .load_setup =3D ram_load_setup, diff --git a/migration/savevm.c b/migration/savevm.c index 5e4bccb966..7f9f770c1e 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1472,10 +1472,10 @@ flush: * the result is split into the amount for units that can and * for units that can't do postcopy. */ -void qemu_savevm_state_pending(uint64_t threshold_size, - uint64_t *res_precopy_only, - uint64_t *res_compatible, - uint64_t *res_postcopy_only) +void qemu_savevm_state_pending_estimate(uint64_t threshold_size, + uint64_t *res_precopy_only, + uint64_t *res_compatible, + uint64_t *res_postcopy_only) { SaveStateEntry *se; =20 @@ -1485,7 +1485,7 @@ void qemu_savevm_state_pending(uint64_t threshold_siz= e, =20 =20 QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { - if (!se->ops || !se->ops->save_live_pending) { + if (!se->ops || !se->ops->state_pending_exact) { continue; } if (se->ops->is_active) { @@ -1493,9 +1493,35 @@ void qemu_savevm_state_pending(uint64_t threshold_si= ze, continue; } } - se->ops->save_live_pending(se->opaque, threshold_size, - res_precopy_only, res_compatible, - res_postcopy_only); + se->ops->state_pending_exact(se->opaque, threshold_size, + res_precopy_only, res_compatible, + res_postcopy_only); + } +} + +void qemu_savevm_state_pending_exact(uint64_t threshold_size, + uint64_t *res_precopy_only, + uint64_t *res_compatible, + uint64_t *res_postcopy_only) +{ + SaveStateEntry *se; + + *res_precopy_only =3D 0; + *res_compatible =3D 0; + *res_postcopy_only =3D 0; + + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + if (!se->ops || !se->ops->state_pending_estimate) { + continue; + } + if (se->ops->is_active) { + if (!se->ops->is_active(se->opaque)) { + continue; + } + } + se->ops->state_pending_estimate(se->opaque, threshold_size, + res_precopy_only, res_compatible, + res_postcopy_only); } } =20 diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 73dffe9e00..52de1c84f8 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -157,7 +157,7 @@ vfio_save_cleanup(const char *name) " (%s)" vfio_save_buffer(const char *name, uint64_t data_offset, uint64_t data_siz= e, uint64_t pending) " (%s) Offset 0x%"PRIx64" size 0x%"PRIx64" pending 0x%= "PRIx64 vfio_update_pending(const char *name, uint64_t pending) " (%s) pending 0x%= "PRIx64 vfio_save_device_config_state(const char *name) " (%s)" -vfio_save_pending(const char *name, uint64_t precopy, uint64_t postcopy, u= int64_t compatible) " (%s) precopy 0x%"PRIx64" postcopy 0x%"PRIx64" compati= ble 0x%"PRIx64 +vfio_state_pending(const char *name, uint64_t precopy, uint64_t postcopy, = uint64_t compatible) " (%s) precopy 0x%"PRIx64" postcopy 0x%"PRIx64" compat= ible 0x%"PRIx64 vfio_save_iterate(const char *name, int data_size) " (%s) data_size %d" vfio_save_complete_precopy(const char *name) " (%s)" vfio_load_device_config_state(const char *name) " (%s)" diff --git a/migration/trace-events b/migration/trace-events index 57003edcbd..adb680b0e6 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -150,7 +150,8 @@ migrate_fd_cleanup(void) "" migrate_fd_error(const char *error_desc) "error=3D%s" migrate_fd_cancel(void) "" migrate_handle_rp_req_pages(const char *rbname, size_t start, size_t len) = "in %s at 0x%zx len 0x%zx" -migrate_pending(uint64_t size, uint64_t max, uint64_t pre, uint64_t compat= , uint64_t post) "pending size %" PRIu64 " max %" PRIu64 " (pre =3D %" PRIu= 64 " compat=3D%" PRIu64 " post=3D%" PRIu64 ")" +migrate_pending_exact(uint64_t size, uint64_t max, uint64_t pre, uint64_t = compat, uint64_t post) "exact pending size %" PRIu64 " max %" PRIu64 " (pre= =3D %" PRIu64 " compat=3D%" PRIu64 " post=3D%" PRIu64 ")" +migrate_pending_estimate(uint64_t size, uint64_t max, uint64_t pre, uint64= _t compat, uint64_t post) "estimate pending size %" PRIu64 " max %" PRIu64 = " (pre =3D %" PRIu64 " compat=3D%" PRIu64 " post=3D%" PRIu64 ")" migrate_send_rp_message(int msg_type, uint16_t len) "%d: len %d" migrate_send_rp_recv_bitmap(char *name, int64_t size) "block '%s' size 0x%= "PRIi64 migration_completion_file_err(void) "" @@ -330,7 +331,7 @@ send_bitmap_bits(uint32_t flags, uint64_t start_sector,= uint32_t nr_sectors, uin dirty_bitmap_save_iterate(int in_postcopy) "in postcopy: %d" dirty_bitmap_save_complete_enter(void) "" dirty_bitmap_save_complete_finish(void) "" -dirty_bitmap_save_pending(uint64_t pending, uint64_t max_size) "pending %"= PRIu64 " max: %" PRIu64 +dirty_bitmap_state_pending(uint64_t pending) "pending %" PRIu64 dirty_bitmap_load_complete(void) "" dirty_bitmap_load_bits_enter(uint64_t first_sector, uint32_t nr_sectors) "= chunk: %" PRIu64 " %" PRIu32 dirty_bitmap_load_bits_zeroes(void) "" @@ -355,7 +356,7 @@ migration_block_save_device_dirty(int64_t sector) "Erro= r reading sector %" PRId6 migration_block_flush_blks(const char *action, int submitted, int read_don= e, int transferred) "%s submitted %d read_done %d transferred %d" migration_block_save(const char *mig_stage, int submitted, int transferred= ) "Enter save live %s submitted %d transferred %d" migration_block_save_complete(void) "Block migration completed" -migration_block_save_pending(uint64_t pending) "Enter save live pending %= " PRIu64 +migration_block_state_pending(uint64_t pending) "Enter save live pending = %" PRIu64 =20 # page_cache.c migration_pagecache_init(int64_t max_num_items) "Setting cache buckets to = %" PRId64 --=20 2.39.1 From nobody Wed May 15 07:48:54 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=1675065877; cv=none; d=zohomail.com; s=zohoarc; b=GmHMj1VWKLG8J2gzEAQae5AOusQN54meU60FG+TfBYSBAP1ApU/ChLLILvywjrRtL66xTIIjdDlpADis0WNu20U2DIybv3PL6LXzuLVIkQzbM5gOMWEfuEUotibC2P19+QytCQsGDtwmfSiWEUhZn7xoTlQrAK/9vuB0pAEgIbM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675065877; 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=almn5ln2UxG/8cmBIYmY15hUzFRkqQExU/G1mVB7PlI=; b=DujIF7LY/j3sQjrIP7L1T7juwhjZtF3torp0dayBo5f5Xdfcc8GhPw4IToZN9uuuLevEHexVEuImXjFU59+sT50TZ4wkmJTFD1/BzRRhUmSOBfZIUPVFa0KF3dSwPYvJ5MmXeAu25dwa90cOeLm2LnsUzeLvyB3qoONQnB2F8FY= 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 16750658770371020.4082353482185; Mon, 30 Jan 2023 00:04:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMP8c-0001z7-I1; Mon, 30 Jan 2023 03:03:38 -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 1pMP8b-0001wf-8V for qemu-devel@nongnu.org; Mon, 30 Jan 2023 03:03:37 -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 1pMP8Z-00012D-5Y for qemu-devel@nongnu.org; Mon, 30 Jan 2023 03:03:36 -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-465-7PrVOAVxO16_b6WE2Nzxxw-1; Mon, 30 Jan 2023 03:03:26 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 65792800B30; Mon, 30 Jan 2023 08:03:25 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 81972492B01; Mon, 30 Jan 2023 08:03:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675065813; 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=almn5ln2UxG/8cmBIYmY15hUzFRkqQExU/G1mVB7PlI=; b=BQuToY6W7b2NvDLCR0pH5e2H4HG/0NRsBy8b4iOQD1HcGlH9xhNA/iFbzAfNTVtfxNZzlE dfLE4usM++MffDq4fRLC1AG3YyX8lL2S0w8Sh+FrTWFkur9lttQj6r1LBmVNcFroFqd0u8 d+0nid2gq0SII8cvXLCzKcwWciRF5EM= X-MC-Unique: 7PrVOAVxO16_b6WE2Nzxxw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Eric Blake , John Snow , Richard Henderson , Fam Zheng , Christian Borntraeger , Thomas Huth , Alex Williamson , "Dr. David Alan Gilbert" , Stefan Hajnoczi , qemu-s390x@nongnu.org, Halil Pasic , Eric Farman , qemu-block@nongnu.org, Vladimir Sementsov-Ogievskiy , David Hildenbrand , Juan Quintela , Ilya Leoshkevich Subject: [PULL 4/5] migration: Remove unused threshold_size parameter Date: Mon, 30 Jan 2023 09:03:06 +0100 Message-Id: <20230130080307.1792-5-quintela@redhat.com> In-Reply-To: <20230130080307.1792-1-quintela@redhat.com> References: <20230130080307.1792-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: 1675065878518100003 Content-Type: text/plain; charset="utf-8" Until previous commit, save_live_pending() was used for ram. Now with the split into state_pending_estimate() and state_pending_exact() it is not needed anymore, so remove them. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- include/migration/register.h | 2 -- migration/savevm.h | 6 ++---- hw/vfio/migration.c | 1 - migration/block-dirty-bitmap.c | 1 - migration/block.c | 2 +- migration/migration.c | 10 ++++------ migration/ram.c | 4 ++-- migration/savevm.c | 11 ++++------- migration/trace-events | 4 ++-- 9 files changed, 15 insertions(+), 26 deletions(-) diff --git a/include/migration/register.h b/include/migration/register.h index 15cf32994d..b91a0cdbf8 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -58,13 +58,11 @@ typedef struct SaveVMHandlers { */ /* This estimates the remaining data to transfer */ void (*state_pending_estimate)(void *opaque, - uint64_t threshold_size, uint64_t *res_precopy_only, uint64_t *res_compatible, uint64_t *res_postcopy_only); /* This calculate the exact remaining data to transfer */ void (*state_pending_exact)(void *opaque, - uint64_t threshold_size, uint64_t *res_precopy_only, uint64_t *res_compatible, uint64_t *res_postcopy_only); diff --git a/migration/savevm.h b/migration/savevm.h index 5d2cff4411..b1901e68d5 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -40,12 +40,10 @@ void qemu_savevm_state_cleanup(void); void qemu_savevm_state_complete_postcopy(QEMUFile *f); int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only, bool inactivate_disks); -void qemu_savevm_state_pending_exact(uint64_t threshold_size, - uint64_t *res_precopy_only, +void qemu_savevm_state_pending_exact(uint64_t *res_precopy_only, uint64_t *res_compatible, uint64_t *res_postcopy_only); -void qemu_savevm_state_pending_estimate(uint64_t thershold_size, - uint64_t *res_precopy_only, +void qemu_savevm_state_pending_estimate(uint64_t *res_precopy_only, uint64_t *res_compatible, uint64_t *res_postcopy_only); void qemu_savevm_send_ping(QEMUFile *f, uint32_t value); diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index c49ca466d4..b3318f0f20 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -457,7 +457,6 @@ static void vfio_save_cleanup(void *opaque) } =20 static void vfio_state_pending(void *opaque, - uint64_t threshold_size, uint64_t *res_precopy_only, uint64_t *res_compatible, uint64_t *res_postcopy_only) diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index 6fac9fb34f..5a621419d3 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -763,7 +763,6 @@ static int dirty_bitmap_save_complete(QEMUFile *f, void= *opaque) } =20 static void dirty_bitmap_state_pending(void *opaque, - uint64_t max_size, uint64_t *res_precopy_only, uint64_t *res_compatible, uint64_t *res_postcopy_only) diff --git a/migration/block.c b/migration/block.c index 544e74e9c5..29f69025af 100644 --- a/migration/block.c +++ b/migration/block.c @@ -863,7 +863,7 @@ static int block_save_complete(QEMUFile *f, void *opaqu= e) return 0; } =20 -static void block_state_pending(void *opaque, uint64_t max_size, +static void block_state_pending(void *opaque, uint64_t *res_precopy_only, uint64_t *res_compatible, uint64_t *res_postcopy_only) diff --git a/migration/migration.c b/migration/migration.c index e7b4b94348..594a42f085 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3751,18 +3751,16 @@ static MigIterateState migration_iteration_run(Migr= ationState *s) uint64_t pend_pre, pend_compat, pend_post; bool in_postcopy =3D s->state =3D=3D MIGRATION_STATUS_POSTCOPY_ACTIVE; =20 - qemu_savevm_state_pending_estimate(s->threshold_size, &pend_pre, - &pend_compat, &pend_post); + qemu_savevm_state_pending_estimate(&pend_pre, &pend_compat, &pend_post= ); uint64_t pending_size =3D pend_pre + pend_compat + pend_post; =20 - trace_migrate_pending_estimate(pending_size, s->threshold_size, + trace_migrate_pending_estimate(pending_size, pend_pre, pend_compat, pend_post); =20 if (pend_pre + pend_compat <=3D s->threshold_size) { - qemu_savevm_state_pending_exact(s->threshold_size, &pend_pre, - &pend_compat, &pend_post); + qemu_savevm_state_pending_exact(&pend_pre, &pend_compat, &pend_pos= t); pending_size =3D pend_pre + pend_compat + pend_post; - trace_migrate_pending_exact(pending_size, s->threshold_size, + trace_migrate_pending_exact(pending_size, pend_pre, pend_compat, pend_post); } =20 diff --git a/migration/ram.c b/migration/ram.c index 56ff9cd29d..885d7dbf23 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3409,7 +3409,7 @@ static int ram_save_complete(QEMUFile *f, void *opaqu= e) return 0; } =20 -static void ram_state_pending_estimate(void *opaque, uint64_t max_size, +static void ram_state_pending_estimate(void *opaque, uint64_t *res_precopy_only, uint64_t *res_compatible, uint64_t *res_postcopy_only) @@ -3427,7 +3427,7 @@ static void ram_state_pending_estimate(void *opaque, = uint64_t max_size, } } =20 -static void ram_state_pending_exact(void *opaque, uint64_t max_size, +static void ram_state_pending_exact(void *opaque, uint64_t *res_precopy_only, uint64_t *res_compatible, uint64_t *res_postcopy_only) diff --git a/migration/savevm.c b/migration/savevm.c index 7f9f770c1e..e1caa3ea7c 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1472,8 +1472,7 @@ flush: * the result is split into the amount for units that can and * for units that can't do postcopy. */ -void qemu_savevm_state_pending_estimate(uint64_t threshold_size, - uint64_t *res_precopy_only, +void qemu_savevm_state_pending_estimate(uint64_t *res_precopy_only, uint64_t *res_compatible, uint64_t *res_postcopy_only) { @@ -1483,7 +1482,6 @@ void qemu_savevm_state_pending_estimate(uint64_t thre= shold_size, *res_compatible =3D 0; *res_postcopy_only =3D 0; =20 - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { if (!se->ops || !se->ops->state_pending_exact) { continue; @@ -1493,14 +1491,13 @@ void qemu_savevm_state_pending_estimate(uint64_t th= reshold_size, continue; } } - se->ops->state_pending_exact(se->opaque, threshold_size, + se->ops->state_pending_exact(se->opaque, res_precopy_only, res_compatible, res_postcopy_only); } } =20 -void qemu_savevm_state_pending_exact(uint64_t threshold_size, - uint64_t *res_precopy_only, +void qemu_savevm_state_pending_exact(uint64_t *res_precopy_only, uint64_t *res_compatible, uint64_t *res_postcopy_only) { @@ -1519,7 +1516,7 @@ void qemu_savevm_state_pending_exact(uint64_t thresho= ld_size, continue; } } - se->ops->state_pending_estimate(se->opaque, threshold_size, + se->ops->state_pending_estimate(se->opaque, res_precopy_only, res_compatible, res_postcopy_only); } diff --git a/migration/trace-events b/migration/trace-events index adb680b0e6..67b65a70ff 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -150,8 +150,8 @@ migrate_fd_cleanup(void) "" migrate_fd_error(const char *error_desc) "error=3D%s" migrate_fd_cancel(void) "" migrate_handle_rp_req_pages(const char *rbname, size_t start, size_t len) = "in %s at 0x%zx len 0x%zx" -migrate_pending_exact(uint64_t size, uint64_t max, uint64_t pre, uint64_t = compat, uint64_t post) "exact pending size %" PRIu64 " max %" PRIu64 " (pre= =3D %" PRIu64 " compat=3D%" PRIu64 " post=3D%" PRIu64 ")" -migrate_pending_estimate(uint64_t size, uint64_t max, uint64_t pre, uint64= _t compat, uint64_t post) "estimate pending size %" PRIu64 " max %" PRIu64 = " (pre =3D %" PRIu64 " compat=3D%" PRIu64 " post=3D%" PRIu64 ")" +migrate_pending_exact(uint64_t size, uint64_t pre, uint64_t compat, uint64= _t post) "exact pending size %" PRIu64 " (pre =3D %" PRIu64 " compat=3D%" P= RIu64 " post=3D%" PRIu64 ")" +migrate_pending_estimate(uint64_t size, uint64_t pre, uint64_t compat, uin= t64_t post) "estimate pending size %" PRIu64 " (pre =3D %" PRIu64 " compat= =3D%" PRIu64 " post=3D%" PRIu64 ")" migrate_send_rp_message(int msg_type, uint16_t len) "%d: len %d" migrate_send_rp_recv_bitmap(char *name, int64_t size) "block '%s' size 0x%= "PRIi64 migration_completion_file_err(void) "" --=20 2.39.1 From nobody Wed May 15 07:48:54 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=1675065886; cv=none; d=zohomail.com; s=zohoarc; b=YdZ9prloFuQdHVYy6aSypJQsow8eZj7x9v6SshqE0Kz5M8kDmrJeJwcZsFIcbcF/92f0+KNROlTCbCssbvCplHmyIW+q1kkFWh4cpEXf/F8U7n71+zjULVYO22c2ENUZLFrDv2oqct1nythUu7YOP6fwzXRA3ofNve7cw+zT1/c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675065886; 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=WpnvIH3TZ/8iZ1ArVTqJJxIBFy6rJKX1QfsQoLI7Mu0=; b=TgDj84ly4yu9SvhtAhari42yF8fAstn+rkIITRwAEAD7E0yCgdHpV+7EZNj92pAplwJ+TU15a///5fQUBozaSvy1WDAqfuhJcOY9RnzJGCS8bK0R1Q56prACdOW0zIceZ7diuz6NnGhm3jK/gQx6UAwdR0ChhAMtPwlOAaOUiok= 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 1675065886717660.1691080748981; Mon, 30 Jan 2023 00:04:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMP8d-00020N-P9; Mon, 30 Jan 2023 03:03:39 -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 1pMP8c-0001z4-G9 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 03:03:38 -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 1pMP8a-00013W-4K for qemu-devel@nongnu.org; Mon, 30 Jan 2023 03:03:38 -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-668-6syNW15DNtO-V_93a8vtUA-1; Mon, 30 Jan 2023 03:03:29 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8E2D13C0DDC0; Mon, 30 Jan 2023 08:03:28 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id ABDB7492B01; Mon, 30 Jan 2023 08:03:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675065815; 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=WpnvIH3TZ/8iZ1ArVTqJJxIBFy6rJKX1QfsQoLI7Mu0=; b=W2010SdQXUGNCsFsTD8T3x65hJQKF1Soo6RH66+d17zmG7HC/n7LSTRopbV66l79FZZynC Uj9K5V1ISIi7SXDQuEoM9PzTTOjv2Q9AsqIOl88q2LIzHM9cNz3AytXAStqYjiEQMxiC3r CjHrnjmE4O4OuiLBRk0klI4b1A8rz34= X-MC-Unique: 6syNW15DNtO-V_93a8vtUA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Eric Blake , John Snow , Richard Henderson , Fam Zheng , Christian Borntraeger , Thomas Huth , Alex Williamson , "Dr. David Alan Gilbert" , Stefan Hajnoczi , qemu-s390x@nongnu.org, Halil Pasic , Eric Farman , qemu-block@nongnu.org, Vladimir Sementsov-Ogievskiy , David Hildenbrand , Juan Quintela , Ilya Leoshkevich Subject: [PULL 5/5] migration: simplify migration_iteration_run() Date: Mon, 30 Jan 2023 09:03:07 +0100 Message-Id: <20230130080307.1792-6-quintela@redhat.com> In-Reply-To: <20230130080307.1792-1-quintela@redhat.com> References: <20230130080307.1792-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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=unavailable 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: 1675065888569100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration/migration.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 594a42f085..644c61e91d 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3764,23 +3764,23 @@ static MigIterateState migration_iteration_run(Migr= ationState *s) pend_pre, pend_compat, pend_post); } =20 - if (pending_size && pending_size >=3D s->threshold_size) { - /* Still a significant amount to transfer */ - if (!in_postcopy && pend_pre <=3D s->threshold_size && - qatomic_read(&s->start_postcopy)) { - if (postcopy_start(s)) { - error_report("%s: postcopy failed to start", __func__); - } - return MIG_ITERATE_SKIP; - } - /* Just another iteration step */ - qemu_savevm_state_iterate(s->to_dst_file, in_postcopy); - } else { + if (pending_size < s->threshold_size) { trace_migration_thread_low_pending(pending_size); migration_completion(s); return MIG_ITERATE_BREAK; } =20 + /* Still a significant amount to transfer */ + if (!in_postcopy && pend_pre <=3D s->threshold_size && + qatomic_read(&s->start_postcopy)) { + if (postcopy_start(s)) { + error_report("%s: postcopy failed to start", __func__); + } + return MIG_ITERATE_SKIP; + } + + /* Just another iteration step */ + qemu_savevm_state_iterate(s->to_dst_file, in_postcopy); return MIG_ITERATE_RESUME; } =20 --=20 2.39.1