From nobody Wed May 8 02:35:06 2024 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.zohomail.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 150720232570188.72180458247647; Thu, 5 Oct 2017 04:18:45 -0700 (PDT) Received: from localhost ([::1]:39117 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e04Ac-0005A1-Px for importer@patchew.org; Thu, 05 Oct 2017 07:18:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36277) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e048i-0003vy-3X for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:16:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e048f-0000Ft-FB for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:16:28 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:56930) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e048f-0000FG-9U for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:16:25 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20171005111623euoutp02288559f70e27d818b0493ad98986c45d~qqGaYEAyH2915429154euoutp02K; Thu, 5 Oct 2017 11:16:23 +0000 (GMT) Received: from eusmges5.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171005111623eucas1p214dd30b0972c8e9c1507a97781b49eb0~qqGZ9Qg8g0162001620eucas1p2d; Thu, 5 Oct 2017 11:16:23 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges5.samsung.com (EUCPMTA) with SMTP id 2E.23.12743.78416D95; Thu, 5 Oct 2017 12:16:23 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171005111622eucas1p1dd4545fb4b45add67b222d91355aa208~qqGZUjj0_1747717477eucas1p1n; Thu, 5 Oct 2017 11:16:22 +0000 (GMT) Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 01.93.20118.68416D95; Thu, 5 Oct 2017 12:16:22 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OXC00M4YKN1XNA0@eusync4.samsung.com>; Thu, 05 Oct 2017 12:16:22 +0100 (BST) X-AuditID: cbfec7f5-f79d06d0000031c7-32-59d614875594 From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Thu, 05 Oct 2017 14:16:05 +0300 Message-id: <1507202170-22619-2-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 2.7.4 In-reply-to: <1507202170-22619-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrGIsWRmVeSWpSXmKPExsWy7djP87rtItciDU7/4baYe/c8i0Xvtnvs FtM+32a3uNL+k91iy/5v7BbHe3ewWNzZ0sfkwO7x5NpmJo/3+66yefRtWcUYwBzFZZOSmpNZ llqkb5fAldH06A9bwSfBipYV09kbGO/xdTFyckgImEhcOnuLCcIWk7hwbz1bFyMXh5DAUkaJ K1+6mSCcz4wSuxZcZ4PpePRuO1RiGaPEu9k7WCGcbiaJvx3LmbsYOTjYBAwk9t2zBWkQEZCU +N11mhmkhllgIaPEg4s97CAJY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ahRz8tmFbnz7Q2hO6r7V95ewttvfciwqUD4aq507b9CaYM/Pl9/SHb0r3pYmV 3bzUqCpRObE9b2PFhXKVZfuO8sgcsY+81inB5P+Hx/dC5aTig6suL54YaJHJO/ecutujnOg5 mxQez3ZgET7Wf0n2xt13NRL51+ssDjbc3yD7T+DQpGMFy5VYijMSDbWYi4oTAU3C16EbAgAA X-CMS-MailID: 20171005111622eucas1p1dd4545fb4b45add67b222d91355aa208 X-Msg-Generator: CA X-Sender-IP: 182.198.249.180 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-CMS-RootMailID: 20171005111622eucas1p1dd4545fb4b45add67b222d91355aa208 X-RootMTR: 20171005111622eucas1p1dd4545fb4b45add67b222d91355aa208 References: <1507202170-22619-1-git-send-email-a.perevalov@samsung.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 210.118.77.12 Subject: [Qemu-devel] [PATCH v11 1/6] migration: introduce postcopy-blocktime capability 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: heetae82.ahn@samsung.com, quintela@redhat.com, Alexey Perevalov , peterx@redhat.com, dgilbert@redhat.com, i.maximets@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" Right now it could be used on destination side to enable vCPU blocktime calculation for postcopy live migration. vCPU blocktime - it's time since vCPU thread was put into interruptible sleep, till memory page was copied and thread awake. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Alexey Perevalov --- migration/migration.c | 9 +++++++++ migration/migration.h | 1 + qapi/migration.json | 5 ++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/migration/migration.c b/migration/migration.c index 98429dc..713f070 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1467,6 +1467,15 @@ bool migrate_zero_blocks(void) return s->enabled_capabilities[MIGRATION_CAPABILITY_ZERO_BLOCKS]; } =20 +bool migrate_postcopy_blocktime(void) +{ + MigrationState *s; + + s =3D migrate_get_current(); + + return s->enabled_capabilities[MIGRATION_CAPABILITY_POSTCOPY_BLOCKTIME= ]; +} + bool migrate_use_compression(void) { MigrationState *s; diff --git a/migration/migration.h b/migration/migration.h index b83ccea..c12ceba 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -193,6 +193,7 @@ int migrate_compress_level(void); int migrate_compress_threads(void); int migrate_decompress_threads(void); bool migrate_use_events(void); +bool migrate_postcopy_blocktime(void); =20 /* Sending on the return path - generic and then for each message type */ void migrate_send_rp_shut(MigrationIncomingState *mis, diff --git a/qapi/migration.json b/qapi/migration.json index f8b365e..0f2af26 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -343,12 +343,15 @@ # # @x-multifd: Use more than one fd for migration (since 2.11) # +# @postcopy-blocktime: Calculate downtime for postcopy live migration +# (since 2.11) +# # Since: 1.2 ## { 'enum': 'MigrationCapability', 'data': ['xbzrle', 'rdma-pin-all', 'auto-converge', 'zero-blocks', 'compress', 'events', 'postcopy-ram', 'x-colo', 'release-ram', - 'block', 'return-path', 'x-multifd' ] } + 'block', 'return-path', 'x-multifd', 'postcopy-blocktime' ] } =20 ## # @MigrationCapabilityStatus: --=20 2.7.4 From nobody Wed May 8 02:35:06 2024 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.zohomail.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 1507202377002203.4035003822869; Thu, 5 Oct 2017 04:19:37 -0700 (PDT) Received: from localhost ([::1]:39119 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e04Bh-00062O-8E for importer@patchew.org; Thu, 05 Oct 2017 07:19:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e048j-0003wZ-9d for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:16:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e048g-0000Gp-HM for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:16:29 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:42759) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e048g-0000GA-7u for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:16:26 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20171005111624euoutp0129333d31a4b0c2443f21c845f260a5ea~qqGbQMHpx1673016730euoutp01K; Thu, 5 Oct 2017 11:16:24 +0000 (GMT) Received: from eusmges4.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171005111624eucas1p183c1c469ba243b595413d0e3883718c4~qqGao-2if1494214942eucas1p1A; Thu, 5 Oct 2017 11:16:24 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges4.samsung.com (EUCPMTA) with SMTP id 96.19.12944.78416D95; Thu, 5 Oct 2017 12:16:23 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171005111623eucas1p272597c60842087cac3ade92b88212eff~qqGZ_OvGs2880128801eucas1p2a; Thu, 5 Oct 2017 11:16:23 +0000 (GMT) Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 8E.A0.18832.78416D95; Thu, 5 Oct 2017 12:16:23 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OXC00M4YKN1XNA0@eusync4.samsung.com>; Thu, 05 Oct 2017 12:16:23 +0100 (BST) X-AuditID: cbfec7f4-f79ab6d000003290-b3-59d61487e12d From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Thu, 05 Oct 2017 14:16:06 +0300 Message-id: <1507202170-22619-3-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 2.7.4 In-reply-to: <1507202170-22619-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrKIsWRmVeSWpSXmKPExsWy7djP87rtItciDaYesrCYe/c8i0Xvtnvs FtM+32a3uNL+k91iy/5v7BbHe3ewWNzZ0sfkwO7x5NpmJo/3+66yefRtWcUYwBzFZZOSmpNZ llqkb5fAlXFx6nWWgtlqFUdfLmFuYDwn18XIySEhYCKx+uAHdghbTOLCvfVsXYxcHEICSxkl tl5vgnI+M0rMnvCdCaZj64GzrCC2kMAyRokf7c4QRd1MEku37wEq4uBgEzCQ2HfPFqRGREBS 4nfXaWaQGmaBhYwSDy72gK0TFoiRaHjx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tSi2Cy TBycUg2M/Z9ucB7hWXjHd8KmK+k/g2SY/bz+1iz7ulsycdJP03uOwbsY9jX9/e9Z+3jBUf6g +5NtpBkOfVpXsOZKnDyb35xJnGftj4hJrj7RUaF/kmndSZtJP6u5E26XbmZz5nxs5F/BF/H2 cH/LjKr29aemPJ60f/MdpztVtrGb513TC2jaZrbvjOSuGUosxRmJhlrMRcWJAME0hm0cAgAA X-CMS-MailID: 20171005111623eucas1p272597c60842087cac3ade92b88212eff 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-CMS-RootMailID: 20171005111623eucas1p272597c60842087cac3ade92b88212eff X-RootMTR: 20171005111623eucas1p272597c60842087cac3ade92b88212eff References: <1507202170-22619-1-git-send-email-a.perevalov@samsung.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 210.118.77.11 Subject: [Qemu-devel] [PATCH v11 2/6] migration: add postcopy blocktime ctx into MigrationIncomingState 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: heetae82.ahn@samsung.com, quintela@redhat.com, Alexey Perevalov , peterx@redhat.com, dgilbert@redhat.com, i.maximets@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" This patch adds request to kernel space for UFFD_FEATURE_THREAD_ID, in case when this feature is provided by kernel. PostcopyBlocktimeContext is incapsulated inside postcopy-ram.c, due to it's postcopy only feature. Also it defines PostcopyBlocktimeContext's instance live time. Information from PostcopyBlocktimeContext instance will be provided much after postcopy migration end, instance of PostcopyBlocktimeContext will live till QEMU exit, but part of it (vcpu_addr, page_fault_vcpu_time) used only during calculation, will be released when postcopy ended or failed. To enable postcopy blocktime calculation on destination, need to request proper capabiltiy (Patch for documentation will be at the tail of the patch set). As an example following command enable that capability, assume QEMU was started with -chardev socket,id=3Dcharmonitor,path=3D/var/lib/migrate-vm-monitor.sock option to control it [root@host]#printf "{\"execute\" : \"qmp_capabilities\"}\r\n \ {\"execute\": \"migrate-set-capabilities\" , \"arguments\": { \"capabilities\": [ { \"capability\": \"postcopy-blocktime\", \"state\": true } ] } }" | nc -U /var/lib/migrate-vm-monitor.sock Or just with HMP (qemu) migrate_set_capability postcopy-blocktime on Signed-off-by: Alexey Perevalov Reviewed-by: Dr. David Alan Gilbert --- migration/migration.h | 8 +++++++ migration/postcopy-ram.c | 59 ++++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 67 insertions(+) diff --git a/migration/migration.h b/migration/migration.h index c12ceba..2bae992 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -22,6 +22,8 @@ #include "hw/qdev.h" #include "io/channel.h" =20 +struct PostcopyBlocktimeContext; + /* State for the incoming migration */ struct MigrationIncomingState { QEMUFile *from_src_file; @@ -59,6 +61,12 @@ struct MigrationIncomingState { /* The coroutine we should enter (back) after failover */ Coroutine *migration_incoming_co; QemuSemaphore colo_incoming_sem; + + /* + * PostcopyBlocktimeContext to keep information for postcopy + * live migration, to calculate vCPU block time + * */ + struct PostcopyBlocktimeContext *blocktime_ctx; }; =20 MigrationIncomingState *migration_incoming_get_current(void); diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index bec6c2c..c18ec5a 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -61,6 +61,52 @@ struct PostcopyDiscardState { #include #include =20 +typedef struct PostcopyBlocktimeContext { + /* time when page fault initiated per vCPU */ + int64_t *page_fault_vcpu_time; + /* page address per vCPU */ + uint64_t *vcpu_addr; + int64_t total_blocktime; + /* blocktime per vCPU */ + int64_t *vcpu_blocktime; + /* point in time when last page fault was initiated */ + int64_t last_begin; + /* number of vCPU are suspended */ + int smp_cpus_down; + + /* + * Handler for exit event, necessary for + * releasing whole blocktime_ctx + */ + Notifier exit_notifier; +} PostcopyBlocktimeContext; + +static void destroy_blocktime_context(struct PostcopyBlocktimeContext *ctx) +{ + g_free(ctx->page_fault_vcpu_time); + g_free(ctx->vcpu_addr); + g_free(ctx->vcpu_blocktime); + g_free(ctx); +} + +static void migration_exit_cb(Notifier *n, void *data) +{ + PostcopyBlocktimeContext *ctx =3D container_of(n, PostcopyBlocktimeCon= text, + exit_notifier); + destroy_blocktime_context(ctx); +} + +static struct PostcopyBlocktimeContext *blocktime_context_new(void) +{ + PostcopyBlocktimeContext *ctx =3D g_new0(PostcopyBlocktimeContext, 1); + ctx->page_fault_vcpu_time =3D g_new0(int64_t, smp_cpus); + ctx->vcpu_addr =3D g_new0(uint64_t, smp_cpus); + ctx->vcpu_blocktime =3D g_new0(int64_t, smp_cpus); + + ctx->exit_notifier.notify =3D migration_exit_cb; + qemu_add_exit_notifier(&ctx->exit_notifier); + return ctx; +} =20 /** * receive_ufd_features: check userfault fd features, to request only supp= orted @@ -153,6 +199,19 @@ static bool ufd_check_and_apply(int ufd, MigrationInco= mingState *mis) } } =20 +#ifdef UFFD_FEATURE_THREAD_ID + if (migrate_postcopy_blocktime() && mis && + UFFD_FEATURE_THREAD_ID & supported_features) { + /* kernel supports that feature */ + /* don't create blocktime_context if it exists */ + if (!mis->blocktime_ctx) { + mis->blocktime_ctx =3D blocktime_context_new(); + } + + asked_features |=3D UFFD_FEATURE_THREAD_ID; + } +#endif + /* * request features, even if asked_features is 0, due to * kernel expects UFFD_API before UFFDIO_REGISTER, per --=20 2.7.4 From nobody Wed May 8 02:35:06 2024 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.zohomail.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 1507202453882160.48474547101102; Thu, 5 Oct 2017 04:20:53 -0700 (PDT) Received: from localhost ([::1]:39138 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e04Cv-0006yB-51 for importer@patchew.org; Thu, 05 Oct 2017 07:20:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36296) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e048j-0003wa-A2 for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:16:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e048h-0000HK-CO for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:16:29 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:42762) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e048h-0000Ge-2H for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:16:27 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20171005111625euoutp010c85bf1ff5d8d7186c415c6c3488090f~qqGb_XR1e1667316673euoutp01k; Thu, 5 Oct 2017 11:16:25 +0000 (GMT) Received: from eusmges5.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171005111624eucas1p1b1e5381265999904e628540017d9b6b0~qqGbQILmZ1501215012eucas1p1y; Thu, 5 Oct 2017 11:16:24 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges5.samsung.com (EUCPMTA) with SMTP id EE.23.12743.88416D95; Thu, 5 Oct 2017 12:16:24 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171005111624eucas1p294c2c03421f17915b82cbde4cf4b9fa3~qqGapyI2f2885928859eucas1p2V; Thu, 5 Oct 2017 11:16:24 +0000 (GMT) Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 4F.A0.18832.88416D95; Thu, 5 Oct 2017 12:16:24 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OXC00M4YKN1XNA0@eusync4.samsung.com>; Thu, 05 Oct 2017 12:16:24 +0100 (BST) X-AuditID: cbfec7f5-f79d06d0000031c7-35-59d6148897d3 From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Thu, 05 Oct 2017 14:16:07 +0300 Message-id: <1507202170-22619-4-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 2.7.4 In-reply-to: <1507202170-22619-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMIsWRmVeSWpSXmKPExsWy7djPc7odItciDRp3KVvMvXuexaJ32z12 i2mfb7NbXGn/yW6xZf83dovjvTtYLO5s6WNyYPd4cm0zk8f7fVfZPPq2rGIMYI7isklJzcks Sy3St0vgypjbNpG94Kx7xb1pD1kaGP+adjFyckgImEjsPNHMDGGLSVy4t56ti5GLQ0hgKaPE 71U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QowMGoxMPrsfVqpBBrYllx Ze4hRgkOZiURXqX/QCHelMTKqtSi/Pii0pzU4kOM0hwsSuK8vXtWRwoJpCeWpGanphakFsFk mTg4pRoY2SMTfZRvzby4Qlxed+PPisP/cuWU8p7E6HqseaKyYNah3RodM8MWa65yfRTc0+C8 O3O2TYjtW1G7hInMvnvnO5s+k1nqn/wmaUPJNJ0FzurT3ha8lK4Vnsi3+82lBaVPln16MiN4 WWuiUP38Oakvdx+bWxfNuPXtlRuMTIuf+x/7+fT58n1/PyuxFGckGmoxFxUnAgCwxWvHGQIA AA== X-CMS-MailID: 20171005111624eucas1p294c2c03421f17915b82cbde4cf4b9fa3 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-CMS-RootMailID: 20171005111624eucas1p294c2c03421f17915b82cbde4cf4b9fa3 X-RootMTR: 20171005111624eucas1p294c2c03421f17915b82cbde4cf4b9fa3 References: <1507202170-22619-1-git-send-email-a.perevalov@samsung.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 210.118.77.11 Subject: [Qemu-devel] [PATCH v11 3/6] migration: calculate vCPU blocktime on dst side 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: heetae82.ahn@samsung.com, quintela@redhat.com, Alexey Perevalov , peterx@redhat.com, dgilbert@redhat.com, i.maximets@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" This patch provides blocktime calculation per vCPU, as a summary and as a overlapped value for all vCPUs. This approach was suggested by Peter Xu, as an improvements of previous approch where QEMU kept tree with faulted page address and cpus bi= tmask in it. Now QEMU is keeping array with faulted page address as value and vCPU as index. It helps to find proper vCPU at UFFD_COPY time. Also it keeps list for blocktime per vCPU (could be traced with page_fault_addr) Blocktime will not calculated if postcopy_blocktime field of MigrationIncomingState wasn't initialized. Signed-off-by: Alexey Perevalov --- migration/postcopy-ram.c | 142 +++++++++++++++++++++++++++++++++++++++++++= +++- migration/trace-events | 5 +- 2 files changed, 145 insertions(+), 2 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index c18ec5a..2e10870 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -553,6 +553,141 @@ static int ram_block_enable_notify(const char *block_= name, void *host_addr, return 0; } =20 +static int get_mem_fault_cpu_index(uint32_t pid) +{ + CPUState *cpu_iter; + + CPU_FOREACH(cpu_iter) { + if (cpu_iter->thread_id =3D=3D pid) { + trace_get_mem_fault_cpu_index(cpu_iter->cpu_index, pid); + return cpu_iter->cpu_index; + } + } + trace_get_mem_fault_cpu_index(-1, pid); + return -1; +} + +/* + * This function is being called when pagefault occurs. It + * tracks down vCPU blocking time. + * + * @addr: faulted host virtual address + * @ptid: faulted process thread id + * @rb: ramblock appropriate to addr + */ +static void mark_postcopy_blocktime_begin(uint64_t addr, uint32_t ptid, + RAMBlock *rb) +{ + int cpu, already_received; + MigrationIncomingState *mis =3D migration_incoming_get_current(); + PostcopyBlocktimeContext *dc =3D mis->blocktime_ctx; + int64_t now_ms; + + if (!dc || ptid =3D=3D 0) { + return; + } + cpu =3D get_mem_fault_cpu_index(ptid); + if (cpu < 0) { + return; + } + + now_ms =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); + if (dc->vcpu_addr[cpu] =3D=3D 0) { + atomic_inc(&dc->smp_cpus_down); + } + + atomic_xchg__nocheck(&dc->last_begin, now_ms); + atomic_xchg__nocheck(&dc->page_fault_vcpu_time[cpu], now_ms); + atomic_xchg__nocheck(&dc->vcpu_addr[cpu], addr); + + /* check it here, not at the begining of the function, + * due to, check could accur early than bitmap_set in + * qemu_ufd_copy_ioctl */ + already_received =3D ramblock_recv_bitmap_test(rb, (void *)addr); + if (already_received) { + atomic_xchg__nocheck(&dc->vcpu_addr[cpu], 0); + atomic_xchg__nocheck(&dc->page_fault_vcpu_time[cpu], 0); + atomic_sub(&dc->smp_cpus_down, 1); + } + trace_mark_postcopy_blocktime_begin(addr, dc, dc->page_fault_vcpu_time= [cpu], + cpu, already_received); +} + +/* + * 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) + * + * @addr: host virtual address + */ +static void mark_postcopy_blocktime_end(uint64_t addr) +{ + MigrationIncomingState *mis =3D migration_incoming_get_current(); + PostcopyBlocktimeContext *dc =3D mis->blocktime_ctx; + int i, affected_cpu =3D 0; + int64_t now_ms; + bool vcpu_total_blocktime =3D false; + + if (!dc) { + return; + } + + now_ms =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); + + /* lookup cpu, to clear it, + * that algorithm looks straighforward, but it's not + * optimal, more optimal algorithm is keeping tree or hash + * where key is address value is a list of */ + for (i =3D 0; i < smp_cpus; i++) { + uint64_t vcpu_blocktime =3D 0; + + if (atomic_fetch_add(&dc->vcpu_addr[i], 0) !=3D addr || + atomic_fetch_add(&dc->page_fault_vcpu_time[i], 0) =3D=3D 0) { + continue; + } + atomic_xchg__nocheck(&dc->vcpu_addr[i], 0); + vcpu_blocktime =3D now_ms - + atomic_fetch_add(&dc->page_fault_vcpu_time[i], 0); + affected_cpu +=3D 1; + /* we need to know is that mark_postcopy_end was due to + * faulted page, another possible case it's prefetched + * page and in that case we shouldn't be here */ + if (!vcpu_total_blocktime && + atomic_fetch_add(&dc->smp_cpus_down, 0) =3D=3D smp_cpus) { + vcpu_total_blocktime =3D true; + } + /* continue cycle, due to one page could affect several vCPUs */ + dc->vcpu_blocktime[i] +=3D vcpu_blocktime; + } + + atomic_sub(&dc->smp_cpus_down, affected_cpu); + if (vcpu_total_blocktime) { + dc->total_blocktime +=3D now_ms - atomic_fetch_add(&dc->last_begin= , 0); + } + trace_mark_postcopy_blocktime_end(addr, dc, dc->total_blocktime, + affected_cpu); +} + /* * Handle faults detected by the USERFAULT markings */ @@ -630,8 +765,11 @@ static void *postcopy_ram_fault_thread(void *opaque) rb_offset &=3D ~(qemu_ram_pagesize(rb) - 1); trace_postcopy_ram_fault_thread_request(msg.arg.pagefault.address, qemu_ram_get_idstr(rb), - rb_offset); + rb_offset, + msg.arg.pagefault.feat.pti= d); =20 + mark_postcopy_blocktime_begin((uintptr_t)(msg.arg.pagefault.addres= s), + msg.arg.pagefault.feat.ptid, rb); /* * Send the request to the source - we want to request one * of our host page sizes (which is >=3D TPS) @@ -721,6 +859,8 @@ static int qemu_ufd_copy_ioctl(int userfault_fd, void *= host_addr, if (!ret) { ramblock_recv_bitmap_set_range(rb, host_addr, pagesize / qemu_target_page_size()); + mark_postcopy_blocktime_end((uint64_t)(uintptr_t)host_addr); + } return ret; } diff --git a/migration/trace-events b/migration/trace-events index 6f29fcc..b0c8708 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -115,6 +115,8 @@ process_incoming_migration_co_end(int ret, int ps) "ret= =3D%d postcopy-state=3D%d" process_incoming_migration_co_postcopy_end_main(void) "" migration_set_incoming_channel(void *ioc, const char *ioctype) "ioc=3D%p i= octype=3D%s" migration_set_outgoing_channel(void *ioc, const char *ioctype, const char = *hostname) "ioc=3D%p ioctype=3D%s hostname=3D%s" +mark_postcopy_blocktime_begin(uint64_t addr, void *dd, int64_t time, int c= pu, int received) "addr: 0x%" PRIx64 ", dd: %p, time: %" PRId64 ", cpu: %d,= already_received: %d" +mark_postcopy_blocktime_end(uint64_t addr, void *dd, int64_t time, int aff= ected_cpu) "addr: 0x%" PRIx64 ", dd: %p, time: %" PRId64 ", affected_cpu: %= d" =20 # migration/rdma.c qemu_rdma_accept_incoming_migration(void) "" @@ -191,7 +193,7 @@ postcopy_ram_enable_notify(void) "" postcopy_ram_fault_thread_entry(void) "" postcopy_ram_fault_thread_exit(void) "" postcopy_ram_fault_thread_quit(void) "" -postcopy_ram_fault_thread_request(uint64_t hostaddr, const char *ramblock,= size_t offset) "Request for HVA=3D0x%" PRIx64 " rb=3D%s offset=3D0x%zx" +postcopy_ram_fault_thread_request(uint64_t hostaddr, const char *ramblock,= size_t offset, uint32_t pid) "Request for HVA=3D%" PRIx64 " rb=3D%s offset= =3D%zx pid=3D%u" postcopy_ram_incoming_cleanup_closeuf(void) "" postcopy_ram_incoming_cleanup_entry(void) "" postcopy_ram_incoming_cleanup_exit(void) "" @@ -200,6 +202,7 @@ 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" ram_load_complete(int ret, uint64_t seq_iter) "exit_code %d seq iteration = %" PRIu64 +get_mem_fault_cpu_index(int cpu, uint32_t pid) "cpu: %d, pid: %u" =20 # migration/exec.c migration_exec_outgoing(const char *cmd) "cmd=3D%s" --=20 2.7.4 From nobody Wed May 8 02:35:06 2024 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.zohomail.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 1507202312841644.3943181924448; Thu, 5 Oct 2017 04:18:32 -0700 (PDT) Received: from localhost ([::1]:39116 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e04AY-00056u-Ti for importer@patchew.org; Thu, 05 Oct 2017 07:18:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36293) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e048j-0003wY-96 for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:16:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e048h-0000Ho-Uw for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:16:29 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:56938) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e048h-0000H7-Nu for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:16:27 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20171005111626euoutp025d394aeb0512591dfb22b858e061ae00~qqGcogAZY2915929159euoutp02I; Thu, 5 Oct 2017 11:16:26 +0000 (GMT) Received: from eusmges4.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171005111625eucas1p2772bef15055ec5cfdd1a2aaa4bf11344~qqGcBf9uJ2665326653eucas1p27; Thu, 5 Oct 2017 11:16:25 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges4.samsung.com (EUCPMTA) with SMTP id 57.19.12944.98416D95; Thu, 5 Oct 2017 12:16:25 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171005111624eucas1p193bfeb0e428c8eee6180a1f7b96c0713~qqGbTPw5H1496414964eucas1p1t; Thu, 5 Oct 2017 11:16:24 +0000 (GMT) Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id A1.93.20118.88416D95; Thu, 5 Oct 2017 12:16:24 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OXC00M4YKN1XNA0@eusync4.samsung.com>; Thu, 05 Oct 2017 12:16:24 +0100 (BST) X-AuditID: cbfec7f4-f79ab6d000003290-b7-59d61489d92e From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Thu, 05 Oct 2017 14:16:08 +0300 Message-id: <1507202170-22619-5-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 2.7.4 In-reply-to: <1507202170-22619-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrCIsWRmVeSWpSXmKPExsWy7djPc7qdItciDZa9kLCYe/c8i0Xvtnvs FtM+32a3uNL+k91iy/5v7BbHe3ewWNzZ0sfkwO7x5NpmJo/3+66yefRtWcUYwBzFZZOSmpNZ llqkb5fAldF6eBZbwRzuivsNM1gbGDdxdjFyckgImEjMmDGTEcIWk7hwbz1bFyMXh5DAUkaJ UzceMUI4nxkl1m1eywTTsXR3AytEYh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pxJpY VlyZe4hRgoNZSYRX6f/VSCHelMTKqtSi/Pii0pzU4kOM0hwsSuK8vXtWRwoJpCeWpGanphak FsFkmTg4pRoYkxtk17pkLhWdk7X70ar/0msYV65OncM0O2O53HM3XYYJcTKyewIL0srSBYwZ 7Vc3NUpKLPCsVcuacVb23vwFK9YqrOOodk65bMf4lf9sdctdHa1U8a33rerb3qYeUGisthN9 ldr4rtC9eG2i9uSQDS8islMCZm08dPRNTK26s/WRpX+OcMUqsRRnJBpqMRcVJwIAkGztqBsC AAA= X-CMS-MailID: 20171005111624eucas1p193bfeb0e428c8eee6180a1f7b96c0713 X-Msg-Generator: CA X-Sender-IP: 182.198.249.180 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-CMS-RootMailID: 20171005111624eucas1p193bfeb0e428c8eee6180a1f7b96c0713 X-RootMTR: 20171005111624eucas1p193bfeb0e428c8eee6180a1f7b96c0713 References: <1507202170-22619-1-git-send-email-a.perevalov@samsung.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 210.118.77.12 Subject: [Qemu-devel] [PATCH v11 4/6] migration: postcopy_blocktime documentation 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: heetae82.ahn@samsung.com, quintela@redhat.com, Alexey Perevalov , peterx@redhat.com, dgilbert@redhat.com, i.maximets@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" Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Alexey Perevalov --- docs/devel/migration.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/devel/migration.txt b/docs/devel/migration.txt index 4030703..cebfe7a 100644 --- a/docs/devel/migration.txt +++ b/docs/devel/migration.txt @@ -402,6 +402,19 @@ will now cause the transition from precopy to postcopy. It can be issued immediately after migration is started or any time later on. Issuing it after the end of a migration is harmless. =20 +Blocktime is a postcopy live migration metric, intended to show +how long the vCPU was in state of interruptable sleep due to pagefault. +That metric is calculated both for all vCPUs as overlapped value, and +separately for each vCPU. These values are calculated on destination side. +To enable postcopy blocktime calculation, enter following command on desti= nation +monitor: + +migrate_set_capability postcopy-blocktime on + +Postcopy blocktime can be retrieved by query-migrate qmp command. +postcopy-blocktime value of qmp command will show overlapped blocking time= for +all vCPU, postcopy-vcpu-blocktime will show list of blocking time per vCPU. + Note: During the postcopy phase, the bandwidth limits set using migrate_set_speed is ignored (to avoid delaying requested pages that the destination is waiting for). --=20 2.7.4 From nobody Wed May 8 02:35:06 2024 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.zohomail.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 1507202549255330.71622455587715; Thu, 5 Oct 2017 04:22:29 -0700 (PDT) Received: from localhost ([::1]:39142 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e04ER-0007p4-AQ for importer@patchew.org; Thu, 05 Oct 2017 07:22:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36334) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e048l-0003xh-8T for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:16:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e048i-0000IF-Hb for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:16:31 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:56940) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e048i-0000HX-8a for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:16:28 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20171005111626euoutp027d1ba95e2618cba77e7263d968c3aa46~qqGdKaIea2915929159euoutp02J; Thu, 5 Oct 2017 11:16:26 +0000 (GMT) Received: from eusmges3.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171005111626eucas1p2445a346a71f424dea8c43b74950d404c~qqGckAqSs0161201612eucas1p21; Thu, 5 Oct 2017 11:16:26 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3.samsung.com (EUCPMTA) with SMTP id 7D.E8.12867.98416D95; Thu, 5 Oct 2017 12:16:25 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171005111625eucas1p28ad35b246e6f964ca7d642cfa60df10d~qqGb9zkiA2882328823eucas1p2n; Thu, 5 Oct 2017 11:16:25 +0000 (GMT) Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id A0.B0.18832.98416D95; Thu, 5 Oct 2017 12:16:25 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OXC00M4YKN1XNA0@eusync4.samsung.com>; Thu, 05 Oct 2017 12:16:25 +0100 (BST) X-AuditID: cbfec7f2-f793b6d000003243-3b-59d61489d2fa From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Thu, 05 Oct 2017 14:16:09 +0300 Message-id: <1507202170-22619-6-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 2.7.4 In-reply-to: <1507202170-22619-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrIIsWRmVeSWpSXmKPExsWy7djP87qdItciDa5Pt7GYe/c8i0Xvtnvs FtM+32a3uNL+k91iy/5v7BbHe3ewWNzZ0sfkwO7x5NpmJo/3+66yefRtWcUYwBzFZZOSmpNZ llqkb5fAlfFym1NBg2LF/SuzWRsY30l0MXJySAiYSCxoaGCEsMUkLtxbz9bFyMUhJLCUUWLh 8YVsIAkhgc+MErsv2XYxcoA1rH/gC1GzjFFi15z5UA3dTBJL3r1lASliEzCQ2HfPFqRXREBS 4nfXaWaQGmaBhYwSDy72sIPUCAsESbSdiAWpYRFQlXj+6hHYLl4Bd4k77YdZIQ6Sk7h5rpMZ pJxTwENi0wFJkDESAo1sEn+2X4c62kXiw6mXbBC2sMSr41vYIWwZic6Og0wQDe2MEt07O1kh nAmMEmem/4Wqspc4dfMqE4jNLMAnMWnbdGaIL3klOtqEIEo8JFrmfYU6yFFi2o81jJBAmc0o cfeDzwRG6QWMDKsYRVJLi3PTU4uN9YoTc4tL89L1kvNzNzECI/L0v+OfdjB+PWF1iFGAg1GJ h5fhwZVIIdbEsuLK3EOMEhzMSiK8Sv+vRgrxpiRWVqUW5ccXleakFh9ilOZgURLntY1qixQS SE8sSc1OTS1ILYLJMnFwSjUwMv+KO8b4rP39iwmrGSfG7d/vJnvqqOLz74s/3encIl+Q8G7p lzn9q25sXXx5z4qalbYRuyR7A/aIG+9bvEmCY8tWj59zI9QLAy4vLlU1O8weKlUQ/MFHY6ub TsTbbvOW4FjND18eXF61Zsv2X2eezW64P7XYaZo1//YlKnFXju2V/vBX9fjiV3OVWIozEg21 mIuKEwGyezdyxAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpnluLIzCtJLcpLzFFi42I5/e/4Nd1OkWuRBlceKFvMvXuexaJ32z12 i2mfb7NbXGn/yW6xZf83dovjvTtYLO5s6WNyYPd4cm0zk8f7fVfZPPq2rGIMYI7isklJzcks Sy3St0vgyni5zamgQbHi/pXZrA2M7yS6GDk4JARMJNY/8O1i5AQyxSQu3FvP1sXIxSEksIRR Yv+2/SwQTi+TxPz+BmaQBjYBA4l992xBGkQEJCV+d51mBqlhFljIKDFn6hNGkISwQIDE6cu/ mUBsFgFVieevHrGB2LwC7hJ32g+zQmyTk7h5rhNsJqeAh8SmA5IgYSGgkpNdZ9kmMPIuYGRY xSiSWlqcm55bbKhXnJhbXJqXrpecn7uJERg824793LyD8dLG4EOMAhyMSjy8HluvRgqxJpYV V+YeYpTgYFYS4VX6DxTiTUmsrEotyo8vKs1JLT7EKM3BoiTO27tndaSQQHpiSWp2ampBahFM lomDU6qBUavgVeJ56fwK86op/9pvKDa0P9/hpdLGnK8a/7O/TnJ2pEKP+/6mqffFZttsni7A 8+amiUu9SKVtRl1si0r/tYqSq4dkLHNcP5c9VN3eXPn+os/s3WsPPlrNLvjrapJxxsaLD98t EJs92d3QMn/h83juK0m1XH5H7zmYdqpvi776cudJeT4vJZbijERDLeai4kQAdAXR0RoCAAA= X-CMS-MailID: 20171005111625eucas1p28ad35b246e6f964ca7d642cfa60df10d 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-CMS-RootMailID: 20171005111625eucas1p28ad35b246e6f964ca7d642cfa60df10d X-RootMTR: 20171005111625eucas1p28ad35b246e6f964ca7d642cfa60df10d References: <1507202170-22619-1-git-send-email-a.perevalov@samsung.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 210.118.77.12 Subject: [Qemu-devel] [PATCH v11 5/6] migration: add blocktime calculation into postcopy-test 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: heetae82.ahn@samsung.com, quintela@redhat.com, Alexey Perevalov , peterx@redhat.com, dgilbert@redhat.com, i.maximets@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" This patch just requests blocktime calculation, and check it in case when UFFD_FEATURE_THREAD_ID feature is set on the host. Signed-off-by: Alexey Perevalov Reviewed-by: Dr. David Alan Gilbert --- tests/postcopy-test.c | 63 +++++++++++++++++++++++++++++++++++++++--------= ---- 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/tests/postcopy-test.c b/tests/postcopy-test.c index 8142f2a..4231cce 100644 --- a/tests/postcopy-test.c +++ b/tests/postcopy-test.c @@ -24,7 +24,8 @@ =20 const unsigned start_address =3D 1024 * 1024; const unsigned end_address =3D 100 * 1024 * 1024; -bool got_stop; +static bool got_stop; +static bool uffd_feature_thread_id; =20 #if defined(__linux__) #include @@ -54,6 +55,7 @@ static bool ufd_version_check(void) g_test_message("Skipping test: UFFDIO_API failed"); return false; } + uffd_feature_thread_id =3D api_struct.features & UFFD_FEATURE_THREAD_I= D; =20 ioctl_mask =3D (__u64)1 << _UFFDIO_REGISTER | (__u64)1 << _UFFDIO_UNREGISTER; @@ -265,22 +267,48 @@ static uint64_t get_migration_pass(void) return result; } =20 -static void wait_for_migration_complete(void) +static bool get_src_status(void) { QDict *rsp, *rsp_return; + const char *status; + bool result; + + rsp =3D return_or_event(qmp("{ 'execute': 'query-migrate' }")); + rsp_return =3D qdict_get_qdict(rsp, "return"); + status =3D qdict_get_str(rsp_return, "status"); + g_assert_cmpstr(status, !=3D, "failed"); + result =3D strcmp(status, "completed") =3D=3D 0; + QDECREF(rsp); + return result; +} + +static void read_blocktime(void) +{ + QDict *rsp, *rsp_return; + + rsp =3D return_or_event(qmp("{ 'execute': 'query-migrate' }")); + rsp_return =3D qdict_get_qdict(rsp, "return"); + g_assert(qdict_haskey(rsp_return, "postcopy-blocktime")); + QDECREF(rsp); +} + +static void wait_for_migration_complete(QTestState *from, QTestState *to) +{ bool completed; =20 do { - const char *status; - - rsp =3D return_or_event(qmp("{ 'execute': 'query-migrate' }")); - rsp_return =3D qdict_get_qdict(rsp, "return"); - status =3D qdict_get_str(rsp_return, "status"); - completed =3D strcmp(status, "completed") =3D=3D 0; - g_assert_cmpstr(status, !=3D, "failed"); - QDECREF(rsp); + + /* test src state */ + global_qtest =3D from; + completed =3D get_src_status(); + usleep(1000 * 100); } while (!completed); + + if (uffd_feature_thread_id) { + global_qtest =3D to; + read_blocktime(); + } } =20 static void wait_for_migration_pass(void) @@ -364,8 +392,6 @@ static void test_migrate(void) char *bootpath =3D g_strdup_printf("%s/bootsect", tmpfs); const char *arch =3D qtest_get_arch(); =20 - got_stop =3D false; - if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { init_bootfile_x86(bootpath); cmd_src =3D g_strdup_printf("-machine accel=3Dkvm:tcg -m 150M" @@ -425,6 +451,15 @@ static void test_migrate(void) g_assert(qdict_haskey(rsp, "return")); QDECREF(rsp); =20 + global_qtest =3D to; + rsp =3D qmp("{ 'execute': 'migrate-set-capabilities'," + "'arguments': { " + "'capabilities': [ {" + "'capability': 'postcopy-blocktime'," + "'state': true } ] } }"); + g_assert(qdict_haskey(rsp, "return")); + QDECREF(rsp); + /* We want to pick a speed slow enough that the test completes * quickly, but that it doesn't complete precopy even on a slow * machine, so also set the downtime. @@ -441,7 +476,6 @@ static void test_migrate(void) g_assert(qdict_haskey(rsp, "return")); QDECREF(rsp); =20 - /* Wait for the first serial output from the source */ wait_for_serial("src_serial"); =20 @@ -467,8 +501,7 @@ static void test_migrate(void) qmp_eventwait("RESUME"); =20 wait_for_serial("dest_serial"); - global_qtest =3D from; - wait_for_migration_complete(); + wait_for_migration_complete(from, to); =20 qtest_quit(from); =20 --=20 2.7.4 From nobody Wed May 8 02:35:06 2024 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.zohomail.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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507202668201540.377740734333; Thu, 5 Oct 2017 04:24:28 -0700 (PDT) Received: from localhost ([::1]:39147 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e04G3-0000TG-2z for importer@patchew.org; Thu, 05 Oct 2017 07:24:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36351) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e048m-0003yn-Go for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:16:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e048j-0000JI-JU for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:16:32 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:56945) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e048j-0000IS-Am for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:16:29 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20171005111627euoutp02e514a84884915ee80769c28cfbb2d97d~qqGeIx1p62915929159euoutp02K; Thu, 5 Oct 2017 11:16:27 +0000 (GMT) Received: from eusmges2.samsung.com (unknown [203.254.199.241]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171005111626eucas1p11a0527b99ded493f937749f4425c5e90~qqGdPzuuh1748117481eucas1p1V; Thu, 5 Oct 2017 11:16:26 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2.samsung.com (EUCPMTA) with SMTP id 56.AA.12907.A8416D95; Thu, 5 Oct 2017 12:16:26 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171005111626eucas1p2ea023000ede617c0b8509f11c99fc10a~qqGcoy1H52880128801eucas1p2d; Thu, 5 Oct 2017 11:16:26 +0000 (GMT) Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 41.B0.18832.A8416D95; Thu, 5 Oct 2017 12:16:26 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OXC00M4YKN1XNA0@eusync4.samsung.com>; Thu, 05 Oct 2017 12:16:26 +0100 (BST) X-AuditID: cbfec7f1-f793a6d00000326b-60-59d6148a90da From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Thu, 05 Oct 2017 14:16:10 +0300 Message-id: <1507202170-22619-7-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 2.7.4 In-reply-to: <1507202170-22619-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrCIsWRmVeSWpSXmKPExsWy7djP87pdItciDX5P0rGYe/c8i0Xvtnvs FtM+32a3uNL+k91iy/5v7BbHe3ewWNzZ0sfkwO7x5NpmJo/3+66yefRtWcUYwBzFZZOSmpNZ llqkb5fAldHbcY+14LBLxeaJvUwNjO9Muxg5OSQETCQunO1igrDFJC7cW8/WxcjFISSwlFHi 25FeVgjnM6PEpotfGGE62ib1s4HYQgLLGCWWXnGDKOpmklhy/TpQEQcHm4CBxL57tiA1IgKS Er+7TjOD1DALLGSUeHCxhx0kISwQKnGj+zvYahYBVYnZjycxg9i8Au4Sx95vZIFYJidx81wn M8hMTgEPiU0HJCHCHWwS/9rDIWwXiXfXN7JB2MISr45vYYewZSQ6Ow4ygeyVEGhnlOje2ckK 4UxglDgz/S9Ulb3EqZtXwY5gFuCTmLRtOtgyCQFeiY42IYgSD4k53+5C3eMo0dzUBQ2i2YwS +/fMZJrAKL2AkWEVo0hqaXFuemqxkV5xYm5xaV66XnJ+7iZGYFye/nf84w7G9yesDjEKcDAq 8fBGPLoSKcSaWFZcmXuIUYKDWUmEV+n/1Ugh3pTEyqrUovz4otKc1OJDjNIcLErivLZRbZFC AumJJanZqakFqUUwWSYOTqkGRpZpu9fKqiveaGZ1fDGFIX7vb6HDao+N5onyn1v1PnbishPS 0k/fzZOT2GeXH2UZGZLpPPG739ucE8s/zE5Mm3C7QN2350pY0btsfb6lWy63/m/sWvNxmszf qU9lmuoe67r4vbHI+/D96s6/G13vL/hvt7asQ+qcdZl4Vs3+N2rhz1ouGB/gD1ZiKc5INNRi LipOBACkddlIxwIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkluLIzCtJLcpLzFFi42I5/e/4Nd0ukWuRBsuvC1nMvXuexaJ32z12 i2mfb7NbXGn/yW6xZf83dovjvTtYLO5s6WNyYPd4cm0zk8f7fVfZPPq2rGIMYI7isklJzcks Sy3St0vgyujtuMdacNilYvPEXqYGxnemXYycHBICJhJtk/rZIGwxiQv31gPZXBxCAksYJX7/ nMwC4fQySdyd18vaxcjBwSZgILHvni1Ig4iApMTvrtPMIDXMAgsZJeZMfcIIkhAWCJW40f2d CcRmEVCVmP14EjOIzSvgLnHs/UYWiG1yEjfPdTKDzOQU8JDYdEASJCwEVHKy6yzbBEbeBYwM qxhFUkuLc9Nziw31ihNzi0vz0vWS83M3MQIDaNuxn5t3MF7aGHyIUYCDUYmH12Pr1Ugh1sSy 4srcQ4wSHMxKIrxK/4FCvCmJlVWpRfnxRaU5qcWHGKU5WJTEeXv3rI4UEkhPLEnNTk0tSC2C yTJxcEo1MMZ2fDG/uqt14tdVVrGTd21TYtI7w/jMccaRS66zo3Z8zthU2fJ31aFLGRd+n79/ eP6mGTdvzXuss9THZP2jeZO0p57mMjANl/FJ/Zp9bYa+5aWWJeEbN2xMrFHtsJxS6vNW94LR 0UdvLy9htPTVcjbUvNqz3KzQbLrq7k+FjJ2P6mJ8xRgdHzArsRRnJBpqMRcVJwIAQRAnGBwC AAA= X-CMS-MailID: 20171005111626eucas1p2ea023000ede617c0b8509f11c99fc10a 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-CMS-RootMailID: 20171005111626eucas1p2ea023000ede617c0b8509f11c99fc10a X-RootMTR: 20171005111626eucas1p2ea023000ede617c0b8509f11c99fc10a References: <1507202170-22619-1-git-send-email-a.perevalov@samsung.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 210.118.77.12 Subject: [Qemu-devel] [PATCH v11 6/6] 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: heetae82.ahn@samsung.com, quintela@redhat.com, Alexey Perevalov , peterx@redhat.com, dgilbert@redhat.com, i.maximets@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 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. This patch has a drawback, it combines states of incoming and outgoing migration. Ongoing migration state will overwrite incoming state. Looks like better to separate query-migrate for incoming and outgoing migration or add parameter to indicate type of migration. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Alexey Perevalov --- hmp.c | 15 +++++++++++++ migration/migration.c | 42 ++++++++++++++++++++++++++++++++---- migration/migration.h | 4 ++++ migration/postcopy-ram.c | 56 ++++++++++++++++++++++++++++++++++++++++++++= ++++ migration/trace-events | 1 + qapi/migration.json | 11 +++++++++- 6 files changed, 124 insertions(+), 5 deletions(-) diff --git a/hmp.c b/hmp.c index ace729d..1939c02 100644 --- a/hmp.c +++ b/hmp.c @@ -264,6 +264,21 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) info->cpu_throttle_percentage); } =20 + if (info->has_postcopy_blocktime) { + monitor_printf(mon, "postcopy blocktime: %" PRId64 "\n", + info->postcopy_blocktime); + } + + if (info->has_postcopy_vcpu_blocktime) { + Visitor *v; + char *str; + v =3D string_output_visitor_new(false, &str); + visit_type_int64List(v, NULL, &info->postcopy_vcpu_blocktime, NULL= ); + visit_complete(v, &str); + monitor_printf(mon, "postcopy vcpu blocktime: %s\n", str); + g_free(str); + visit_free(v); + } qapi_free_MigrationInfo(info); qapi_free_MigrationCapabilityStatusList(caps); } diff --git a/migration/migration.c b/migration/migration.c index 713f070..91fe885 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -584,14 +584,15 @@ static void populate_disk_info(MigrationInfo *info) } } =20 -MigrationInfo *qmp_query_migrate(Error **errp) +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) { case MIGRATION_STATUS_NONE: /* no migration has happened ever */ + /* do not overwrite destination migration status */ + return; break; case MIGRATION_STATUS_SETUP: info->has_status =3D true; @@ -640,8 +641,6 @@ MigrationInfo *qmp_query_migrate(Error **errp) break; } info->status =3D s->state; - - return info; } =20 /** @@ -705,6 +704,41 @@ static bool migrate_caps_check(bool *cap_list, return true; } =20 +static void fill_destination_migration_info(MigrationInfo *info) +{ + MigrationIncomingState *mis =3D migration_incoming_get_current(); + + switch (mis->state) { + case MIGRATION_STATUS_NONE: + return; + 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; +} + +MigrationInfo *qmp_query_migrate(Error **errp) +{ + MigrationInfo *info =3D g_malloc0(sizeof(*info)); + + fill_destination_migration_info(info); + fill_source_migration_info(info); + + return info; +} + void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params, Error **errp) { diff --git a/migration/migration.h b/migration/migration.h index 2bae992..cb68768 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -71,6 +71,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 #define TYPE_MIGRATION "migration" =20 diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 2e10870..a203bae 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -108,6 +108,55 @@ 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 populates MigrationInfo from postcopy's + * blocktime context. It will not populate MigrationInfo, + * unless postcopy-blocktime capability was set. + * + * @info: pointer to MigrationInfo to populate + */ +void fill_destination_postcopy_migration_info(MigrationInfo *info) +{ + MigrationIncomingState *mis =3D migration_incoming_get_current(); + PostcopyBlocktimeContext *bc =3D mis->blocktime_ctx; + + if (!bc) { + return; + } + + info->has_postcopy_blocktime =3D true; + info->postcopy_blocktime =3D bc->total_blocktime; + info->has_postcopy_vcpu_blocktime =3D true; + info->postcopy_vcpu_blocktime =3D get_vcpu_blocktime_list(bc); +} + +static uint64_t get_postcopy_total_blocktime(void) +{ + MigrationIncomingState *mis =3D migration_incoming_get_current(); + PostcopyBlocktimeContext *bc =3D mis->blocktime_ctx; + + if (!bc) { + return 0; + } + + return bc->total_blocktime; +} + /** * receive_ufd_features: check userfault fd features, to request only supp= orted * features in the future. @@ -482,6 +531,9 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingStat= e *mis) munmap(mis->postcopy_tmp_zero_page, mis->largest_page_size); mis->postcopy_tmp_zero_page =3D NULL; } + trace_postcopy_ram_incoming_cleanup_blocktime( + get_postcopy_total_blocktime()); + trace_postcopy_ram_incoming_cleanup_exit(); return 0; } @@ -958,6 +1010,10 @@ void *postcopy_get_tmp_page(MigrationIncomingState *m= is) =20 #else /* No target OS support, stubs just fail */ +void fill_destination_postcopy_migration_info(MigrationInfo *info) +{ +} + 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 b0c8708..f667981 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -198,6 +198,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/migration.json b/qapi/migration.json index 0f2af26..bf19984 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -150,6 +150,13 @@ # @status is 'failed'. Clients should not attempt to parse the # error strings. (Since 2.7) # +# @postcopy-blocktime: total time when all vCPU were blocked during postco= py +# live migration (Since 2.11) +# +# @postcopy-vcpu-blocktime: list of the postcopy blocktime per vCPU (Since= 2.11) +# + +# # Since: 0.14.0 ## { 'struct': 'MigrationInfo', @@ -161,7 +168,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 2.7.4