Patchwork [4/4] migration: calculate expected_downtime

login
register
mail settings
Submitter Juan Quintela
Date Feb. 1, 2013, 12:32 p.m.
Message ID <1359721976-19238-5-git-send-email-quintela@redhat.com>
Download mbox | patch
Permalink /patch/217454/
State New
Headers show

Comments

Juan Quintela - Feb. 1, 2013, 12:32 p.m.
We removed the calculation in commit e4ed1541ac9413eac494a03532e34beaf8a7d1c5

Now we add it back.  We need to create dirty_bytes_rate because we
can't include cpu-all.h from migration.c, and there is no other way to
include TARGET_PAGE_SIZE.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 arch_init.c                   | 1 +
 include/migration/migration.h | 1 +
 migration.c                   | 5 +++++
 3 files changed, 7 insertions(+)
Orit Wasserman - Feb. 4, 2013, 12:53 p.m.
On 02/01/2013 02:32 PM, Juan Quintela wrote:
> We removed the calculation in commit e4ed1541ac9413eac494a03532e34beaf8a7d1c5
> 
> Now we add it back.  We need to create dirty_bytes_rate because we
> can't include cpu-all.h from migration.c, and there is no other way to
> include TARGET_PAGE_SIZE.
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  arch_init.c                   | 1 +
>  include/migration/migration.h | 1 +
>  migration.c                   | 5 +++++
>  3 files changed, 7 insertions(+)
> 
> diff --git a/arch_init.c b/arch_init.c
> index dada6de..634490a 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -414,6 +414,7 @@ static void migration_bitmap_sync(void)
>      if (end_time > start_time + 1000) {
>          s->dirty_pages_rate = num_dirty_pages_period * 1000
>              / (end_time - start_time);
> +        s->dirty_bytes_rate = s->dirty_pages_rate * TARGET_PAGE_SIZE;
>          start_time = end_time;
>          num_dirty_pages_period = 0;
>      }
> diff --git a/include/migration/migration.h b/include/migration/migration.h
> index a8c9639..d121409 100644
> --- a/include/migration/migration.h
> +++ b/include/migration/migration.h
> @@ -51,6 +51,7 @@ struct MigrationState
>      int64_t downtime;
>      int64_t expected_downtime;
>      int64_t dirty_pages_rate;
> +    int64_t dirty_bytes_rate;
>      bool enabled_capabilities[MIGRATION_CAPABILITY_MAX];
>      int64_t xbzrle_cache_size;
>      bool complete;
> diff --git a/migration.c b/migration.c
> index 64e75ca..4eca42e 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -746,6 +746,11 @@ static void *buffered_file_thread(void *opaque)
>              DPRINTF("transferred %" PRIu64 " time_spent %" PRIu64
>                      " bandwidth %g max_size %" PRId64 "\n",
>                      transferred_bytes, time_spent, bandwidth, max_size);
> +            /* if we haven't sent anything, we don't want to recalculate
> +               10000 is a small enough number for our purposes */
> +            if (s->dirty_bytes_rate && transferred_bytes > 10000) {
> +                s->expected_downtime = s->dirty_bytes_rate / bandwidth;
> +            }
> 
>              s->bytes_xfer = 0;
>              sleep_time = 0;
> 
Reviewed-by: Orit Wasserman <owasserm@redhat.com>

Patch

diff --git a/arch_init.c b/arch_init.c
index dada6de..634490a 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -414,6 +414,7 @@  static void migration_bitmap_sync(void)
     if (end_time > start_time + 1000) {
         s->dirty_pages_rate = num_dirty_pages_period * 1000
             / (end_time - start_time);
+        s->dirty_bytes_rate = s->dirty_pages_rate * TARGET_PAGE_SIZE;
         start_time = end_time;
         num_dirty_pages_period = 0;
     }
diff --git a/include/migration/migration.h b/include/migration/migration.h
index a8c9639..d121409 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -51,6 +51,7 @@  struct MigrationState
     int64_t downtime;
     int64_t expected_downtime;
     int64_t dirty_pages_rate;
+    int64_t dirty_bytes_rate;
     bool enabled_capabilities[MIGRATION_CAPABILITY_MAX];
     int64_t xbzrle_cache_size;
     bool complete;
diff --git a/migration.c b/migration.c
index 64e75ca..4eca42e 100644
--- a/migration.c
+++ b/migration.c
@@ -746,6 +746,11 @@  static void *buffered_file_thread(void *opaque)
             DPRINTF("transferred %" PRIu64 " time_spent %" PRIu64
                     " bandwidth %g max_size %" PRId64 "\n",
                     transferred_bytes, time_spent, bandwidth, max_size);
+            /* if we haven't sent anything, we don't want to recalculate
+               10000 is a small enough number for our purposes */
+            if (s->dirty_bytes_rate && transferred_bytes > 10000) {
+                s->expected_downtime = s->dirty_bytes_rate / bandwidth;
+            }

             s->bytes_xfer = 0;
             sleep_time = 0;