[Qemu-devel] [PATCH 08/31] ram: Move iterations_prev into RAMState

Juan Quintela posted 31 patches 8 years, 7 months ago
There is a newer version of this series
[Qemu-devel] [PATCH 08/31] ram: Move iterations_prev into RAMState
Posted by Juan Quintela 8 years, 7 months ago
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 migration/ram.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/migration/ram.c b/migration/ram.c
index ae077c5..6cdad06 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -157,6 +157,8 @@ struct RAMState {
     int64_t num_dirty_pages_period;
     /* xbzrle misses since the beggining of the period */
     uint64_t xbzrle_cache_miss_prev;
+    /* number of iterations at the beggining of period */
+    uint64_t iterations_prev;
 };
 typedef struct RAMState RAMState;
 
@@ -602,16 +604,13 @@ static void migration_bitmap_sync_range(ram_addr_t start, ram_addr_t length)
         cpu_physical_memory_sync_dirty_bitmap(bitmap, start, length);
 }
 
-/* Fix me: there are too many global variables used in migration process. */
-static uint64_t iterations_prev;
-
 static void migration_bitmap_sync_init(RAMState *rs)
 {
     rs->start_time = 0;
     rs->bytes_xfer_prev = 0;
     rs->num_dirty_pages_period = 0;
     rs->xbzrle_cache_miss_prev = 0;
-    iterations_prev = 0;
+    rs->iterations_prev = 0;
 }
 
 /* Returns a summary bitmap of the page sizes of all RAMBlocks;
@@ -687,13 +686,13 @@ static void migration_bitmap_sync(RAMState *rs)
         }
 
         if (migrate_use_xbzrle()) {
-            if (iterations_prev != acct_info.iterations) {
+            if (rs->iterations_prev != acct_info.iterations) {
                 acct_info.xbzrle_cache_miss_rate =
                    (double)(acct_info.xbzrle_cache_miss -
                             rs->xbzrle_cache_miss_prev) /
-                   (acct_info.iterations - iterations_prev);
+                   (acct_info.iterations - rs->iterations_prev);
             }
-            iterations_prev = acct_info.iterations;
+            rs->iterations_prev = acct_info.iterations;
             rs->xbzrle_cache_miss_prev = acct_info.xbzrle_cache_miss;
         }
         s->dirty_pages_rate = rs->num_dirty_pages_period * 1000
-- 
2.9.3


Re: [Qemu-devel] [PATCH 08/31] ram: Move iterations_prev into RAMState
Posted by Dr. David Alan Gilbert 8 years, 7 months ago
* Juan Quintela (quintela@redhat.com) wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  migration/ram.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/migration/ram.c b/migration/ram.c
> index ae077c5..6cdad06 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -157,6 +157,8 @@ struct RAMState {
>      int64_t num_dirty_pages_period;
>      /* xbzrle misses since the beggining of the period */
>      uint64_t xbzrle_cache_miss_prev;
> +    /* number of iterations at the beggining of period */
                                         ^  ^ 
                                         One extra g, one missing n

Other than that,
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> +    uint64_t iterations_prev;
>  };
>  typedef struct RAMState RAMState;
>  
> @@ -602,16 +604,13 @@ static void migration_bitmap_sync_range(ram_addr_t start, ram_addr_t length)
>          cpu_physical_memory_sync_dirty_bitmap(bitmap, start, length);
>  }
>  
> -/* Fix me: there are too many global variables used in migration process. */
> -static uint64_t iterations_prev;
> -
>  static void migration_bitmap_sync_init(RAMState *rs)
>  {
>      rs->start_time = 0;
>      rs->bytes_xfer_prev = 0;
>      rs->num_dirty_pages_period = 0;
>      rs->xbzrle_cache_miss_prev = 0;
> -    iterations_prev = 0;
> +    rs->iterations_prev = 0;
>  }
>  
>  /* Returns a summary bitmap of the page sizes of all RAMBlocks;
> @@ -687,13 +686,13 @@ static void migration_bitmap_sync(RAMState *rs)
>          }
>  
>          if (migrate_use_xbzrle()) {
> -            if (iterations_prev != acct_info.iterations) {
> +            if (rs->iterations_prev != acct_info.iterations) {
>                  acct_info.xbzrle_cache_miss_rate =
>                     (double)(acct_info.xbzrle_cache_miss -
>                              rs->xbzrle_cache_miss_prev) /
> -                   (acct_info.iterations - iterations_prev);
> +                   (acct_info.iterations - rs->iterations_prev);
>              }
> -            iterations_prev = acct_info.iterations;
> +            rs->iterations_prev = acct_info.iterations;
>              rs->xbzrle_cache_miss_prev = acct_info.xbzrle_cache_miss;
>          }
>          s->dirty_pages_rate = rs->num_dirty_pages_period * 1000
> -- 
> 2.9.3
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

Re: [Qemu-devel] [PATCH 08/31] ram: Move iterations_prev into RAMState
Posted by Philippe Mathieu-Daudé 8 years, 7 months ago
On 03/16/2017 09:26 AM, Dr. David Alan Gilbert wrote:
> * Juan Quintela (quintela@redhat.com) wrote:
>> Signed-off-by: Juan Quintela <quintela@redhat.com>
>> ---
>>  migration/ram.c | 13 ++++++-------
>>  1 file changed, 6 insertions(+), 7 deletions(-)
>>
>> diff --git a/migration/ram.c b/migration/ram.c
>> index ae077c5..6cdad06 100644
>> --- a/migration/ram.c
>> +++ b/migration/ram.c
>> @@ -157,6 +157,8 @@ struct RAMState {
>>      int64_t num_dirty_pages_period;
>>      /* xbzrle misses since the beggining of the period */
>>      uint64_t xbzrle_cache_miss_prev;
>> +    /* number of iterations at the beggining of period */
>                                          ^  ^
>                                          One extra g, one missing n
>
> Other than that,
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

>> +    uint64_t iterations_prev;
>>  };
>>  typedef struct RAMState RAMState;
>>
>> @@ -602,16 +604,13 @@ static void migration_bitmap_sync_range(ram_addr_t start, ram_addr_t length)
>>          cpu_physical_memory_sync_dirty_bitmap(bitmap, start, length);
>>  }
>>
>> -/* Fix me: there are too many global variables used in migration process. */
>> -static uint64_t iterations_prev;
>> -
>>  static void migration_bitmap_sync_init(RAMState *rs)
>>  {
>>      rs->start_time = 0;
>>      rs->bytes_xfer_prev = 0;
>>      rs->num_dirty_pages_period = 0;
>>      rs->xbzrle_cache_miss_prev = 0;
>> -    iterations_prev = 0;
>> +    rs->iterations_prev = 0;
>>  }
>>
>>  /* Returns a summary bitmap of the page sizes of all RAMBlocks;
>> @@ -687,13 +686,13 @@ static void migration_bitmap_sync(RAMState *rs)
>>          }
>>
>>          if (migrate_use_xbzrle()) {
>> -            if (iterations_prev != acct_info.iterations) {
>> +            if (rs->iterations_prev != acct_info.iterations) {
>>                  acct_info.xbzrle_cache_miss_rate =
>>                     (double)(acct_info.xbzrle_cache_miss -
>>                              rs->xbzrle_cache_miss_prev) /
>> -                   (acct_info.iterations - iterations_prev);
>> +                   (acct_info.iterations - rs->iterations_prev);
>>              }
>> -            iterations_prev = acct_info.iterations;
>> +            rs->iterations_prev = acct_info.iterations;
>>              rs->xbzrle_cache_miss_prev = acct_info.xbzrle_cache_miss;
>>          }
>>          s->dirty_pages_rate = rs->num_dirty_pages_period * 1000
>> --
>> 2.9.3
>>
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
>