From nobody Tue Feb 10 22:18:24 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494596233033189.7075513156367; Fri, 12 May 2017 06:37:13 -0700 (PDT) Received: from localhost ([::1]:53855 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9Akp-0000uD-OQ for importer@patchew.org; Fri, 12 May 2017 09:37:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57689) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9Afj-0005OA-6Q for qemu-devel@nongnu.org; Fri, 12 May 2017 09:31:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d9Afe-00072j-NS for qemu-devel@nongnu.org; Fri, 12 May 2017 09:31:55 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:20657) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d9Afe-00070o-Hm for qemu-devel@nongnu.org; Fri, 12 May 2017 09:31:50 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OPU00GMPDKPLB10@mailout1.w1.samsung.com> for qemu-devel@nongnu.org; Fri, 12 May 2017 14:31:49 +0100 (BST) Received: from eusmges2.samsung.com (unknown [203.254.199.241]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170512133149eucas1p25af3720a729202cf751a3109ce4f7429~93w_ArjG80751307513eucas1p2L; Fri, 12 May 2017 13:31:49 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2.samsung.com (EUCPMTA) with SMTP id 2D.94.04459.449B5195; Fri, 12 May 2017 14:31:48 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170512133148eucas1p2c04111d415b1fbd6fb702cfc2a3ed6f9~93w9YZ0Pe0605406054eucas1p2Y; Fri, 12 May 2017 13:31:48 +0000 (GMT) Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id BF.8E.17452.7D9B5195; Fri, 12 May 2017 14:34:15 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OPU00791DKM5L30@eusync1.samsung.com>; Fri, 12 May 2017 14:31:48 +0100 (BST) X-AuditID: cbfec7f1-f796e6d00000116b-80-5915b944e945 From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Fri, 12 May 2017 16:31:25 +0300 Message-id: <1494595886-30912-9-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1494595886-30912-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrKIsWRmVeSWpSXmKPExsWy7djPc7ouO0UjDa7M0LGYe/c8i0Xvtnvs Flfaf7JbbNn/jd3ieO8OFgdWjyfXNjN5vN93lc2jb8sqxgDmKC6blNSczLLUIn27BK6MVfcm MhdMdqzoXN7F2MA43biLkZNDQsBEovvxGRYIW0ziwr31bF2MXBxCAksZJS5OOcoE4XxmlNgw 9wdQFQdYx9nDEhDxZYwSh683MIF0Cwl0M0ks+ZgGUsMmYCCx754tSFhEQFLid9dpZhCbWSBW 4u31a2wgtrBA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oNZSYTXcAtQiDclsbIq tSg/vqg0J7X4EKMp0FETmaVEk/OB0ZNXEm9oYmhuaWhkbGFhbmSkJM5b8uFKuJBAemJJanZq akFqEUwfEwenVAOjjI3uS8YIRxvzJZX3Nor4MTj27Lv/4tERSYklBuv8F/M0B3ZEHZ5SMeVZ 4eMH33kOO706+uRfX1pc9/Xcs6fTatYsvZqhfJulhe3R87LrXntVUp71aluVHBLUYZg12V1t 0o60oHCXIHaxxJjgNa2iJ67kTgxKn7zhiPJdr3+L2ruyO+YGrnuqxFKckWioxVxUnAgAUxCy A2YCAAA= X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170512133148eucas1p2c04111d415b1fbd6fb702cfc2a3ed6f9 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?QWxleGV5IFBlcmV2YWxvdhtTUlItVmlydHVhbGl6YXRpb24g?= =?UTF-8?B?TGFiG+yCvOyEseyghOyekBtTZW5pb3IgRW5naW5lZXI=?= X-Global-Sender: =?UTF-8?B?QWxleGV5IFBlcmV2YWxvdhtTUlItVmlydHVhbGl6YXRpb24g?= =?UTF-8?B?TGFiG1NhbXN1bmcgRWxlY3Ryb25pY3MbU2VuaW9yIEVuZ2luZWVy?= X-Sender-Code: =?UTF-8?B?QzEwG0NJU0hRG0MxMEdEMDFHRDAxMDE1NA==?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170512133148eucas1p2c04111d415b1fbd6fb702cfc2a3ed6f9 X-RootMTR: 20170512133148eucas1p2c04111d415b1fbd6fb702cfc2a3ed6f9 References: <1494595886-30912-1-git-send-email-a.perevalov@samsung.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 210.118.77.11 Subject: [Qemu-devel] [PATCH V5 8/9] migration: add postcopy total blocktime into query-migrate 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: i.maximets@samsung.com, dgilbert@redhat.com, peterx@redhat.com, a.perevalov@samsung.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Postcopy total blocktime is available on destination side only. But query-migrate was possible only for source. This patch adds ability to call query-migrate on destination. To distinguish src/dst, state of the MigrationState is using, query-migrate prepares MigrationInfo for source machine only in case of migration's state is diffe= rent than MIGRATION_STATUS_NONE. To be able to see postcopy blocktime, need to request postcopy-blocktime capability. The query-migrate command will show following sample result: {"return": "postcopy_vcpu_blocktime": [115, 100], "status": "completed", "postcopy_blocktime": 100 }} postcopy_vcpu_blocktime contains list, where the first item is the first vCPU in QEMU. Signed-off-by: Alexey Perevalov --- include/migration/migration.h | 4 +++ migration/migration.c | 47 ++++++++++++++++++++++++++-- migration/postcopy-ram.c | 73 +++++++++++++++++++++++++++++++++++++++= ++++ migration/trace-events | 1 + qapi-schema.json | 6 +++- 5 files changed, 127 insertions(+), 4 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 7e69a2d..aba0535 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -135,6 +135,10 @@ struct MigrationIncomingState { =20 MigrationIncomingState *migration_incoming_get_current(void); void migration_incoming_state_destroy(void); +/* + * Functions to work with blocktime context + */ +void fill_destination_postcopy_migration_info(MigrationInfo *info); =20 struct MigrationState { diff --git a/migration/migration.c b/migration/migration.c index c0443ce..7a4f33f 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -666,9 +666,15 @@ static void populate_ram_info(MigrationInfo *info, Mig= rationState *s) } } =20 -MigrationInfo *qmp_query_migrate(Error **errp) +/* TODO improve this assumption */ +static bool is_source_migration(void) +{ + MigrationState *ms =3D migrate_get_current(); + return ms->state !=3D MIGRATION_STATUS_NONE; +} + +static void fill_source_migration_info(MigrationInfo *info) { - MigrationInfo *info =3D g_malloc0(sizeof(*info)); MigrationState *s =3D migrate_get_current(); =20 switch (s->state) { @@ -759,10 +765,45 @@ MigrationInfo *qmp_query_migrate(Error **errp) break; } info->status =3D s->state; +} + +static void fill_destination_migration_info(MigrationInfo *info) +{ + MigrationIncomingState *mis =3D migration_incoming_get_current(); =20 - return info; + switch (mis->state) { + case MIGRATION_STATUS_NONE: + break; + case MIGRATION_STATUS_SETUP: + case MIGRATION_STATUS_CANCELLING: + case MIGRATION_STATUS_CANCELLED: + case MIGRATION_STATUS_ACTIVE: + case MIGRATION_STATUS_POSTCOPY_ACTIVE: + case MIGRATION_STATUS_FAILED: + case MIGRATION_STATUS_COLO: + info->has_status =3D true; + break; + case MIGRATION_STATUS_COMPLETED: + info->has_status =3D true; + fill_destination_postcopy_migration_info(info); + break; + } + info->status =3D mis->state; } =20 +MigrationInfo *qmp_query_migrate(Error **errp) +{ + MigrationInfo *info =3D g_malloc0(sizeof(*info)); + + if (is_source_migration()) { + fill_source_migration_info(info); + } else { + fill_destination_migration_info(info); + } + + return info; + } + void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params, Error **errp) { diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index e2660ae..fe047c8 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -129,6 +129,71 @@ static struct PostcopyBlocktimeContext *blocktime_cont= ext_new(void) return ctx; } =20 +static int64List *get_vcpu_blocktime_list(PostcopyBlocktimeContext *ctx) +{ + int64List *list =3D NULL, *entry =3D NULL; + int i; + + for (i =3D smp_cpus - 1; i >=3D 0; i--) { + entry =3D g_new0(int64List, 1); + entry->value =3D ctx->vcpu_blocktime[i]; + entry->next =3D list; + list =3D entry; + } + + return list; +} + +/* + * This function just provide calculated blocktime per cpu and trace it. + * Total blocktime is calculated in mark_postcopy_blocktime_end. + * + * + * Assume we have 3 CPU + * + * S1 E1 S1 E1 + * -----***********------------xxx***************------------------------>= CPU1 + * + * S2 E2 + * ------------****************xxx--------------------------------------->= CPU2 + * + * S3 E3 + * ------------------------****xxx********------------------------------->= CPU3 + * + * We have sequence S1,S2,E1,S3,S1,E2,E3,E1 + * S2,E1 - doesn't match condition due to sequence S1,S2,E1 doesn't includ= e CPU3 + * S3,S1,E2 - sequence includes all CPUs, in this case overlap will be S1,= E2 - + * it's a part of total blocktime. + * S1 - here is last_begin + * Legend of the picture is following: + * * - means blocktime per vCPU + * x - means overlapped blocktime (total blocktime) + */ +void fill_destination_postcopy_migration_info(MigrationInfo *info) +{ + MigrationIncomingState *mis =3D migration_incoming_get_current(); + + if (!mis->blocktime_ctx) { + return; + } + + info->has_postcopy_blocktime =3D true; + info->postcopy_blocktime =3D mis->blocktime_ctx->total_blocktime; + info->has_postcopy_vcpu_blocktime =3D true; + info->postcopy_vcpu_blocktime =3D get_vcpu_blocktime_list(mis->blockti= me_ctx); +} + +static uint64_t get_postcopy_total_blocktime(void) +{ + MigrationIncomingState *mis =3D migration_incoming_get_current(); + + if (!mis->blocktime_ctx) { + return 0; + } + + return mis->blocktime_ctx->total_blocktime; +} + /* * Check userfault fd features, to request only supported features in * future. @@ -462,6 +527,9 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingStat= e *mis) } =20 postcopy_state_set(POSTCOPY_INCOMING_END); + /* here should be blocktime receiving back operation */ + trace_postcopy_ram_incoming_cleanup_blocktime( + get_postcopy_total_blocktime()); migrate_send_rp_shut(mis, qemu_file_get_error(mis->from_src_file) !=3D= 0); =20 if (mis->postcopy_tmp_page) { @@ -876,6 +944,11 @@ void *postcopy_get_tmp_page(MigrationIncomingState *mi= s) =20 #else /* No target OS support, stubs just fail */ +void fill_destination_postcopy_migration_info(MigrationInfo *info) +{ + error_report("%s: No OS support", __func__); +} + bool postcopy_ram_supported_by_host(MigrationIncomingState *mis) { error_report("%s: No OS support", __func__); diff --git a/migration/trace-events b/migration/trace-events index 9424e3e..bdaca1d 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -193,6 +193,7 @@ postcopy_ram_incoming_cleanup_closeuf(void) "" postcopy_ram_incoming_cleanup_entry(void) "" postcopy_ram_incoming_cleanup_exit(void) "" postcopy_ram_incoming_cleanup_join(void) "" +postcopy_ram_incoming_cleanup_blocktime(uint64_t total) "total blocktime %= " PRIu64 save_xbzrle_page_skipping(void) "" save_xbzrle_page_overflow(void) "" ram_save_iterate_big_wait(uint64_t milliconds, int iterations) "big wait: = %" PRIu64 " milliseconds, %d iterations" diff --git a/qapi-schema.json b/qapi-schema.json index fde6d63..e11c5f2 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -712,6 +712,8 @@ # @status is 'failed'. Clients should not attempt to parse the # error strings. (Since 2.7) # +# @postcopy_vcpu_blocktime: list of the postcopy blocktime per vCPU (Since= 2.9) +# # Since: 0.14.0 ## { 'struct': 'MigrationInfo', @@ -723,7 +725,9 @@ '*downtime': 'int', '*setup-time': 'int', '*cpu-throttle-percentage': 'int', - '*error-desc': 'str'} } + '*error-desc': 'str', + '*postcopy_blocktime' : 'int64', + '*postcopy_vcpu_blocktime': ['int64']} } =20 ## # @query-migrate: --=20 1.9.1