From nobody Sun Feb 8 23:06:15 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502980401423635.377205292211; Thu, 17 Aug 2017 07:33:21 -0700 (PDT) Received: from localhost ([::1]:55697 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diLrL-0000M5-W8 for importer@patchew.org; Thu, 17 Aug 2017 10:33:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36156) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diLnT-0005hJ-C0 for qemu-devel@nongnu.org; Thu, 17 Aug 2017 10:29:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1diLnQ-0006uk-6d for qemu-devel@nongnu.org; Thu, 17 Aug 2017 10:29:19 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:48672) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1diLnP-0006iW-PX; Thu, 17 Aug 2017 10:29:16 -0400 Received: from a88-114-101-76.elisa-laajakaista.fi ([88.114.101.76] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1diLmn-00044C-1t; Thu, 17 Aug 2017 16:28:37 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1diLmZ-0001w2-EF; Thu, 17 Aug 2017 17:28:23 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=ZRNVCCbHWHXeJ5qop39nxE97NF6RnkwXwVIXMCbRetI=; b=HxQNBzIMbAJxIudg41XHzdqNQGbOYHsWe5cEE7nBUCnT65/ZFqQ7h2jIU5jVlO7aJ/NYpxIUhraIOusRNRPriKFXDGYSc0sDTwb3S4Pp8NwnVR0Pp105vFvhqMCagmiyZkOfj+ZQuyiHjdTiX390OBYLenHmLOVlT+dsU3PxumDEQZTQnqjS+cGNCpqh/5gEgNKV9fFA0rEjXXOePJEXkSUUq8UcS65mlFtwxUUaP0AakhRlz7z+Xu4JZ19OQBtQw9VXlA589dp8vh5QOfeHiNstYJTMIHLSAiWfo8IVQqRoFKWu1OOQdIe0NM0MEzWWhS8evCJl89oPPSyXtuYI5g==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 17 Aug 2017 17:28:15 +0300 Message-Id: <01b7212cc910cea55e4a1ac8d4704afaff0647b4.1502979710.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH 4/4] throttle: Make LeakyBucket.avg and LeakyBucket.max integer types X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alberto Garcia , Stefan Hajnoczi , qemu-block@nongnu.org, Manos Pitsidianakis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Both the throttling limits set with the throttling.iops-* and throttling.bps-* options and their QMP equivalents defined in the BlockIOThrottle struct are integer values. Those limits are also reported in the BlockDeviceInfo struct and they are integers there as well. Therefore there's no reason to store them internally as double and do the conversion everytime we're setting or querying them, so this patch uses int64_t for those types. LeakyBucket.level and LeakyBucket.burst_level do however remain double because their value changes depending on the fraction of time elapsed since the previous I/O operation. Signed-off-by: Alberto Garcia Reviewed-by: Manos Pitsidianakis --- include/qemu/throttle.h | 4 ++-- util/throttle.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h index 66a8ac10a4..c466f6ccaa 100644 --- a/include/qemu/throttle.h +++ b/include/qemu/throttle.h @@ -77,8 +77,8 @@ typedef enum { */ =20 typedef struct LeakyBucket { - double avg; /* average goal in units per second */ - double max; /* leaky bucket max burst in units */ + int64_t avg; /* average goal in units per second */ + int64_t max; /* leaky bucket max burst in units */ double level; /* bucket level in units */ double burst_level; /* bucket level in units (for computing burs= ts) */ unsigned burst_length; /* max length of the burst period, in second= s */ diff --git a/util/throttle.c b/util/throttle.c index 1f29cf9918..55a2451a14 100644 --- a/util/throttle.c +++ b/util/throttle.c @@ -106,13 +106,13 @@ int64_t throttle_compute_wait(LeakyBucket *bkt) /* If bkt->max is 0 we still want to allow short bursts of I/O * from the guest, otherwise every other request will be throttled * and performance will suffer considerably. */ - bucket_size =3D bkt->avg / 10; + bucket_size =3D (double) bkt->avg / 10; burst_bucket_size =3D 0; } else { /* If we have a burst limit then we have to wait until all I/O * at burst rate has finished before throttling to bkt->avg */ bucket_size =3D bkt->max * bkt->burst_length; - burst_bucket_size =3D bkt->max / 10; + burst_bucket_size =3D (double) bkt->max / 10; } =20 /* If the main bucket is full then we have to wait */ --=20 2.11.0