From: Eric Blake <eblake@redhat.com>
To: "Benoît Canet" <benoit.canet@nodalink.com>, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org
Subject: Re: [Qemu-devel] [PATCH v2 1/3] throttle: Make NANOSECONDS_PER_SECOND an integer
Date: Mon, 08 Sep 2014 08:46:05 -0600 [thread overview]
Message-ID: <540DC12D.6090401@redhat.com> (raw)
In-Reply-To: <1410178693-23370-2-git-send-email-benoit.canet@nodalink.com>
[-- Attachment #1: Type: text/plain, Size: 2289 bytes --]
On 09/08/2014 06:18 AM, Benoît Canet wrote:
> We will want to reuse this define in the future by making it common to multiples
s/multiples/multiple/
> QEMU modules.
> It would be safer that this define be an integer so we avoid stranges float
s/stranges/strange/
> rounding errors.
> Do this conversion.
>
> Signed-off-by: Benoît Canet <benoit.canet@nodalink.com>
> ---
> include/qemu/throttle.h | 2 +-
> util/throttle.c | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h
> index b890613..8f9e611 100644
> --- a/include/qemu/throttle.h
> +++ b/include/qemu/throttle.h
> @@ -27,7 +27,7 @@
> #include "qemu-common.h"
> #include "qemu/timer.h"
>
> -#define NANOSECONDS_PER_SECOND 1000000000.0
> +#define NANOSECONDS_PER_SECOND 1000000000
This hunk is good.
>
> typedef enum {
> THROTTLE_BPS_TOTAL,
> diff --git a/util/throttle.c b/util/throttle.c
> index f976ac7..af8445a 100644
> --- a/util/throttle.c
> +++ b/util/throttle.c
> @@ -34,7 +34,7 @@ void throttle_leak_bucket(LeakyBucket *bkt, int64_t delta_ns)
> double leak;
>
> /* compute how much to leak */
> - leak = (bkt->avg * (double) delta_ns) / NANOSECONDS_PER_SECOND;
> + leak = (bkt->avg * (double) delta_ns) / (double) NANOSECONDS_PER_SECOND;
This hunk is spurious. With just your first hunk, it evaluates to the
following types via promotion rules:
(double * double) / int
double / int
double / double
double
so the explicit cast isn't changing anything.
>
> /* make the bucket leak */
> bkt->level = MAX(bkt->level - leak, 0);
> @@ -70,7 +70,7 @@ static void throttle_do_leak(ThrottleState *ts, int64_t now)
> */
> static int64_t throttle_do_compute_wait(double limit, double extra)
> {
> - double wait = extra * NANOSECONDS_PER_SECOND;
> + double wait = extra * (double) NANOSECONDS_PER_SECOND;
This hunk is also spurious. Again, with just your first hunk, it
evaluates through the following promotion rules:
double * int
double * double
double
and the cast isn't changing anything.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]
next prev parent reply other threads:[~2014-09-08 14:46 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-08 12:18 [Qemu-devel] [PATCH v2 0/3] Add the infrastructure that will be used to compute I/O accouting averages Benoît Canet
2014-09-08 12:18 ` [Qemu-devel] [PATCH v2 1/3] throttle: Make NANOSECONDS_PER_SECOND an integer Benoît Canet
2014-09-08 14:46 ` Eric Blake [this message]
2014-09-15 10:01 ` Markus Armbruster
2014-09-08 12:18 ` [Qemu-devel] [PATCH v2 2/3] timers: Move NANOSECONDS_PER_SECONDS to timer.h for future reuse Benoît Canet
2014-09-08 14:56 ` Eric Blake
2014-09-08 12:18 ` [Qemu-devel] [PATCH v2 3/3] util: Add an utility infrastructure used to compute an average on a time slice Benoît Canet
2014-09-08 14:29 ` Paolo Bonzini
2014-09-08 14:49 ` Benoît Canet
2014-09-08 15:09 ` Paolo Bonzini
2014-09-08 15:25 ` Benoît Canet
2014-09-15 11:13 ` Markus Armbruster
2014-09-15 11:41 ` Benoît Canet
2014-09-15 11:44 ` Benoît Canet
2014-09-24 13:26 ` Benoît Canet
2014-09-15 10:23 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=540DC12D.6090401@redhat.com \
--to=eblake@redhat.com \
--cc=benoit.canet@nodalink.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).