diff mbox

[04/13] migration: Create x-multifd-threads parameter

Message ID 1477078935-7182-5-git-send-email-quintela@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Juan Quintela Oct. 21, 2016, 7:42 p.m. UTC
Indicates the number of threads that we would create.  By default we
create 2 threads.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hmp.c                         |  7 +++++++
 include/migration/migration.h |  2 ++
 migration/migration.c         | 24 ++++++++++++++++++++++++
 qapi-schema.json              | 11 +++++++++--
 4 files changed, 42 insertions(+), 2 deletions(-)

Comments

Dr. David Alan Gilbert Oct. 26, 2016, 6:33 p.m. UTC | #1
* Juan Quintela (quintela@redhat.com) wrote:
> Indicates the number of threads that we would create.  By default we
> create 2 threads.
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>

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

> ---
>  hmp.c                         |  7 +++++++
>  include/migration/migration.h |  2 ++
>  migration/migration.c         | 24 ++++++++++++++++++++++++
>  qapi-schema.json              | 11 +++++++++--
>  4 files changed, 42 insertions(+), 2 deletions(-)
> 
> diff --git a/hmp.c b/hmp.c
> index 80f7f1f..54f9f03 100644
> --- a/hmp.c
> +++ b/hmp.c
> @@ -318,6 +318,9 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
>          monitor_printf(mon, " %s: %" PRId64 " milliseconds",
>              MigrationParameter_lookup[MIGRATION_PARAMETER_DOWNTIME_LIMIT],
>              params->downtime_limit);
> +        monitor_printf(mon, " %s: %" PRId64,
> +            MigrationParameter_lookup[MIGRATION_PARAMETER_X_MULTIFD_THREADS],
> +            params->x_multifd_threads);
>          monitor_printf(mon, "\n");
>      }
> 
> @@ -1386,6 +1389,9 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
>                  p.has_downtime_limit = true;
>                  use_int_value = true;
>                  break;
> +            case MIGRATION_PARAMETER_X_MULTIFD_THREADS:
> +                p.has_x_multifd_threads = true;
> +                break;
>              }
> 
>              if (use_int_value) {
> @@ -1402,6 +1408,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
>                  p.cpu_throttle_initial = valueint;
>                  p.cpu_throttle_increment = valueint;
>                  p.downtime_limit = valueint;
> +                p.x_multifd_threads = valueint;
>              }
> 
>              qmp_migrate_set_parameters(&p, &err);
> diff --git a/include/migration/migration.h b/include/migration/migration.h
> index 5666068..709355e 100644
> --- a/include/migration/migration.h
> +++ b/include/migration/migration.h
> @@ -240,6 +240,8 @@ bool migration_in_postcopy(MigrationState *);
>  bool migration_in_postcopy_after_devices(MigrationState *);
>  MigrationState *migrate_get_current(void);
> 
> +int migrate_multifd_threads(void);
> +
>  void migrate_compress_threads_create(void);
>  void migrate_compress_threads_join(void);
>  void migrate_decompress_threads_create(void);
> diff --git a/migration/migration.c b/migration/migration.c
> index 5f7a570..217ccbc 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -62,6 +62,8 @@
>  /* Migration XBZRLE default cache size */
>  #define DEFAULT_MIGRATE_CACHE_SIZE (64 * 1024 * 1024)
> 
> +#define DEFAULT_MIGRATE_MULTIFD_THREADS 2
> +
>  static NotifierList migration_state_notifiers =
>      NOTIFIER_LIST_INITIALIZER(migration_state_notifiers);
> 
> @@ -94,6 +96,7 @@ MigrationState *migrate_get_current(void)
>              .cpu_throttle_increment = DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT,
>              .max_bandwidth = MAX_THROTTLE,
>              .downtime_limit = DEFAULT_MIGRATE_SET_DOWNTIME,
> +            .x_multifd_threads = DEFAULT_MIGRATE_MULTIFD_THREADS,
>          },
>      };
> 
> @@ -567,6 +570,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp)
>      params->max_bandwidth = s->parameters.max_bandwidth;
>      params->has_downtime_limit = true;
>      params->downtime_limit = s->parameters.downtime_limit;
> +    params->has_x_multifd_threads = true;
> +    params->x_multifd_threads = s->parameters.x_multifd_threads;
> 
>      return params;
>  }
> @@ -813,6 +818,13 @@ void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp)
>                     "an integer in the range of 0 to 2000000 milliseconds");
>          return;
>      }
> +    if (params->has_x_multifd_threads &&
> +            (params->x_multifd_threads < 1 || params->x_multifd_threads > 255)) {
> +        error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
> +                   "multifd_threads",
> +                   "is invalid, it should be in the range of 1 to 255");
> +        return;
> +    }
> 
>      if (params->has_compress_level) {
>          s->parameters.compress_level = params->compress_level;
> @@ -847,6 +859,9 @@ void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp)
>      if (params->has_downtime_limit) {
>          s->parameters.downtime_limit = params->downtime_limit;
>      }
> +    if (params->has_x_multifd_threads) {
> +        s->parameters.x_multifd_threads = params->x_multifd_threads;
> +    }
>  }
> 
> 
> @@ -1282,6 +1297,15 @@ bool migrate_multifd(void)
>      return s->enabled_capabilities[MIGRATION_CAPABILITY_X_MULTIFD];
>  }
> 
> +int migrate_multifd_threads(void)
> +{
> +    MigrationState *s;
> +
> +    s = migrate_get_current();
> +
> +    return s->parameters.x_multifd_threads;
> +}
> +
>  int migrate_use_xbzrle(void)
>  {
>      MigrationState *s;
> diff --git a/qapi-schema.json b/qapi-schema.json
> index bc96ee4..b5c9a06 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -665,13 +665,16 @@
>  # @downtime-limit: set maximum tolerated downtime for migration. maximum
>  #                  downtime in milliseconds (Since 2.8)
>  #
> +# @x-multifd-threads: Number of threads used to migrate data in parallel
> +#                     The default value is 1 (since 2.8)
> +#
>  # Since: 2.4
>  ##
>  { 'enum': 'MigrationParameter',
>    'data': ['compress-level', 'compress-threads', 'decompress-threads',
>             'cpu-throttle-initial', 'cpu-throttle-increment',
>             'tls-creds', 'tls-hostname', 'max-bandwidth',
> -           'downtime-limit'] }
> +           'downtime-limit', 'x-multifd-threads'] }
> 
>  #
>  # @migrate-set-parameters
> @@ -726,6 +729,9 @@
>  # @downtime-limit: set maximum tolerated downtime for migration. maximum
>  #                  downtime in milliseconds (Since 2.8)
>  #
> +# @x-multifd-threads: Number of threads used to migrate data in parallel
> +#                     The default value is 1 (since 2.8)
> +#
>  # Since: 2.4
>  ##
>  { 'struct': 'MigrationParameters',
> @@ -737,7 +743,8 @@
>              '*tls-creds': 'str',
>              '*tls-hostname': 'str',
>              '*max-bandwidth': 'int',
> -            '*downtime-limit': 'int'} }
> +            '*downtime-limit': 'int',
> +            '*x-multifd-threads': 'int'} }
>  ##
>  # @query-migrate-parameters
>  #
> -- 
> 2.7.4
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
Eric Blake Oct. 26, 2016, 9:16 p.m. UTC | #2
On 10/21/2016 02:42 PM, Juan Quintela wrote:
> Indicates the number of threads that we would create.  By default we
> create 2 threads.
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---

> @@ -1386,6 +1389,9 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
>                  p.has_downtime_limit = true;
>                  use_int_value = true;
>                  break;
> +            case MIGRATION_PARAMETER_X_MULTIFD_THREADS:
> +                p.has_x_multifd_threads = true;
> +                break;

Won't work unless you add a line 'use_int_value = true;'

>              }
> 
>              if (use_int_value) {
> @@ -1402,6 +1408,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
>                  p.cpu_throttle_initial = valueint;
>                  p.cpu_throttle_increment = valueint;
>                  p.downtime_limit = valueint;
> +                p.x_multifd_threads = valueint;
>              }

See also commit bb2b777 as a regression fix for a missing use_int_value.

> +++ b/qapi-schema.json
> @@ -665,13 +665,16 @@
>  # @downtime-limit: set maximum tolerated downtime for migration. maximum
>  #                  downtime in milliseconds (Since 2.8)
>  #
> +# @x-multifd-threads: Number of threads used to migrate data in parallel
> +#                     The default value is 1 (since 2.8)
> +#
>  # Since: 2.4
>  ##
>  { 'enum': 'MigrationParameter',
>    'data': ['compress-level', 'compress-threads', 'decompress-threads',
>             'cpu-throttle-initial', 'cpu-throttle-increment',
>             'tls-creds', 'tls-hostname', 'max-bandwidth',
> -           'downtime-limit'] }
> +           'downtime-limit', 'x-multifd-threads'] }
> 
>  #
>  # @migrate-set-parameters
> @@ -726,6 +729,9 @@
>  # @downtime-limit: set maximum tolerated downtime for migration. maximum
>  #                  downtime in milliseconds (Since 2.8)
>  #
> +# @x-multifd-threads: Number of threads used to migrate data in parallel
> +#                     The default value is 1 (since 2.8)

Pre-existing in the other parameters, but we have an inconsistent use of
#optional markers here.

> +#
>  # Since: 2.4
>  ##
>  { 'struct': 'MigrationParameters',
> @@ -737,7 +743,8 @@
>              '*tls-creds': 'str',
>              '*tls-hostname': 'str',
>              '*max-bandwidth': 'int',
> -            '*downtime-limit': 'int'} }
> +            '*downtime-limit': 'int',
> +            '*x-multifd-threads': 'int'} }
>  ##
>  # @query-migrate-parameters
>  #
>
diff mbox

Patch

diff --git a/hmp.c b/hmp.c
index 80f7f1f..54f9f03 100644
--- a/hmp.c
+++ b/hmp.c
@@ -318,6 +318,9 @@  void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
         monitor_printf(mon, " %s: %" PRId64 " milliseconds",
             MigrationParameter_lookup[MIGRATION_PARAMETER_DOWNTIME_LIMIT],
             params->downtime_limit);
+        monitor_printf(mon, " %s: %" PRId64,
+            MigrationParameter_lookup[MIGRATION_PARAMETER_X_MULTIFD_THREADS],
+            params->x_multifd_threads);
         monitor_printf(mon, "\n");
     }

@@ -1386,6 +1389,9 @@  void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
                 p.has_downtime_limit = true;
                 use_int_value = true;
                 break;
+            case MIGRATION_PARAMETER_X_MULTIFD_THREADS:
+                p.has_x_multifd_threads = true;
+                break;
             }

             if (use_int_value) {
@@ -1402,6 +1408,7 @@  void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
                 p.cpu_throttle_initial = valueint;
                 p.cpu_throttle_increment = valueint;
                 p.downtime_limit = valueint;
+                p.x_multifd_threads = valueint;
             }

             qmp_migrate_set_parameters(&p, &err);
diff --git a/include/migration/migration.h b/include/migration/migration.h
index 5666068..709355e 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -240,6 +240,8 @@  bool migration_in_postcopy(MigrationState *);
 bool migration_in_postcopy_after_devices(MigrationState *);
 MigrationState *migrate_get_current(void);

+int migrate_multifd_threads(void);
+
 void migrate_compress_threads_create(void);
 void migrate_compress_threads_join(void);
 void migrate_decompress_threads_create(void);
diff --git a/migration/migration.c b/migration/migration.c
index 5f7a570..217ccbc 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -62,6 +62,8 @@ 
 /* Migration XBZRLE default cache size */
 #define DEFAULT_MIGRATE_CACHE_SIZE (64 * 1024 * 1024)

+#define DEFAULT_MIGRATE_MULTIFD_THREADS 2
+
 static NotifierList migration_state_notifiers =
     NOTIFIER_LIST_INITIALIZER(migration_state_notifiers);

@@ -94,6 +96,7 @@  MigrationState *migrate_get_current(void)
             .cpu_throttle_increment = DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT,
             .max_bandwidth = MAX_THROTTLE,
             .downtime_limit = DEFAULT_MIGRATE_SET_DOWNTIME,
+            .x_multifd_threads = DEFAULT_MIGRATE_MULTIFD_THREADS,
         },
     };

@@ -567,6 +570,8 @@  MigrationParameters *qmp_query_migrate_parameters(Error **errp)
     params->max_bandwidth = s->parameters.max_bandwidth;
     params->has_downtime_limit = true;
     params->downtime_limit = s->parameters.downtime_limit;
+    params->has_x_multifd_threads = true;
+    params->x_multifd_threads = s->parameters.x_multifd_threads;

     return params;
 }
@@ -813,6 +818,13 @@  void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp)
                    "an integer in the range of 0 to 2000000 milliseconds");
         return;
     }
+    if (params->has_x_multifd_threads &&
+            (params->x_multifd_threads < 1 || params->x_multifd_threads > 255)) {
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+                   "multifd_threads",
+                   "is invalid, it should be in the range of 1 to 255");
+        return;
+    }

     if (params->has_compress_level) {
         s->parameters.compress_level = params->compress_level;
@@ -847,6 +859,9 @@  void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp)
     if (params->has_downtime_limit) {
         s->parameters.downtime_limit = params->downtime_limit;
     }
+    if (params->has_x_multifd_threads) {
+        s->parameters.x_multifd_threads = params->x_multifd_threads;
+    }
 }


@@ -1282,6 +1297,15 @@  bool migrate_multifd(void)
     return s->enabled_capabilities[MIGRATION_CAPABILITY_X_MULTIFD];
 }

+int migrate_multifd_threads(void)
+{
+    MigrationState *s;
+
+    s = migrate_get_current();
+
+    return s->parameters.x_multifd_threads;
+}
+
 int migrate_use_xbzrle(void)
 {
     MigrationState *s;
diff --git a/qapi-schema.json b/qapi-schema.json
index bc96ee4..b5c9a06 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -665,13 +665,16 @@ 
 # @downtime-limit: set maximum tolerated downtime for migration. maximum
 #                  downtime in milliseconds (Since 2.8)
 #
+# @x-multifd-threads: Number of threads used to migrate data in parallel
+#                     The default value is 1 (since 2.8)
+#
 # Since: 2.4
 ##
 { 'enum': 'MigrationParameter',
   'data': ['compress-level', 'compress-threads', 'decompress-threads',
            'cpu-throttle-initial', 'cpu-throttle-increment',
            'tls-creds', 'tls-hostname', 'max-bandwidth',
-           'downtime-limit'] }
+           'downtime-limit', 'x-multifd-threads'] }

 #
 # @migrate-set-parameters
@@ -726,6 +729,9 @@ 
 # @downtime-limit: set maximum tolerated downtime for migration. maximum
 #                  downtime in milliseconds (Since 2.8)
 #
+# @x-multifd-threads: Number of threads used to migrate data in parallel
+#                     The default value is 1 (since 2.8)
+#
 # Since: 2.4
 ##
 { 'struct': 'MigrationParameters',
@@ -737,7 +743,8 @@ 
             '*tls-creds': 'str',
             '*tls-hostname': 'str',
             '*max-bandwidth': 'int',
-            '*downtime-limit': 'int'} }
+            '*downtime-limit': 'int',
+            '*x-multifd-threads': 'int'} }
 ##
 # @query-migrate-parameters
 #