From patchwork Fri Oct 21 19:42:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 685243 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3t0x7S6YMBz9svs for ; Sat, 22 Oct 2016 06:48:35 +1100 (AEDT) Received: from localhost ([::1]:34108 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bxfnr-0001i6-4f for incoming@patchwork.ozlabs.org; Fri, 21 Oct 2016 15:48:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55379) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bxfi3-00058E-7i for qemu-devel@nongnu.org; Fri, 21 Oct 2016 15:42:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bxfi2-0007Uh-3D for qemu-devel@nongnu.org; Fri, 21 Oct 2016 15:42:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35488) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bxfi1-0007U0-RV for qemu-devel@nongnu.org; Fri, 21 Oct 2016 15:42:30 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 208708E672 for ; Fri, 21 Oct 2016 19:42:29 +0000 (UTC) Received: from emacs.mitica (ovpn-116-122.ams2.redhat.com [10.36.116.122]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9LJgLrb018033; Fri, 21 Oct 2016 15:42:27 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Oct 2016 21:42:06 +0200 Message-Id: <1477078935-7182-5-git-send-email-quintela@redhat.com> In-Reply-To: <1477078935-7182-1-git-send-email-quintela@redhat.com> References: <1477078935-7182-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 21 Oct 2016 19:42:29 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 04/13] migration: Create x-multifd-threads parameter X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amit.shah@redhat.com, dgilbert@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Indicates the number of threads that we would create. By default we create 2 threads. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- 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 #