[PATCH] migration: fix xbzrle encoding rate calculation

Wei Wang posted 1 patch 3 years, 11 months ago
Test docker-mingw@fedora passed
Test checkpatch passed
Test asan passed
Test docker-quick@centos7 passed
Test FreeBSD passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1591577607-13998-1-git-send-email-wei.w.wang@intel.com
Maintainers: "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Juan Quintela <quintela@redhat.com>
migration/ram.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
[PATCH] migration: fix xbzrle encoding rate calculation
Posted by Wei Wang 3 years, 11 months ago
It's reported an error of implicit conversion from "unsigned long" to
"double" when compiling with Clang 10. Simply make the encoding rate 0
when the encoded_size is 0.

Fixes: e460a4b1a4
Reported-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Wei Wang <wei.w.wang@intel.com>
---
 migration/ram.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/migration/ram.c b/migration/ram.c
index 41cc530..069b6e3 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -913,10 +913,8 @@ static void migration_update_rates(RAMState *rs, int64_t end_time)
         unencoded_size = (xbzrle_counters.pages - rs->xbzrle_pages_prev) *
                          TARGET_PAGE_SIZE;
         encoded_size = xbzrle_counters.bytes - rs->xbzrle_bytes_prev;
-        if (xbzrle_counters.pages == rs->xbzrle_pages_prev) {
+        if (xbzrle_counters.pages == rs->xbzrle_pages_prev || !encoded_size) {
             xbzrle_counters.encoding_rate = 0;
-        } else if (!encoded_size) {
-            xbzrle_counters.encoding_rate = UINT64_MAX;
         } else {
             xbzrle_counters.encoding_rate = unencoded_size / encoded_size;
         }
-- 
2.7.4


Re: [PATCH] migration: fix xbzrle encoding rate calculation
Posted by Richard Henderson 3 years, 11 months ago
On 6/7/20 5:53 PM, Wei Wang wrote:
> It's reported an error of implicit conversion from "unsigned long" to
> "double" when compiling with Clang 10. Simply make the encoding rate 0
> when the encoded_size is 0.
> 
> Fixes: e460a4b1a4
> Reported-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Wei Wang <wei.w.wang@intel.com>
> ---
>  migration/ram.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)

Queuing to a clang 10 fixes branch.


r~

Re: [PATCH] migration: fix xbzrle encoding rate calculation
Posted by Dr. David Alan Gilbert 3 years, 11 months ago
* Richard Henderson (richard.henderson@linaro.org) wrote:
> On 6/7/20 5:53 PM, Wei Wang wrote:
> > It's reported an error of implicit conversion from "unsigned long" to
> > "double" when compiling with Clang 10. Simply make the encoding rate 0
> > when the encoded_size is 0.
> > 
> > Fixes: e460a4b1a4
> > Reported-by: Richard Henderson <richard.henderson@linaro.org>
> > Signed-off-by: Wei Wang <wei.w.wang@intel.com>
> > ---
> >  migration/ram.c | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> Queuing to a clang 10 fixes branch.

Thanks

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

Dave


> 
> 
> r~
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


Re: [PATCH] migration: fix xbzrle encoding rate calculation
Posted by Richard Henderson 3 years, 11 months ago
On 6/7/20 5:53 PM, Wei Wang wrote:
> It's reported an error of implicit conversion from "unsigned long" to
> "double" when compiling with Clang 10. Simply make the encoding rate 0
> when the encoded_size is 0.
> 
> Fixes: e460a4b1a4
> Reported-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Wei Wang <wei.w.wang@intel.com>
> ---
>  migration/ram.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~