From: Wei Wang <wei.w.wang@intel.com>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: kevin.tian@intel.com, Juan Quintela <quintela@redhat.com>,
"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
Peter Xu <peterx@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
gloryxiao@tencent.com, yi.y.sun@intel.com
Subject: Re: [PATCH v3] migration/xbzrle: add encoding rate
Date: Thu, 04 Jun 2020 10:58:12 +0800 [thread overview]
Message-ID: <5ED86344.4020505@intel.com> (raw)
In-Reply-To: <CAFXwXrm4R5nxk6ruTJ2kP5dUnF7Qm3TfRRiKVAUDNA1uwYf65w@mail.gmail.com>
On 06/04/2020 03:28 AM, Richard Henderson wrote:
> On Wed, 29 Apr 2020 at 18:54, Wei Wang <wei.w.wang@intel.com> wrote:
>> + if (xbzrle_counters.pages == rs->xbzrle_pages_prev) {
>> + xbzrle_counters.encoding_rate = 0;
>> + } else if (!encoded_size) {
>> + xbzrle_counters.encoding_rate = UINT64_MAX;
>> + } else {
>> + xbzrle_counters.encoding_rate = unencoded_size / encoded_size;
>> + }
> With clang 10, this produces
>
> CC aarch64-softmmu/migration/ram.o
> /home/rth/qemu/qemu/migration/ram.c:919:45: error: implicit conversion
> from 'unsigned long' to 'double' changes value from
> 18446744073709551615 to 18446744073709551616
> [-Werror,-Wimplicit-int-float-conversion]
> xbzrle_counters.encoding_rate = UINT64_MAX;
> ~ ^~~~~~~~~~
> /usr/include/stdint.h:130:23: note: expanded from macro 'UINT64_MAX'
> # define UINT64_MAX (__UINT64_C(18446744073709551615))
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /usr/include/stdint.h:107:25: note: expanded from macro '__UINT64_C'
> # define __UINT64_C(c) c ## UL
> ^~~~~~~
> <scratch space>:36:1: note: expanded from here
> 18446744073709551615UL
> ^~~~~~~~~~~~~~~~~~~~~~
> 1 error generated.
>
> UINT64_MAX apprears both arbitrary and wrong.
>
> The only way I can imagine encoded_size == 0 is unencoded_size == 0,
> so 0 seems like the correct answer. Moreover, it really seems like
> the first test sufficiently covers that possibility.
It is possible that encoded_size==0, but unencoded_size !=0. For example,
a page is written with the same data that it already has.
>
> In addition, the only user of this value is
>
>> + monitor_printf(mon, "xbzrle encoding rate: %0.2f\n",
>> + info->xbzrle_cache->encoding_rate);
> which would be quite happy to print NaN even if the 0/0 computation
> were to run. Though as I say above, I don't think that's reachable.
The encoding_rate is expected to reflect if the page is xbzrle encoding
friendly.
The larger, the more friendly, so 0 might not be a good representation here.
Maybe, we could change UINT64_MAX above to "~0ULL" to avoid the issue?
Best,
Wei
next prev parent reply other threads:[~2020-06-04 2:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-30 0:59 [PATCH v3] migration/xbzrle: add encoding rate Wei Wang
2020-04-30 9:00 ` Dr. David Alan Gilbert
2020-05-07 15:53 ` Dr. David Alan Gilbert
2020-06-03 19:28 ` Richard Henderson
2020-06-04 2:58 ` Wei Wang [this message]
2020-06-04 3:22 ` Richard Henderson
2020-06-04 6:46 ` Wei Wang
2020-06-04 9:38 ` Dr. David Alan Gilbert
2020-06-04 10:27 ` Wei Wang
2020-06-04 16:57 ` Richard Henderson
2020-06-05 2:04 ` Wei Wang
2020-06-05 9:25 ` Dr. David Alan Gilbert
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=5ED86344.4020505@intel.com \
--to=wei.w.wang@intel.com \
--cc=dgilbert@redhat.com \
--cc=gloryxiao@tencent.com \
--cc=kevin.tian@intel.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=richard.henderson@linaro.org \
--cc=yi.y.sun@intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.