Received: by 2002:a05:6512:3aa:0:0:0:0 with SMTP id v10csp1386058lfp; Thu, 13 Feb 2020 19:29:09 -0800 (PST) X-Google-Smtp-Source: APXvYqzzsUFhGTAVHMbimDqVXFyh4SDEjjl22ZiHA/qWTyaXIr4t8UShUN5H4mWb9ossNSLWAFLS X-Received: by 2002:ac8:340d:: with SMTP id u13mr1015715qtb.114.1581650949575; Thu, 13 Feb 2020 19:29:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581650949; cv=none; d=google.com; s=arc-20160816; b=CmgigLv+t+zyR7ewJNLMqwjwgJySGAq2yw8y1y+TzqS40YjgatpuB+8rUBLBOVo4Uo XY4qcEvoIxKSL1mLOCskQdL1rVGBox+UcKdQcL9I5D5rU9X+Ml8v2QrpQ9LwDP8B9VmD F0ZiYXaJhkNytf4VJuI8WZK3wTLMN7UZ/7ag017kialltt162Ho0wbgQHit/0lnBqYbl PSQwSMhq6XMvO835zm63X6jy0Cbnr8SsAcxhxogNg3faUf6AEC5CyRYOyDc4APL50yQ2 fkGVQaTDFAu1FibTXdvcdkb1RGS68qeJ8JxS2THRWyjnQ960L/CklufQvGAQeWV+9mHP dydQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from; bh=VqBod+GQP5VGxS8piHpb7wjvI2dWSKiITo7W4akJUo0=; b=ywd+NzDRoCRUnS3amSNEDOfkuDdRv444C9zvAsrJQJeDFmwnhUumRUSuf2qmXcVpWf ckt2kwQsoFiuj2xMHNmOVKdeVc3BtSKSJnRT/bpUOol3lBm0OL3VDvR8yxjQ5kttrdwO aFuyAEMlu/9BIx0p1JgPmEIy47quYtF5OBPgG/h+JK8ZMRGvamnwKZ+hPOuL3e7qT4j/ nMUbxZ+u/EYhvhccOMgG1V8v6t52So+8FgzZwuYeitub5ithAHO6UUKL9C5pLNDW+Ez6 Q7r4KhJ9jCIiR938Mg33nRP5d+9Txqahm5KGIbKpXtukY22ac81buHAIRZ3u1gl+Ja7z 2r0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w8si791405qtn.359.2020.02.13.19.29.09 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Feb 2020 19:29:09 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org" Received: from localhost ([::1]:34236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2RfA-00080X-Vb for alex.bennee@linaro.org; Thu, 13 Feb 2020 22:29:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45717) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2Rf2-00080A-Az for qemu-arm@nongnu.org; Thu, 13 Feb 2020 22:29:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2Rf0-0005I4-Lh for qemu-arm@nongnu.org; Thu, 13 Feb 2020 22:29:00 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:2707 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j2Rf0-0004nN-2x; Thu, 13 Feb 2020 22:28:58 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 34CABA5DAE5ECF7882FD; Fri, 14 Feb 2020 11:28:47 +0800 (CST) Received: from linux-TFkxOR.huawei.com (10.175.104.212) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Fri, 14 Feb 2020 11:28:41 +0800 From: Keqian Zhu To: Subject: [PATCH] migration/throttle: Make throttle slower at tail stage Date: Fri, 14 Feb 2020 11:27:00 +0800 Message-ID: <20200214032700.25011-1-zhukeqian1@huawei.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.104.212] X-CFilter-Loop: Reflected Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 45.249.212.190 X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juan Quintela , Eric Blake , "Dr. David Alan Gilbert" , Markus Armbruster , qemu-arm@nongnu.org, wanghaibin.wang@huawei.com, Keqian Zhu Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-arm" X-TUID: xihsL5t4ZODp At the tail stage of throttle, VM is very sensitive to CPU percentage. We just throttle 30% of remaining CPU when throttle is more than 80 percentage. This doesn't conflict with cpu_throttle_increment. This may make migration time longer, and is disabled by default. Signed-off-by: Keqian Zhu --- Cc: Juan Quintela Cc: "Dr. David Alan Gilbert" Cc: Eric Blake Cc: Markus Armbruster --- migration/migration.c | 13 +++++++++++++ migration/ram.c | 18 ++++++++++++++++-- monitor/hmp-cmds.c | 4 ++++ qapi/migration.json | 21 +++++++++++++++++++++ 4 files changed, 54 insertions(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 3a21a4686c..37b569cee9 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -782,6 +782,8 @@ MigrationParameters *qmp_query_migrate_parameters(Err= or **errp) params->cpu_throttle_initial =3D s->parameters.cpu_throttle_initial; params->has_cpu_throttle_increment =3D true; params->cpu_throttle_increment =3D s->parameters.cpu_throttle_increm= ent; + params->has_cpu_throttle_tailslow =3D true; + params->cpu_throttle_tailslow =3D s->parameters.cpu_throttle_tailslo= w; params->has_tls_creds =3D true; params->tls_creds =3D g_strdup(s->parameters.tls_creds); params->has_tls_hostname =3D true; @@ -1287,6 +1289,10 @@ static void migrate_params_test_apply(MigrateSetPa= rameters *params, dest->cpu_throttle_increment =3D params->cpu_throttle_increment; } =20 + if (params->has_cpu_throttle_tailslow) { + dest->cpu_throttle_tailslow =3D params->cpu_throttle_tailslow; + } + if (params->has_tls_creds) { assert(params->tls_creds->type =3D=3D QTYPE_QSTRING); dest->tls_creds =3D g_strdup(params->tls_creds->u.s); @@ -1368,6 +1374,10 @@ static void migrate_params_apply(MigrateSetParamet= ers *params, Error **errp) s->parameters.cpu_throttle_increment =3D params->cpu_throttle_in= crement; } =20 + if (params->has_cpu_throttle_tailslow) { + s->parameters.cpu_throttle_tailslow =3D params->cpu_throttle_tai= lslow; + } + if (params->has_tls_creds) { g_free(s->parameters.tls_creds); assert(params->tls_creds->type =3D=3D QTYPE_QSTRING); @@ -3504,6 +3514,8 @@ static Property migration_properties[] =3D { DEFINE_PROP_UINT8("x-cpu-throttle-increment", MigrationState, parameters.cpu_throttle_increment, DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT), + DEFINE_PROP_BOOL("x-cpu-throttle-tailslow", MigrationState, + parameters.cpu_throttle_tailslow, false), DEFINE_PROP_SIZE("x-max-bandwidth", MigrationState, parameters.max_bandwidth, MAX_THROTTLE), DEFINE_PROP_UINT64("x-downtime-limit", MigrationState, @@ -3600,6 +3612,7 @@ static void migration_instance_init(Object *obj) params->has_decompress_threads =3D true; params->has_cpu_throttle_initial =3D true; params->has_cpu_throttle_increment =3D true; + params->has_cpu_throttle_tailslow =3D true; params->has_max_bandwidth =3D true; params->has_downtime_limit =3D true; params->has_x_checkpoint_delay =3D true; diff --git a/migration/ram.c b/migration/ram.c index ed23ed1c7c..d86413a5d1 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -29,6 +29,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include +#include #include "qemu/cutils.h" #include "qemu/bitops.h" #include "qemu/bitmap.h" @@ -620,15 +621,28 @@ static void mig_throttle_guest_down(void) { MigrationState *s =3D migrate_get_current(); uint64_t pct_initial =3D s->parameters.cpu_throttle_initial; - uint64_t pct_icrement =3D s->parameters.cpu_throttle_increment; + uint64_t pct_increment =3D s->parameters.cpu_throttle_increment; + bool pct_tailslow =3D s->parameters.cpu_throttle_tailslow; int pct_max =3D s->parameters.max_cpu_throttle; =20 + const uint64_t cpu_throttle_now =3D cpu_throttle_get_percentage(); + uint64_t cpu_throttle_inc; + /* We have not started throttling yet. Let's start it. */ if (!cpu_throttle_active()) { cpu_throttle_set(pct_initial); } else { /* Throttling already on, just increase the rate */ - cpu_throttle_set(MIN(cpu_throttle_get_percentage() + pct_icremen= t, + if (cpu_throttle_now >=3D 80 && pct_tailslow) { + /* Eat some scale of CPU from remaining */ + cpu_throttle_inc =3D ceil((100 - cpu_throttle_now) * 0.3); + if (cpu_throttle_inc > pct_increment) { + cpu_throttle_inc =3D pct_increment; + } + } else { + cpu_throttle_inc =3D pct_increment; + } + cpu_throttle_set(MIN(cpu_throttle_now + cpu_throttle_inc, pct_max)); } } diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 558fe06b8f..b5f5c0b382 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -416,6 +416,10 @@ void hmp_info_migrate_parameters(Monitor *mon, const= QDict *qdict) monitor_printf(mon, "%s: %u\n", MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INCR= EMENT), params->cpu_throttle_increment); + assert(params->has_cpu_throttle_tailslow); + monitor_printf(mon, "%s: %s\n", + MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_TAIL= SLOW), + params->cpu_throttle_tailslow ? "on" : "off"); assert(params->has_max_cpu_throttle); monitor_printf(mon, "%s: %u\n", MigrationParameter_str(MIGRATION_PARAMETER_MAX_CPU_THROTTLE)= , diff --git a/qapi/migration.json b/qapi/migration.json index b7348d0c8b..0ac94e00f2 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -532,6 +532,12 @@ # auto-converge detects that migration is not m= aking # progress. The default value is 10. (Since 2.7= ) # +# @cpu-throttle-tailslow: Make throttle slower at tail stage +# At the tail stage of throttle, VM is very sens= itive to +# CPU percentage. We just throttle 30% of remain= ing CPU +# when throttle is more than 80 percentage. The = default +# value is false. (Since 4.1) +# # @tls-creds: ID of the 'tls-creds' object that provides credentials for # establishing a TLS connection over the migration data chan= nel. # On the outgoing side of the migration, the credentials mus= t @@ -594,6 +600,7 @@ 'compress-level', 'compress-threads', 'decompress-threads', 'compress-wait-thread', 'cpu-throttle-initial', 'cpu-throttle-increment', + 'cpu-throttle-tailslow', 'tls-creds', 'tls-hostname', 'tls-authz', 'max-bandwidth', 'downtime-limit', 'x-checkpoint-delay', 'block-incremental', 'multifd-channels', @@ -634,6 +641,12 @@ # auto-converge detects that migration is not m= aking # progress. The default value is 10. (Since 2.7= ) # +# @cpu-throttle-tailslow: Make throttle slower at tail stage +# At the tail stage of throttle, VM is very sens= itive to +# CPU percentage. We just throttle 30% of remain= ing CPU +# when throttle is more than 80 percentage. The = default +# value is false. (Since 4.1) +# # @tls-creds: ID of the 'tls-creds' object that provides credentials # for establishing a TLS connection over the migration data # channel. On the outgoing side of the migration, the creden= tials @@ -703,6 +716,7 @@ '*decompress-threads': 'int', '*cpu-throttle-initial': 'int', '*cpu-throttle-increment': 'int', + '*cpu-throttle-tailslow': 'bool', '*tls-creds': 'StrOrNull', '*tls-hostname': 'StrOrNull', '*tls-authz': 'StrOrNull', @@ -767,6 +781,12 @@ # auto-converge detects that migration is not m= aking # progress. (Since 2.7) # +# @cpu-throttle-tailslow: Make throttle slower at tail stage +# At the tail stage of throttle, VM is very sens= itive to +# CPU percentage. We just throttle 30% of remain= ing CPU +# when throttle is more than 80 percentage. The = default +# value is false. (Since 4.1) +# # @tls-creds: ID of the 'tls-creds' object that provides credentials # for establishing a TLS connection over the migration data # channel. On the outgoing side of the migration, the creden= tials @@ -836,6 +856,7 @@ '*decompress-threads': 'uint8', '*cpu-throttle-initial': 'uint8', '*cpu-throttle-increment': 'uint8', + '*cpu-throttle-tailslow': 'bool', '*tls-creds': 'str', '*tls-hostname': 'str', '*tls-authz': 'str', --=20 2.19.1