From patchwork Thu Feb 9 23:34:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 13135219 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74085C05027 for ; Thu, 9 Feb 2023 23:36:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231305AbjBIXgb (ORCPT ); Thu, 9 Feb 2023 18:36:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231263AbjBIXgO (ORCPT ); Thu, 9 Feb 2023 18:36:14 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3796E65682 for ; Thu, 9 Feb 2023 15:34:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675985686; 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=uHOT9wZeB+0b4Ejcrcd0vvTrtjiS44Q0GkTx2lSsIMo=; b=Kv1QQMZuk4JZCl6qDExdCFK/ImkdydZouwUHdVU06LESrSBk3XSNwfvdRmoixg7uRa93AR RthGpxDGaw03kMl9jaKAUTbruxcvV+t4fIo8WhtAaR1aOF2C5ZGQf2TAEBR+WbFAAg3skW 2tNblxnZEJ4zNPUmS8q/K8plevthP+I= 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-626-W6KkPsGnN_qtwwI4pXb9-w-1; Thu, 09 Feb 2023 18:34:43 -0500 X-MC-Unique: W6KkPsGnN_qtwwI4pXb9-w-1 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 357BE1C05AAF; Thu, 9 Feb 2023 23:34:43 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 34935175AD; Thu, 9 Feb 2023 23:34:41 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Juan Quintela , "Dr. David Alan Gilbert" , =?utf-8?q?Daniel_P=2E_Berra?= =?utf-8?q?ng=C3=A9?= , Paolo Bonzini , Cornelia Huck , "Michael S. Tsirkin" , Thomas Huth , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [PULL 06/17] migration: Simplify ram_find_and_save_block() Date: Fri, 10 Feb 2023 00:34:15 +0100 Message-Id: <20230209233426.37811-7-quintela@redhat.com> In-Reply-To: <20230209233426.37811-1-quintela@redhat.com> References: <20230209233426.37811-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org We will need later that find_dirty_block() return errors, so simplify the loop. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Juan Quintela --- migration/ram.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index b966e148c2..dd809fec1f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2542,7 +2542,6 @@ static int ram_find_and_save_block(RAMState *rs) { PageSearchStatus *pss = &rs->pss[RAM_CHANNEL_PRECOPY]; int pages = 0; - bool again, found; /* No dirty page as there is zero RAM */ if (!ram_bytes_total()) { @@ -2564,18 +2563,17 @@ static int ram_find_and_save_block(RAMState *rs) pss_init(pss, rs->last_seen_block, rs->last_page); do { - again = true; - found = get_queued_page(rs, pss); - - if (!found) { + if (!get_queued_page(rs, pss)) { /* priority queue empty, so just search for something dirty */ - found = find_dirty_block(rs, pss, &again); + bool again = true; + if (!find_dirty_block(rs, pss, &again)) { + if (!again) { + break; + } + } } - - if (found) { - pages = ram_save_host_page(rs, pss); - } - } while (!pages && again); + pages = ram_save_host_page(rs, pss); + } while (!pages); rs->last_seen_block = pss->block; rs->last_page = pss->page;