From nobody Thu Jul 10 04:26:02 2025 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1653392841; cv=none; d=zohomail.com; s=zohoarc; b=brwFJ4Q8Mjt+I8OfD1etktK9tfosCK8U/HLpiR2Tu5yGPz5/89o/oj2SjsQskbs6G8T3Tjr1y58L2gxYOyBQQjEL1sBSZrHjiWsWBiUfB88d2OaORB+1hMWeUPWnITbpD6qaFlKk15Y0LQYyprATKbDG//CASgt70UbSEq68Dwk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653392841; h=Content-Type: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=omqVQcD2wd6yHjOZp8jLK64Uo39yJDgaOhIBAv9DTFo=; b=m+0he2z3d7Qg1lKkS+IZDQgRxruoDXDWZTDp/ZWJhW92JC3JKn4BwtG/Pn2eQB+/oWr7kTqcez27SLEbAdP92xVtHaqzFgtVxBuBGMizPjQ53+oVc9XMaXIw9mRvaOfznjKQZVUxP6kG9Rqyo3HdJ4+mo5VJ/+WtxaLGJVMZGNs= 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+importer2=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 1653392841659371.8543570127016; Tue, 24 May 2022 04:47:21 -0700 (PDT) Received: from localhost ([::1]:45078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntT0P-000251-KM for importer2@patchew.org; Tue, 24 May 2022 07:47:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJZ-0005nn-B8 for qemu-devel@nongnu.org; Tue, 24 May 2022 07:03:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:28299) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJP-0003Ne-CK for qemu-devel@nongnu.org; Tue, 24 May 2022 07:02:58 -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-625-QCR2t9h8Mc-NhBSBWFDnTA-1; Tue, 24 May 2022 07:02:46 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BBD70100FBC3; Tue, 24 May 2022 11:02:45 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84AD21121315; Tue, 24 May 2022 11:02:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653390169; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=omqVQcD2wd6yHjOZp8jLK64Uo39yJDgaOhIBAv9DTFo=; b=K8x1UoPe5BfOHLHAawmxV9+g4zgqK5GzhbU7ugnkt7J8IV5cT9zGG7qBIrOVlzDPSXoRdc bY4Eq/oxW+xqJVPSO5BRv0yZSo72c3+kDVu49py6AV8BkHc+T8k/gxzTYzT1UeyHhV0M5M nr7FT4dk7Z3Eu2THkRxbczKvXNDmzUU= X-MC-Unique: QCR2t9h8Mc-NhBSBWFDnTA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , qemu-block@nongnu.org, Stefan Hajnoczi , Hailiang Zhang , Juan Quintela , Fam Zheng Subject: [PATCH 04/20] migration: rename rate limiting fields in QEMUFile Date: Tue, 24 May 2022 12:02:19 +0100 Message-Id: <20220524110235.145079-5-berrange@redhat.com> In-Reply-To: <20220524110235.145079-1-berrange@redhat.com> References: <20220524110235.145079-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=berrange@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=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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653392843053100001 This renames the following QEMUFile fields * bytes_xfer -> rate_limit_used * xfer_limit -> rate_limit_max The intent is to make it clear that 'bytes_xfer' is specifically related to rate limiting of data and applies to data queued, which need not have been transferred on the wire yet if a flush hasn't taken place. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Dr. David Alan Gilbert --- migration/qemu-file.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 1479cddad9..03f0b13a55 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -39,8 +39,16 @@ struct QEMUFile { const QEMUFileHooks *hooks; void *opaque; =20 - int64_t bytes_xfer; - int64_t xfer_limit; + /* + * Maximum amount of data in bytes to transfer during one + * rate limiting time window + */ + int64_t rate_limit_max; + /* + * Total amount of data in bytes queued for transfer + * during this rate limiting time window + */ + int64_t rate_limit_used; =20 int64_t pos; /* start of buffer when writing, end of buffer when reading */ @@ -304,7 +312,7 @@ size_t ram_control_save_page(QEMUFile *f, ram_addr_t bl= ock_offset, int ret =3D f->hooks->save_page(f, f->opaque, block_offset, offset, size, bytes_sent); if (ret !=3D RAM_SAVE_CONTROL_NOT_SUPP) { - f->bytes_xfer +=3D size; + f->rate_limit_used +=3D size; } =20 if (ret !=3D RAM_SAVE_CONTROL_DELAYED && @@ -457,7 +465,7 @@ void qemu_put_buffer_async(QEMUFile *f, const uint8_t *= buf, size_t size, return; } =20 - f->bytes_xfer +=3D size; + f->rate_limit_used +=3D size; add_to_iovec(f, buf, size, may_free); } =20 @@ -475,7 +483,7 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, s= ize_t size) l =3D size; } memcpy(f->buf + f->buf_index, buf, l); - f->bytes_xfer +=3D l; + f->rate_limit_used +=3D l; add_buf_to_iovec(f, l); if (qemu_file_get_error(f)) { break; @@ -492,7 +500,7 @@ void qemu_put_byte(QEMUFile *f, int v) } =20 f->buf[f->buf_index] =3D v; - f->bytes_xfer++; + f->rate_limit_used++; add_buf_to_iovec(f, 1); } =20 @@ -674,7 +682,7 @@ int qemu_file_rate_limit(QEMUFile *f) if (qemu_file_get_error(f)) { return 1; } - if (f->xfer_limit > 0 && f->bytes_xfer > f->xfer_limit) { + if (f->rate_limit_max > 0 && f->rate_limit_used > f->rate_limit_max) { return 1; } return 0; @@ -682,22 +690,22 @@ int qemu_file_rate_limit(QEMUFile *f) =20 int64_t qemu_file_get_rate_limit(QEMUFile *f) { - return f->xfer_limit; + return f->rate_limit_max; } =20 void qemu_file_set_rate_limit(QEMUFile *f, int64_t limit) { - f->xfer_limit =3D limit; + f->rate_limit_max =3D limit; } =20 void qemu_file_reset_rate_limit(QEMUFile *f) { - f->bytes_xfer =3D 0; + f->rate_limit_used =3D 0; } =20 void qemu_file_update_transfer(QEMUFile *f, int64_t len) { - f->bytes_xfer +=3D len; + f->rate_limit_used +=3D len; } =20 void qemu_put_be16(QEMUFile *f, unsigned int v) --=20 2.36.1