From nobody Mon Feb 9 14:37:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1692110386; cv=none; d=zohomail.com; s=zohoarc; b=LcGah2/mGjPKR3KqzvLX2AxkugPXuIn/bwhf+rog+yCJMVpJscZQSMCHqOqjXFkHaB0n4DIetwJFe3CjiMzz/WYrBwW6ns3xoXTzJHEcjr3z4HJXuiCRMqTixXlrp32Zs3uPzWnVmvtLbzescjl0ZbuRpK201S/JuwTpRCnqqns= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692110386; 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=rDHF1F1Gm9CKMTWMnNAi///z2f1xyUqQ3HKLwljCm00=; b=iQLKpRhOcCzsMAPnesNanB88VPO1dkzvJFxDQhvSNWIRaBQDZbWkGoQ4aLLgqVwiHc8TmPld0xNgmIuAJz25RTV2x8cuMcjBHYgY5mczcJ49lwl2/qMTIwlW9Tr4wTqzY7KdBIgDNm5bnSNQv7OYuHj8tKMLI7lfNFYxlAo046s= 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 1692110386040371.59468848437257; Tue, 15 Aug 2023 07:39:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qVvC1-0008R7-Bi; Tue, 15 Aug 2023 10:38:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qVvC0-0008Pz-0O for qemu-devel@nongnu.org; Tue, 15 Aug 2023 10:38:44 -0400 Received: from smtp-out2.suse.de ([2001:67c:2178:6::1d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qVvBx-0002wO-Ns for qemu-devel@nongnu.org; Tue, 15 Aug 2023 10:38:43 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id A75701F749; Tue, 15 Aug 2023 14:38:40 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5DC6213909; Tue, 15 Aug 2023 14:38:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UBc0Cu+N22T0WQAAMHmgww (envelope-from ); Tue, 15 Aug 2023 14:38:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1692110320; h=from:from:reply-to: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=rDHF1F1Gm9CKMTWMnNAi///z2f1xyUqQ3HKLwljCm00=; b=dqBEDlvdW1j9CeKbqHrCUe1Mx2Tc2eM8/RvqdXzPTw3IJ8kwN9uVh7a55NbmMXbLnfRrFQ fWBYMlT1vY83/yAPM6Phjtx8BCSV07TmyZnUHtPIphEGw/7M3DwdZ7c7D9WIfN9qYesGgq eRQ7MQdLxgCp2kTsqYopUIUCq0cjLyA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1692110320; h=from:from:reply-to: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=rDHF1F1Gm9CKMTWMnNAi///z2f1xyUqQ3HKLwljCm00=; b=5Y9cnO4dZyOM7VoBmhJn3T2ihxxpnuB/TxG4GS/zb9Ms1ofbWQRq6+5SmWV/FWqMBFHmFc Vd0PV/XWGXwMUZDg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Juan Quintela , Peter Xu , Leonardo Bras Subject: [PATCH 5/5] migration/ram: Merge save_zero_page functions Date: Tue, 15 Aug 2023 11:38:28 -0300 Message-Id: <20230815143828.15436-6-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230815143828.15436-1-farosas@suse.de> References: <20230815143828.15436-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:67c:2178:6::1d; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @suse.de) X-ZM-MESSAGEID: 1692110387071100001 Content-Type: text/plain; charset="utf-8" We don't need to do this in two pieces. One single function makes it easier to grasp, specially since it removes the indirection on the return value handling. Signed-off-by: Fabiano Rosas --- migration/ram.c | 41 +++++++++++------------------------------ 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 8ec38f69e8..13935ead1c 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1128,32 +1128,6 @@ void ram_release_page(const char *rbname, uint64_t o= ffset) ram_discard_range(rbname, offset, TARGET_PAGE_SIZE); } =20 -/** - * save_zero_page_to_file: send the zero page to the file - * - * Returns the size of data written to the file, 0 means the page is not - * a zero page - * - * @pss: current PSS channel - * @block: block that contains the page we want to send - * @offset: offset inside the block for the page - */ -static int save_zero_page_to_file(PageSearchStatus *pss, RAMBlock *block, - ram_addr_t offset) -{ - uint8_t *p =3D block->host + offset; - QEMUFile *file =3D pss->pss_channel; - int len =3D 0; - - if (buffer_is_zero(p, TARGET_PAGE_SIZE)) { - len +=3D save_page_header(pss, file, block, offset | RAM_SAVE_FLAG= _ZERO); - qemu_put_byte(file, 0); - len +=3D 1; - ram_release_page(block->idstr, offset); - } - return len; -} - /** * save_zero_page: send the zero page to the stream * @@ -1167,12 +1141,19 @@ static int save_zero_page_to_file(PageSearchStatus = *pss, RAMBlock *block, static int save_zero_page(RAMState *rs, PageSearchStatus *pss, RAMBlock *b= lock, ram_addr_t offset) { - int len =3D save_zero_page_to_file(pss, block, offset); + uint8_t *p =3D block->host + offset; + QEMUFile *file =3D pss->pss_channel; + int len =3D 0; =20 - if (!len) { - return -1; + if (!buffer_is_zero(p, TARGET_PAGE_SIZE)) { + return 0; } =20 + len +=3D save_page_header(pss, file, block, offset | RAM_SAVE_FLAG_ZER= O); + qemu_put_byte(file, 0); + len +=3D 1; + ram_release_page(block->idstr, offset); + stat64_add(&mig_stats.zero_pages, 1); ram_transferred_add(len); =20 @@ -1186,7 +1167,7 @@ static int save_zero_page(RAMState *rs, PageSearchSta= tus *pss, RAMBlock *block, XBZRLE_cache_unlock(); } =20 - return 1; + return len; } =20 /* --=20 2.35.3