From nobody Mon Apr 29 08:22:01 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.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 149553992432771.35998381532647; Tue, 23 May 2017 04:45:24 -0700 (PDT) Received: from localhost ([::1]:47902 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD8Fe-0001bR-MV for importer@patchew.org; Tue, 23 May 2017 07:45:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD82F-0006gK-Je for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dD82D-0003dU-BJ for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:31 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:24889) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dD82D-0003d3-5a for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:29 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OQE0007FLCFX870@mailout1.w1.samsung.com> for qemu-devel@nongnu.org; Tue, 23 May 2017 12:31:27 +0100 (BST) Received: from eusmges5.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170523113127eucas1p12287e534e1f4e8f3cc014e1971773da1~BOOBUS7CW1979719797eucas1p1I; Tue, 23 May 2017 11:31:27 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges5.samsung.com (EUCPMTA) with SMTP id 1D.B0.25577.F8D14295; Tue, 23 May 2017 12:31:27 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170523113126eucas1p163c64fe50bd44026fdf4d36716bfc4f2~BOOAuPgIt0479904799eucas1p1-; Tue, 23 May 2017 11:31:26 +0000 (GMT) Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id FF.C1.20206.E8D14295; Tue, 23 May 2017 12:31:26 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OQE003QBLC1VWB0@eusync3.samsung.com>; Tue, 23 May 2017 12:31:26 +0100 (BST) X-AuditID: cbfec7f5-f792f6d0000063e9-1f-59241d8fdf1d From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Tue, 23 May 2017 14:31:02 +0300 Message-id: <1495539071-12995-2-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1495539071-12995-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrNIsWRmVeSWpSXmKPExsWy7djP87r9siqRBpsWclrMvXuexaJ32z12 i4lv17NaXGn/yW6xZf83dovjvTtYHNg8nlzbzOTxft9VNo++LasYA5ijuGxSUnMyy1KL9O0S uDIuzcgtWM5ecb7vHWsD43fWLkZODgkBE4lVc3exQ9hiEhfurWfrYuTiEBJYyihxZP1rFgjn M6PE55332GA6mtZ3MUIkljFKTJ/ZyArhdDNJ9K7bCpTh4GATMJDYd88WpEFEQFLid9dpZpAa ZoFmRolDj38ygySEBUIkv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CKlE CvGmJFZWpRblxxeV5qQWH2I0BbppIrOUaHI+MJLySuINTQzNLQ2NjC0szI2MlMR5p364Ei4k kJ5YkpqdmlqQWgTTx8TBKdXAKLj7rIugPP+kcsbUOV+fCYuYbrks+C11RgzHIe4dfH3/NlTK xce7yH4Syt198cenHmEX1/IWHqb2Aw5r7ryZ4XxfYrVRZ1O4k8r1ZTOmuB87uPieVgCPYrzi vZzMxWsl/c9bnbCXTl28zaFaJvm7VMyySZ03Xsy6PlfqckrynZmrfAwtWH23K7EUZyQaajEX FScCAMGRp51sAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170523113126eucas1p163c64fe50bd44026fdf4d36716bfc4f2 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-HopCount: 7 X-CMS-RootMailID: 20170523113126eucas1p163c64fe50bd44026fdf4d36716bfc4f2 X-RootMTR: 20170523113126eucas1p163c64fe50bd44026fdf4d36716bfc4f2 References: <1495539071-12995-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 V6 01/10] userfault: add pid into uffd_msg & update UFFD_FEATURE_* 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, Alexey Perevalov 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 commit duplicates header of "userfaultfd: provide pid in userfault msg" into linux kernel. Signed-off-by: Alexey Perevalov --- linux-headers/linux/userfaultfd.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/linux-headers/linux/userfaultfd.h b/linux-headers/linux/userfa= ultfd.h index 2ed5dc3..e7c8898 100644 --- a/linux-headers/linux/userfaultfd.h +++ b/linux-headers/linux/userfaultfd.h @@ -77,6 +77,9 @@ struct uffd_msg { struct { __u64 flags; __u64 address; + union { + __u32 ptid; + } feat; } pagefault; =20 struct { @@ -158,6 +161,8 @@ struct uffdio_api { #define UFFD_FEATURE_EVENT_MADVDONTNEED (1<<3) #define UFFD_FEATURE_MISSING_HUGETLBFS (1<<4) #define UFFD_FEATURE_MISSING_SHMEM (1<<5) +#define UFFD_FEATURE_EVENT_UNMAP (1<<6) +#define UFFD_FEATURE_THREAD_ID (1<<7) __u64 features; =20 __u64 ioctls; --=20 1.8.3.1 From nobody Mon Apr 29 08:22:01 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.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 1495540191824470.80815837061414; Tue, 23 May 2017 04:49:51 -0700 (PDT) Received: from localhost ([::1]:47936 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD8Jx-0005JC-Hj for importer@patchew.org; Tue, 23 May 2017 07:49:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48824) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD82M-0006mf-DQ for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dD82I-0003gX-3G for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:38 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:29807) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dD82H-0003eu-QN for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:34 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OQE00088LCGQB70@mailout3.w1.samsung.com> for qemu-devel@nongnu.org; Tue, 23 May 2017 12:31:28 +0100 (BST) Received: from eusmges2.samsung.com (unknown [203.254.199.241]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170523113128eucas1p145de69af044ae3eb3873eed185fb2df7~BOOB9Tesj1979719797eucas1p1K; Tue, 23 May 2017 11:31:28 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2.samsung.com (EUCPMTA) with SMTP id 3A.54.04459.F8D14295; Tue, 23 May 2017 12:31:27 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170523113127eucas1p22dba0fddcc9bcf70e554bf659272f947~BOOBUmp8A0956409564eucas1p2O; Tue, 23 May 2017 11:31:27 +0000 (GMT) Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 80.D1.20206.F8D14295; Tue, 23 May 2017 12:31:27 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OQE003QBLC1VWB0@eusync3.samsung.com>; Tue, 23 May 2017 12:31:27 +0100 (BST) X-AuditID: cbfec7f1-f796e6d00000116b-be-59241d8f3a46 From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Tue, 23 May 2017 14:31:03 +0300 Message-id: <1495539071-12995-3-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1495539071-12995-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrDIsWRmVeSWpSXmKPExsWy7djP87r9siqRBlv2G1nMvXuexaJ32z12 i4lv17NaXGn/yW6xZf83dovjvTtYHNg8nlzbzOTxft9VNo++LasYA5ijuGxSUnMyy1KL9O0S uDKOrTrIWPBNpmLRN98GxgbxLkZODgkBE4k3J2awQthiEhfurWfrYuTiEBJYyihx8/1aVgjn M6PEwQln2GE6Dvx5CVW1jFFi08JlLBBON5PEsue/gao4ONgEDCT23bMFaRARkJT43XWaGaSG WaCZUeLQ45/MIAlhgSSJ8/Pugu1mEVCVWH74L9gGXgF3iZurn0Ftk5M4eWwyWA2ngIfEu8P3 wJZJCNxnk9i2+AkbyDIJAVmJTQeYIepdJM6/mAdlC0u8Or4Fao6MxOXJ3VC97YwS3Ts7WSGc CYwSZ6b/haqylzh18yoTiM0swCcxadt0ZogFvBIdbUIQJR4Sa7tXMULYjhIznvxigvh+NqPE ovVnWCYwyixgZFjFKJJaWpybnlpspFecmFtcmpeul5yfu4kRGKen/x3/uIPx/QmrQ4wCHIxK PLwaj5UihVgTy4orcw8xSnAwK4nw+gipRArxpiRWVqUW5ccXleakFh9ilOZgURLn5Tp1LUJI ID2xJDU7NbUgtQgmy8TBKdXAWKf97vES+e+PROalMJ+JbXksWHzj0VbuN75s/suuLvhpvV5S RJpV+PHG9a8/zj32SHR93uFCI/XfKq37hOcd0Oc349jO3NZSueI6M9vE5bwrkk4ov5vfvu0h EzfjgVfRdxo8OHO2rd4Vznry6eEN7DyRtdmPmYxrv0yt+/yEL0jemavWcJ3kUSWW4oxEQy3m ouJEAJ8a3KPPAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrJLMWRmVeSWpSXmKPExsVy+t/xq7r9siqRBttucFrMvXuexaJ32z12 i4lv17NaXGn/yW6xZf83dovjvTtYHNg8nlzbzOTxft9VNo++LasYA5ij3GwyUhNTUosUUvOS 81My89JtlUJD3HQtlBTyEnNTbZUidH1DgpQUyhJzSoE8IwM04OAc4B6spG+X4JZxbNVBxoJv MhWLvvk2MDaIdzFyckgImEgc+POSDcIWk7hwbz2QzcUhJLCEUWLHxgeMIAkhgV4mibOrPLsY OTjYBAwk9t2zBQmLCEhK/O46zQxSzyzQzCjRuroNbJCwQJLE+Xl3WUFsFgFVieWH/7KD2LwC 7hI3Vz9jh1gmJ3Hy2GSwGk4BD4l3h++xQOxylzg98TrrBEbeBYwMqxhFUkuLc9Nzi430ihNz i0vz0vWS83M3MQKDdduxn1t2MHa9Cz7EKMDBqMTDq/FYKVKINbGsuDL3EKMEB7OSCK+PkEqk EG9KYmVValF+fFFpTmrxIUZToKMmMkuJJucDIymvJN7QxNDc0tDI2MLC3MhISZx36ocr4UIC 6YklqdmpqQWpRTB9TBycUg2M290uCPExdyqwfpt7oVVIxOlNyXY2u8vqtUcSAxUiP1aZ8sWv VmG2+6T5qn9JyKG135k8nO9evbWLq/GsTqh5bfRK2xT3FDVjWenaKDEpieNv9bsZpd4Up/F8 fPKW239u1WPrsxP85XpvTzv2bGfbHJ7vCR8OO/+xzm1dd/+BzhSJ6l8TZ5QqsRRnJBpqMRcV JwIAvWRQSmwCAAA= X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170523113127eucas1p22dba0fddcc9bcf70e554bf659272f947 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-HopCount: 7 X-CMS-RootMailID: 20170523113127eucas1p22dba0fddcc9bcf70e554bf659272f947 X-RootMTR: 20170523113127eucas1p22dba0fddcc9bcf70e554bf659272f947 References: <1495539071-12995-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.13 Subject: [Qemu-devel] [PATCH V6 02/10] migration: pass MigrationIncomingState* into migration check functions 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, Alexey Perevalov 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" That tiny refactoring is necessary to be able to set UFFD_FEATURE_THREAD_ID while requesting features, and then to create downtime context in case when kernel supports it. Signed-off-by: Alexey Perevalov --- migration/migration.c | 2 +- migration/postcopy-ram.c | 10 +++++----- migration/postcopy-ram.h | 2 +- migration/savevm.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 0304c01..d735976 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -789,7 +789,7 @@ void qmp_migrate_set_capabilities(MigrationCapabilitySt= atusList *params, * special support. */ if (!old_postcopy_cap && runstate_check(RUN_STATE_INMIGRATE) && - !postcopy_ram_supported_by_host()) { + !postcopy_ram_supported_by_host(NULL)) { /* postcopy_ram_supported_by_host will have emitted a more * detailed message */ diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index a0489f6..4adab36 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -59,7 +59,7 @@ struct PostcopyDiscardState { #include #include =20 -static bool ufd_version_check(int ufd) +static bool ufd_version_check(int ufd, MigrationIncomingState *mis) { struct uffdio_api api_struct; uint64_t ioctl_mask; @@ -112,7 +112,7 @@ static int test_range_shared(const char *block_name, vo= id *host_addr, * normally fine since if the postcopy succeeds it gets turned back on at = the * end. */ -bool postcopy_ram_supported_by_host(void) +bool postcopy_ram_supported_by_host(MigrationIncomingState *mis) { long pagesize =3D getpagesize(); int ufd =3D -1; @@ -135,7 +135,7 @@ bool postcopy_ram_supported_by_host(void) } =20 /* Version and features check */ - if (!ufd_version_check(ufd)) { + if (!ufd_version_check(ufd, mis)) { goto out; } =20 @@ -512,7 +512,7 @@ int postcopy_ram_enable_notify(MigrationIncomingState *= mis) * Although the host check already tested the API, we need to * do the check again as an ABI handshake on the new fd. */ - if (!ufd_version_check(mis->userfault_fd)) { + if (!ufd_version_check(mis->userfault_fd, mis)) { return -1; } =20 @@ -650,7 +650,7 @@ void *postcopy_get_tmp_page(MigrationIncomingState *mis) =20 #else /* No target OS support, stubs just fail */ -bool postcopy_ram_supported_by_host(void) +bool postcopy_ram_supported_by_host(MigrationIncomingState *mis) { error_report("%s: No OS support", __func__); return false; diff --git a/migration/postcopy-ram.h b/migration/postcopy-ram.h index 52d51e8..587a8b8 100644 --- a/migration/postcopy-ram.h +++ b/migration/postcopy-ram.h @@ -14,7 +14,7 @@ #define QEMU_POSTCOPY_RAM_H =20 /* Return true if the host supports everything we need to do postcopy-ram = */ -bool postcopy_ram_supported_by_host(void); +bool postcopy_ram_supported_by_host(MigrationIncomingState *mis); =20 /* * Make all of RAM sensitive to accesses to areas that haven't yet been wr= itten diff --git a/migration/savevm.c b/migration/savevm.c index f5e8194..61a6df7 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1356,7 +1356,7 @@ static int loadvm_postcopy_handle_advise(MigrationInc= omingState *mis) return -1; } =20 - if (!postcopy_ram_supported_by_host()) { + if (!postcopy_ram_supported_by_host(mis)) { postcopy_state_set(POSTCOPY_INCOMING_NONE); return -1; } --=20 1.8.3.1 From nobody Mon Apr 29 08:22:01 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.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 1495540694879526.2825149378284; Tue, 23 May 2017 04:58:14 -0700 (PDT) Received: from localhost ([::1]:48033 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD8S5-00036c-NC for importer@patchew.org; Tue, 23 May 2017 07:58:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48778) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD82L-0006ll-As for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dD82H-0003fb-F7 for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:37 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:54528) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dD82H-0003eh-9R for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:33 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OQE0031GLCGDF70@mailout4.w1.samsung.com> for qemu-devel@nongnu.org; Tue, 23 May 2017 12:31:28 +0100 (BST) Received: from eusmges5.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170523113128eucas1p231809c442033b0462307d87f061362ee~BOOCYXyds0795307953eucas1p2U; Tue, 23 May 2017 11:31:28 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges5.samsung.com (EUCPMTA) with SMTP id 8D.B0.25577.09D14295; Tue, 23 May 2017 12:31:28 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170523113127eucas1p1b6cebc0fc51a056b8c1a983d375f1012~BOOBr5EBX0479504795eucas1p19; Tue, 23 May 2017 11:31:27 +0000 (GMT) Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id BA.AB.17452.F8D14295; Tue, 23 May 2017 12:31:27 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OQE003QBLC1VWB0@eusync3.samsung.com>; Tue, 23 May 2017 12:31:27 +0100 (BST) X-AuditID: cbfec7f5-f792f6d0000063e9-21-59241d90aa44 From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Tue, 23 May 2017 14:31:04 +0300 Message-id: <1495539071-12995-4-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1495539071-12995-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4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spG+X4JbxrGUfW8E8 tor5m44xNTD+Zuli5OSQEDCROPNxLzOELSZx4d56ti5GLg4hgSWMEs2/FjGBJIQEepkkzq7y 7GLk4GATMJDYd88WJCwiICnxu+s0M0g9s0Azo0Tr6jY2kISwQIDE572LwBawCKhKbFu8gB2k l1fAXeLLND+IXXISJ49NZgWxOQU8JN4dvscCscpd4vTE66wTGHkXMDKsYhRJLS3OTc8tNtQr TswtLs1L10vOz93ECAzWbcd+bt7BeGlj8CFGAQ5GJR5ejcdKkUKsiWXFlbmHGCU4mJVEeH2E VCKFeFMSK6tSi/Lji0pzUosPMZoC3TSRWUo0OR8YSXkl8YYmhuaWhkbGFhbmRkZK4rwlH66E CwmkJ5akZqemFqQWwfQxcXBKNTBWK+x2/7W7cXqyWmO5nYTps8Lp3/SKT82e0v6+uOlizsM0 7+Q1k3a9yZOavMHJ/sAORV+/aXe8r9iIRHT89e3S+BDc2bX7mZ3GymTNz6Y868LWH3rfLROy 81e/mdkBZx020alReqxvnHXmcnH+0rkdwm21f8GBli+qUl5Xb+j+sPnT8qOa7bsSS3FGoqEW c1FxIgAaoDq4bAIAAA== X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170523113127eucas1p1b6cebc0fc51a056b8c1a983d375f1012 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: 20170523113127eucas1p1b6cebc0fc51a056b8c1a983d375f1012 X-RootMTR: 20170523113127eucas1p1b6cebc0fc51a056b8c1a983d375f1012 References: <1495539071-12995-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.14 Subject: [Qemu-devel] [PATCH V6 03/10] migration: fix hardcoded function name in error report 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, Alexey Perevalov 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 --- migration/postcopy-ram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 4adab36..3ed78bf 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -67,7 +67,7 @@ static bool ufd_version_check(int ufd, MigrationIncomingS= tate *mis) api_struct.api =3D UFFD_API; api_struct.features =3D 0; if (ioctl(ufd, UFFDIO_API, &api_struct)) { - error_report("postcopy_ram_supported_by_host: UFFDIO_API failed: %= s", + error_report("%s: UFFDIO_API failed: %s", __func__ strerror(errno)); return false; } --=20 1.8.3.1 From nobody Mon Apr 29 08:22:01 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.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 149554086822190.87028251395964; Tue, 23 May 2017 05:01:08 -0700 (PDT) Received: from localhost ([::1]:48119 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD8Ur-0004nX-RR for importer@patchew.org; Tue, 23 May 2017 08:01:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48799) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD82L-0006mG-Qy for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dD82H-0003gA-SG for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:37 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:43229) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dD82H-0003er-L1 for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:33 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OQE0013QLCHCV70@mailout2.w1.samsung.com> for qemu-devel@nongnu.org; Tue, 23 May 2017 12:31:29 +0100 (BST) Received: from eusmges4.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170523113129eucas1p2e7334beca347fd2cb237b7e6fa08df21~BOOC4f_bV1787917879eucas1p2T; Tue, 23 May 2017 11:31:29 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges4.samsung.com (EUCPMTA) with SMTP id EF.C2.04729.09D14295; Tue, 23 May 2017 12:31:28 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170523113128eucas1p17a89f8cb47d5731c50f94c3218ba155f~BOOCSG3fv0479504795eucas1p1_; Tue, 23 May 2017 11:31:28 +0000 (GMT) Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 2B.AB.17452.09D14295; Tue, 23 May 2017 12:31:28 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OQE003QBLC1VWB0@eusync3.samsung.com>; Tue, 23 May 2017 12:31:28 +0100 (BST) X-AuditID: cbfec7f4-f79806d000001279-b5-59241d90adb6 From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Tue, 23 May 2017 14:31:05 +0300 Message-id: <1495539071-12995-5-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1495539071-12995-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrNIsWRmVeSWpSXmKPExsWy7djP87oTZFUiDdovGlrMvXuexaJ32z12 i4lv17NaXGn/yW6xZf83dovjvTtYHNg8nlzbzOTxft9VNo++LasYA5ijuGxSUnMyy1KL9O0S uDJ6thxlLFinVbG4dRtLA+MO+S5GTg4JAROJeYdaWSFsMYkL99azdTFycQgJLGWU6H+3kAXC +cwo8f/0aiaYjicTvjCC2EICyxgl/sDY3UwSZ+a7dTFycLAJGEjsu2cLEhYRkJT43XWaGWQO s0Azo8Shxz+ZQRLCAokSl2ceBdvMIqAq0brsPzuIzSvgLrFhzRQ2iF1yEiePTQar4RTwkHh3 +B7YQRIC99kkvh7aywqyTEJAVmLTAWaIeheJfYcfQdnCEq+Ob2GHsGUkOjsOMkH0tjNKdO/s ZIVwJjBKnJn+F6rKXuLUzatgXzIL8ElM2jadGWIBr0RHmxBEiYfEgUlTocodJdZc38oKCaHZ jBJfT61jm8Aos4CRYRWjSGppcW56arGJXnFibnFpXrpecn7u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Zqb7f6P5porJxmrlOx2bmzwSdi5s15rc8v1SOMmcyn58IRj+wqUWIozEg21mIuK EwEkYa3obQIAAA== X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170523113128eucas1p17a89f8cb47d5731c50f94c3218ba155f 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: 20170523113128eucas1p17a89f8cb47d5731c50f94c3218ba155f X-RootMTR: 20170523113128eucas1p17a89f8cb47d5731c50f94c3218ba155f References: <1495539071-12995-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.12 Subject: [Qemu-devel] [PATCH V6 04/10] migration: split ufd_version_check onto receive/request features part 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, Alexey Perevalov 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 modification is necessary for userfault fd features which are required to be requested from userspace. UFFD_FEATURE_THREAD_ID is a one of such "on demand" feature, which will be introduced in the next patch. QEMU have to use separate userfault file descriptor, due to userfault context has internal state, and after first call of ioctl UFFD_API it changes its state to UFFD_STATE_RUNNING (in case of success), but kernel while handling ioctl UFFD_API expects UFFD_STATE_WAIT_= API. So only one ioctl with UFFD_API is possible per ufd. Signed-off-by: Alexey Perevalov --- migration/postcopy-ram.c | 100 ++++++++++++++++++++++++++++++++++++++++++-= ---- 1 file changed, 91 insertions(+), 9 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 3ed78bf..4f3f495 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -59,32 +59,114 @@ struct PostcopyDiscardState { #include #include =20 -static bool ufd_version_check(int ufd, MigrationIncomingState *mis) + +/** + * receive_ufd_features: check userfault fd features, to request only supp= orted + * features in the future. + * + * Returns: true on success + * + * __NR_userfaultfd - should be checked before + * @features: out parameter will contain uffdio_api.features provided by = kernel + * in case of success + */ +static bool receive_ufd_features(uint64_t *features) { - struct uffdio_api api_struct; - uint64_t ioctl_mask; + struct uffdio_api api_struct =3D {0}; + int ufd; + bool ret =3D true; + + /* if we are here __NR_userfaultfd should exists */ + ufd =3D syscall(__NR_userfaultfd, O_CLOEXEC); + if (ufd =3D=3D -1) { + error_report("%s: syscall __NR_userfaultfd failed: %s", __func__, + strerror(errno)); + return false; + } =20 + /* ask features */ api_struct.api =3D UFFD_API; api_struct.features =3D 0; if (ioctl(ufd, UFFDIO_API, &api_struct)) { - error_report("%s: UFFDIO_API failed: %s", __func__ + error_report("%s: UFFDIO_API failed: %s", __func__, strerror(errno)); + ret =3D false; + goto release_ufd; + } + + *features =3D api_struct.features; + +release_ufd: + close(ufd); + return ret; +} + +/** + * request_ufd_features: this function should be called only once on a new= ly + * opened ufd, subsequent calls will lead to error. + * + * Returns: true on succes + * + * @ufd: fd obtained from userfaultfd syscall + * @features: bit mask see UFFD_API_FEATURES + */ +static bool request_ufd_features(int ufd, uint64_t features) +{ + struct uffdio_api api_struct =3D {0}; + uint64_t ioctl_mask; + + api_struct.api =3D UFFD_API; + api_struct.features =3D features; + if (ioctl(ufd, UFFDIO_API, &api_struct)) { + error_report("%s failed: UFFDIO_API failed: %s", __func__, + strerror(errno)); return false; } =20 - ioctl_mask =3D (__u64)1 << _UFFDIO_REGISTER | - (__u64)1 << _UFFDIO_UNREGISTER; + ioctl_mask =3D 1 << _UFFDIO_REGISTER | + 1 << _UFFDIO_UNREGISTER; if ((api_struct.ioctls & ioctl_mask) !=3D ioctl_mask) { error_report("Missing userfault features: %" PRIx64, (uint64_t)(~api_struct.ioctls & ioctl_mask)); return false; } =20 + return true; +} + +static bool ufd_check_and_apply(int ufd, MigrationIncomingState *mis) +{ + uint64_t asked_features =3D 0; + static uint64_t supported_features; + + /* + * it's not possible to + * request UFFD_API twice per one fd + * userfault fd features is persistent + */ + if (!supported_features) { + if (!receive_ufd_features(&supported_features)) { + error_report("%s failed", __func__); + return false; + } + } + + /* + * request features, even if asked_features is 0, due to + * kernel expects UFFD_API before UFFDIO_REGISTER, per + * userfault file descriptor + */ + if (!request_ufd_features(ufd, asked_features)) { + error_report("%s failed: features %" PRIu64, __func__, + asked_features); + return false; + } + if (getpagesize() !=3D ram_pagesize_summary()) { bool have_hp =3D false; /* We've got a huge page */ #ifdef UFFD_FEATURE_MISSING_HUGETLBFS - have_hp =3D api_struct.features & UFFD_FEATURE_MISSING_HUGETLBFS; + have_hp =3D supported_features & UFFD_FEATURE_MISSING_HUGETLBFS; #endif if (!have_hp) { error_report("Userfault on this host does not support huge pag= es"); @@ -135,7 +217,7 @@ bool postcopy_ram_supported_by_host(MigrationIncomingSt= ate *mis) } =20 /* Version and features check */ - if (!ufd_version_check(ufd, mis)) { + if (!ufd_check_and_apply(ufd, mis)) { goto out; } =20 @@ -512,7 +594,7 @@ int postcopy_ram_enable_notify(MigrationIncomingState *= mis) * Although the host check already tested the API, we need to * do the check again as an ABI handshake on the new fd. */ - if (!ufd_version_check(mis->userfault_fd, mis)) { + if (!ufd_check_and_apply(mis->userfault_fd, mis)) { return -1; } =20 --=20 1.8.3.1 From nobody Mon Apr 29 08:22:01 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.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 1495540761826358.33367654659116; Tue, 23 May 2017 04:59:21 -0700 (PDT) Received: from localhost ([::1]:48035 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD8T9-0003d4-Dx for importer@patchew.org; Tue, 23 May 2017 07:59:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48788) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD82L-0006lz-Hj for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dD82H-0003fr-Kl for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:37 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:54528) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dD82H-0003eh-Fn for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:33 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OQE0024TLCJWO70@mailout4.w1.samsung.com> for qemu-devel@nongnu.org; Tue, 23 May 2017 12:31:31 +0100 (BST) Received: from eusmges4.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170523113130eucas1p2df69edd3cfcb9c7478ef8faac13256a7~BOOEeBv-20955109551eucas1p2V; Tue, 23 May 2017 11:31:30 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges4.samsung.com (EUCPMTA) with SMTP id B0.D2.04729.19D14295; Tue, 23 May 2017 12:31:30 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170523113129eucas1p2146e1018e660eed0b319cbe22adc2712~BOODF8gn10301003010eucas1p2o; Tue, 23 May 2017 11:31:29 +0000 (GMT) Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 93.D1.20206.19D14295; Tue, 23 May 2017 12:31:29 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OQE003QBLC1VWB0@eusync3.samsung.com>; Tue, 23 May 2017 12:31:29 +0100 (BST) X-AuditID: cbfec7f4-f79806d000001279-b7-59241d9189e6 From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Tue, 23 May 2017 14:31:06 +0300 Message-id: <1495539071-12995-6-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1495539071-12995-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrNIsWRmVeSWpSXmKPExsWy7djPc7qTZFUiDQ5PVrCYe/c8i0Xvtnvs FhPfrme1uNL+k91iy/5v7BbHe3ewOLB5PLm2mcnj/b6rbB59W1YxBjBHcdmkpOZklqUW6dsl cGWc6m9mLDgkVDH1eRd7A+My/i5GDg4JAROJF7OLuhg5gUwxiQv31rN1MXJxCAksZZRY1PGG HcL5zCjR3X+AEaLKRGLHidksEIlljBIrlp1mhHC6mSQ2vL7PDDKWTcBAYt89W5AGEQFJ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g7HoXfIhRgINRiYdX47FSpBBrYllxZe4hRgkOZiURXh8h lUgh3pTEyqrUovz4otKc1OJDjKZAN01klhJNzgfGUl5JvKGJobmloZGxhYW5kZGSOO/UD1fC hQTSE0tSs1NTC1KLYPqYODilGhjDJeqezsyc9fB2vbdKifykWTZunTUMt1tMCqzltKM/iMgE 9YlWN09lZPCsmipnYqfklFTo+mTR7pe8Hb/STzB9SH3PbbAnxk/xuLa9YQpX+mrzjW8Z74dU 2N9YP/nHgVvLf+pNYbxb9/v9l9nNT19JNiZF7P2hOCWup/OBn/GBFMailznhu5RYijMSDbWY i4oTAUfAihJtAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170523113129eucas1p2146e1018e660eed0b319cbe22adc2712 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-HopCount: 7 X-CMS-RootMailID: 20170523113129eucas1p2146e1018e660eed0b319cbe22adc2712 X-RootMTR: 20170523113129eucas1p2146e1018e660eed0b319cbe22adc2712 References: <1495539071-12995-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.14 Subject: [Qemu-devel] [PATCH V6 05/10] 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: i.maximets@samsung.com, dgilbert@redhat.com, peterx@redhat.com, Alexey Perevalov 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 --- include/migration/migration.h | 1 + migration/migration.c | 9 +++++++++ qapi-schema.json | 5 ++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 49ec501..2951253 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -270,6 +270,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_message(MigrationIncomingState *mis, diff --git a/migration/migration.c b/migration/migration.c index d735976..e10284e 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1341,6 +1341,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/qapi-schema.json b/qapi-schema.json index 80603cf..78617fe 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -894,11 +894,14 @@ # @release-ram: if enabled, qemu will free the migrated ram pages on the s= ource # during postcopy-ram migration. (since 2.9) # +# @postcopy-blocktime: Calculate downtime for postcopy live migration (sin= ce 2.10) +# # Since: 1.2 ## { 'enum': 'MigrationCapability', 'data': ['xbzrle', 'rdma-pin-all', 'auto-converge', 'zero-blocks', - 'compress', 'events', 'postcopy-ram', 'x-colo', 'release-ram'] } + 'compress', 'events', 'postcopy-ram', 'x-colo', 'release-ram', + 'postcopy-blocktime'] } =20 ## # @MigrationCapabilityStatus: --=20 1.8.3.1 From nobody Mon Apr 29 08:22:01 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.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 14955401026041001.6120642434236; Tue, 23 May 2017 04:48:22 -0700 (PDT) Received: from localhost ([::1]:47927 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD8IX-0004BE-71 for importer@patchew.org; Tue, 23 May 2017 07:48:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48802) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD82L-0006mH-Rt for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dD82I-0003gS-34 for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:37 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:43229) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dD82H-0003er-Td for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:34 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OQE0013SLCICV70@mailout2.w1.samsung.com> for qemu-devel@nongnu.org; Tue, 23 May 2017 12:31:30 +0100 (BST) Received: from eusmges5.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170523113130eucas1p17c009c4e777cda0ad81ceb1092206883~BOOEJveLy1797117971eucas1p1k; Tue, 23 May 2017 11:31:30 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges5.samsung.com (EUCPMTA) with SMTP id 7E.B0.25577.29D14295; Tue, 23 May 2017 12:31:30 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170523113129eucas1p179082f20f41d1069f5fbd0f37535fae9~BOODebW120479504795eucas1p1F; Tue, 23 May 2017 11:31:29 +0000 (GMT) Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id CB.AB.17452.19D14295; Tue, 23 May 2017 12:31:29 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OQE003QBLC1VWB0@eusync3.samsung.com>; Tue, 23 May 2017 12:31:29 +0100 (BST) X-AuditID: cbfec7f5-f792f6d0000063e9-27-59241d928f98 From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Tue, 23 May 2017 14:31:07 +0300 Message-id: <1495539071-12995-7-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1495539071-12995-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrLIsWRmVeSWpSXmKPExsWy7djP87qTZFUiDdYf4raYe/c8i0Xvtnvs FhPfrme1uNL+k91iy/5v7BbHe3ewOLB5PLm2mcnj/b6rbB59W1YxBjBHcdmkpOZklqUW6dsl cGVcerGfveCUT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sGZhgViJbYsus4PYLAKqEt9XNzCC2LwC 7hLLJk9ihVgmJ3Hy2GQwm1PAQ+Ld4XssEIvdJU5PvM46gZF3ASPDKkaR1NLi3PTcYkO94sTc 4tK8dL3k/NxNjMBw3Xbs5+YdjJc2Bh9iFOBgVOLh1XisFCnEmlhWXJl7iFGCg1lJhNdHSCVS iDclsbIqtSg/vqg0J7X4EKMp0FETmaVEk/OBsZRXEm9oYmhuaWhkbGFhbmSkJM5b8uFKuJBA emJJanZqakFqEUwfEwenVANjyoWcnwFfPVqjjrb49U2et+oiq/Iig18LvoifvPOAZWXVVSaX ol3rW9Ri2Q5+XlUT8Dgr4XLMhOYC7k+T2rqfLKyb/iD53aWKx5tdPqt5KKh987fMXh4rc6rh /ofHi6TL97MserH67Ldf1zcfOLJZUWYbS4H9vfX3P9xTz51xXcMkI/R8fO+JdCWW4oxEQy3m ouJEAHl2QNRtAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170523113129eucas1p179082f20f41d1069f5fbd0f37535fae9 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: 20170523113129eucas1p179082f20f41d1069f5fbd0f37535fae9 X-RootMTR: 20170523113129eucas1p179082f20f41d1069f5fbd0f37535fae9 References: <1495539071-12995-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.12 Subject: [Qemu-devel] [PATCH V6 06/10] 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: i.maximets@samsung.com, dgilbert@redhat.com, peterx@redhat.com, Alexey Perevalov 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 --- include/migration/migration.h | 8 +++++ migration/postcopy-ram.c | 80 +++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 88 insertions(+) diff --git a/include/migration/migration.h b/include/migration/migration.h index 2951253..449cb07 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -57,6 +57,8 @@ enum mig_rp_message_type { =20 typedef QLIST_HEAD(, LoadStateEntry) LoadStateEntry_Head; =20 +struct PostcopyBlocktimeContext; + /* State for the incoming migration */ struct MigrationIncomingState { QEMUFile *from_src_file; @@ -97,6 +99,12 @@ struct MigrationIncomingState { =20 /* See savevm.c */ LoadStateEntry_Head loadvm_handlers; + + /* + * 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 4f3f495..5435a40 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -59,6 +59,73 @@ 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; + /* + * Handler for postcopy event, necessary for + * releasing unnecessary part of blocktime_ctx + */ + Notifier postcopy_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 postcopy_migration_cb(Notifier *n, void *data) +{ + PostcopyBlocktimeContext *ctx =3D container_of(n, PostcopyBlocktimeCon= text, + postcopy_notifier); + MigrationState *s =3D data; + if (migration_has_finished(s) || migration_has_failed(s)) { + g_free(ctx->page_fault_vcpu_time); + /* g_free is NULL robust */ + ctx->page_fault_vcpu_time =3D NULL; + g_free(ctx->vcpu_addr); + ctx->vcpu_addr =3D NULL; + } +} + +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; + ctx->postcopy_notifier.notify =3D postcopy_migration_cb; + qemu_add_exit_notifier(&ctx->exit_notifier); + add_migration_state_change_notifier(&ctx->postcopy_notifier); + return ctx; +} =20 /** * receive_ufd_features: check userfault fd features, to request only supp= orted @@ -151,6 +218,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 1.8.3.1 From nobody Mon Apr 29 08:22:01 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.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 1495540950349831.2821822594974; Tue, 23 May 2017 05:02:30 -0700 (PDT) Received: from localhost ([::1]:48291 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD8W9-0005hz-HJ for importer@patchew.org; Tue, 23 May 2017 08:02:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD82L-0006lr-C1 for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dD82H-0003fa-Ep for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:37 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:24896) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dD82H-0003ez-7D for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:33 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OQE0016WLCJ5K70@mailout1.w1.samsung.com> for qemu-devel@nongnu.org; Tue, 23 May 2017 12:31:31 +0100 (BST) Received: from eusmges3.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170523113131eucas1p1163909297f4e469c03fa696046a6cd76~BOOFAsSTg1972819728eucas1p1T; Tue, 23 May 2017 11:31:31 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3.samsung.com (EUCPMTA) with SMTP id CF.32.17464.39D14295; Tue, 23 May 2017 12:31:31 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170523113130eucas1p1babac9d8659c10abe22ddc7d5b9526ab~BOOESWxGU1797217972eucas1p1k; Tue, 23 May 2017 11:31:30 +0000 (GMT) Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 64.D1.20206.29D14295; Tue, 23 May 2017 12:31:30 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OQE003QBLC1VWB0@eusync3.samsung.com>; Tue, 23 May 2017 12:31:30 +0100 (BST) X-AuditID: cbfec7f2-f797e6d000004438-3f-59241d934f3a From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Tue, 23 May 2017 14:31:08 +0300 Message-id: <1495539071-12995-8-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1495539071-12995-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrNIsWRmVeSWpSXmKPExsWy7djPc7qTZVUiDZ5dZ7WYe/c8i0Xvtnvs FhPfrme1uNL+k91iy/5v7BbHe3ewOLB5PLm2mcnj/b6rbB59W1YxBjBHcdmkpOZklqUW6dsl cGV8/d/EXNBrUPH7ZAdzA+M35S5GTg4JAROJeUe/s0PYYhIX7q1n62Lk4hASWMoosfL/fHYI 5zOjRP/Dl4wwHR8a50JVLWOUmLXjMyuE080kcWhvM5DDwcEmYCCx754tSIOIgKTE767TzCA1 zALNjBKHHv9kBkkIC9hLNL78zQpiswioSsy+vY0FpJdXwF3ixQlXiGVyEiePTQYr4RTwkHh3 +B4LyBwJgftsEv2tO9hA6iUEZCU2HWCGqHeRON44iQ3CFpZ4dXwL1GsyEpcnd0P1tjNKdO/s ZIVwJjBKnJn+F6rKXuLUzatMIDazAJ/EpG3TmSEW8Ep0tAlBmB4Si9YlQFQ7Suzt3cAE8fts Rom+y9NZJzDKLGBkWMUoklpanJueWmysV5yYW1yal66XnJ+7iREYpaf/Hf+0g/HrCatDjAIc jEo8vBqPlSKFWBPLiitzDzFKcDArifD6CKlECvGmJFZWpRblxxeV5qQWH2KU5mBREuflOnUt QkggPbEkNTs1tSC1CCbLxMEp1cCoNathBavO8YKYiJbwuFOqO/jjt55hz/V+dktJ1fTvqZLF PBKmp6vsMt4/i2DgTHL8wB0n8mRqlZAG06dERdEDEzZsXSx35Y3gpg6P9bdefO/TjNd16fw7 VaJk4ivb1+35f64fjQ7b52S28J7Fx5dvV634vN7f7cTmrW7RSdxvT2c85jSIeH9eiaU4I9FQ i7moOBEAN9BqEc4CAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrFLMWRmVeSWpSXmKPExsVy+t/xq7qTZFUiDfbdEbGYe/c8i0Xvtnvs FhPfrme1uNL+k91iy/5v7BbHe3ewOLB5PLm2mcnj/b6rbB59W1YxBjBHudlkpCampBYppOYl 56dk5qXbKoWGuOlaKCnkJeam2ipF6PqGBCkplCXmlAJ5RgZowME5wD1YSd8uwS3j6/8m5oJe g4rfJzuYGxi/KXcxcnJICJhIfGicywZhi0lcuLceyObiEBJYwiix79wyFginl0ni/YPJTF2M HBxsAgYS++7ZgjSICEhK/O46zQxSwyzQzCjRuroNbJKwgL1E48vfrCA2i4CqxOzb21hAenkF 3CVenHCFWCYncfLYZLASTgEPiXeH77GA2EJAJacnXmedwMi7gJFhFaNIamlxbnpusZFecWJu cWleul5yfu4mRmC4bjv2c8sOxq53wYcYBTgYlXh4NR4rRQqxJpYVV+YeYpTgYFYS4fURUokU 4k1JrKxKLcqPLyrNSS0+xGgKdNNEZinR5HxgLOWVxBuaGJpbGhoZW1iYGxkpifNO/XAlXEgg PbEkNTs1tSC1CKaPiYNTqoHRwEf5fJimUejnaNU2sWbN3+scQ+fJh80Q1te+4SDyaoFOzZM/ LCW3Pl+tdphcePL1+oUxe89OOuBxdk/j0cdpeytDVouc380bf0OQw+hF8GT9QtnjD3n2+x6p O5V0cfLuhLmWHycbuf+axrL0hbF86+eEhkXWG5fv83+ZeivdPvUkk+Ap98PxSizFGYmGWsxF xYkAKmi+Jm0CAAA= X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170523113130eucas1p1babac9d8659c10abe22ddc7d5b9526ab 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-HopCount: 7 X-CMS-RootMailID: 20170523113130eucas1p1babac9d8659c10abe22ddc7d5b9526ab X-RootMTR: 20170523113130eucas1p1babac9d8659c10abe22ddc7d5b9526ab References: <1495539071-12995-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 V6 07/10] migration: add bitmap for copied page 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, Alexey Perevalov 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 ability to track down already copied pages, it's necessary for calculation vCPU block time in postcopy migration feature and maybe for restore after postcopy migration failure. Functions which work with RAMBlock are placed into ram.c, due to TARGET_WORDS_BIGENDIAN is poisoned int postcopy-ram.c - hardware independed code. Signed-off-by: Alexey Perevalov --- include/migration/migration.h | 16 +++++++++++ migration/postcopy-ram.c | 22 ++++++++++++--- migration/ram.c | 63 +++++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 97 insertions(+), 4 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 449cb07..4e05c83 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -101,6 +101,20 @@ struct MigrationIncomingState { LoadStateEntry_Head loadvm_handlers; =20 /* + * bitmap indicates whether page copied, + * based on ramblock offset + * now it is using only for blocktime calculation in + * postcopy migration, so livetime of this entry: + * since user requested blocktime calculation, + * till the end of postcopy migration + * as an example it could represend following memory map + * ___________________________________ + * |4k pages | hugepages | 4k pages + * + * */ + unsigned long *copied_pages; + + /* * PostcopyBlocktimeContext to keep information for postcopy * live migration, to calculate vCPU block time * */ @@ -279,6 +293,8 @@ int migrate_compress_threads(void); int migrate_decompress_threads(void); bool migrate_use_events(void); bool migrate_postcopy_blocktime(void); +unsigned long int get_copied_bit_offset(ram_addr_t addr); +unsigned long int *copied_pages_bitmap_new(void); =20 /* Sending on the return path - generic and then for each message type */ void migrate_send_rp_message(MigrationIncomingState *mis, diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 5435a40..d647769 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -94,23 +94,34 @@ static void destroy_blocktime_context(struct PostcopyBl= ocktimeContext *ctx) =20 static void postcopy_migration_cb(Notifier *n, void *data) { - PostcopyBlocktimeContext *ctx =3D container_of(n, PostcopyBlocktimeCon= text, - postcopy_notifier); MigrationState *s =3D data; if (migration_has_finished(s) || migration_has_failed(s)) { + MigrationIncomingState *mis =3D migration_incoming_get_current(); + PostcopyBlocktimeContext *ctx =3D mis->blocktime_ctx; + + if (!ctx) { + return; + } + g_free(ctx->page_fault_vcpu_time); /* g_free is NULL robust */ ctx->page_fault_vcpu_time =3D NULL; g_free(ctx->vcpu_addr); ctx->vcpu_addr =3D NULL; + g_free(mis->copied_pages); + mis->copied_pages =3D NULL; } } =20 static void migration_exit_cb(Notifier *n, void *data) { - PostcopyBlocktimeContext *ctx =3D container_of(n, PostcopyBlocktimeCon= text, - exit_notifier); + MigrationIncomingState *mis =3D migration_incoming_get_current(); + PostcopyBlocktimeContext *ctx =3D mis->blocktime_ctx; + if (!ctx) { + return; + } destroy_blocktime_context(ctx); + mis->blocktime_ctx =3D NULL; } =20 static struct PostcopyBlocktimeContext *blocktime_context_new(void) @@ -227,6 +238,9 @@ static bool ufd_check_and_apply(int ufd, MigrationIncom= ingState *mis) mis->blocktime_ctx =3D blocktime_context_new(); } =20 + if (!mis->copied_pages) { + mis->copied_pages =3D copied_pages_bitmap_new(); + } asked_features |=3D UFFD_FEATURE_THREAD_ID; } #endif diff --git a/migration/ram.c b/migration/ram.c index f59fdd4..1abb6bb 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2661,6 +2661,69 @@ static int ram_load(QEMUFile *f, void *opaque, int v= ersion_id) return ret; } =20 +static unsigned long get_total_bits_per_page(ram_addr_t mem_length, + size_t page_size) +{ + unsigned long page_size_bit =3D find_last_bit((unsigned long *)&page_s= ize, + BITS_PER_LONG); + unsigned long total_bits =3D mem_length >> page_size_bit; + if (mem_length % page_size) { + total_bits +=3D 1; + } + return total_bits; +} + +/* + * this function allocates bitmap for copied pages, + * also it calculates + * how many entries do we need + * */ +unsigned long int *copied_pages_bitmap_new(void) +{ + RAMBlock *block; + unsigned long int total_bits =3D 0; + + rcu_read_lock(); + RAMBLOCK_FOREACH(block) { + /* in general case used_length may not be aligned + * by page_size */ + + total_bits +=3D get_total_bits_per_page(block->used_length, + block->page_size); + } + rcu_read_unlock(); + + return bitmap_new(total_bits); +} + +unsigned long int get_copied_bit_offset(ram_addr_t addr) +{ + RAMBlock *block; + unsigned long int iter_bit =3D 0; + + rcu_read_lock(); + RAMBLOCK_FOREACH(block) { + /* in general case used_length may not be aligned + * by page_size */ + if (block->host =3D=3D NULL) { + continue; + } + if (addr - (ram_addr_t)block->host < block->max_length) { + unsigned long page_size_bit =3D find_last_bit( + (unsigned long *)&block->page_size, + BITS_PER_LONG); + ram_addr_t offset =3D addr - (ram_addr_t)block->host; + iter_bit +=3D offset >> page_size_bit; + break; + } + iter_bit +=3D get_total_bits_per_page(block->used_length, + block->page_size); + } + rcu_read_unlock(); + + return iter_bit; +} + static SaveVMHandlers savevm_ram_handlers =3D { .save_live_setup =3D ram_save_setup, .save_live_iterate =3D ram_save_iterate, --=20 1.8.3.1 From nobody Mon Apr 29 08:22:01 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.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 1495540228653224.93255477493267; Tue, 23 May 2017 04:50:28 -0700 (PDT) Received: from localhost ([::1]:47946 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD8KZ-0005no-2f for importer@patchew.org; Tue, 23 May 2017 07:50:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48779) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD82L-0006lo-BM for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dD82H-0003g4-RF for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:37 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:54528) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dD82H-0003eh-Lz for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:33 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OQE0031LLCKDF70@mailout4.w1.samsung.com> for qemu-devel@nongnu.org; Tue, 23 May 2017 12:31:32 +0100 (BST) Received: from eusmges5.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170523113132eucas1p235de821a046aef6c17b044dd8116c1f7~BOOFwMEHp1788017880eucas1p2q; Tue, 23 May 2017 11:31:32 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges5.samsung.com (EUCPMTA) with SMTP id FF.B0.25577.39D14295; Tue, 23 May 2017 12:31:31 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170523113131eucas1p24a041de6004237e437f97a24340507e2~BOOE_WvB90956409564eucas1p2V; Tue, 23 May 2017 11:31:31 +0000 (GMT) Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id E4.D1.20206.39D14295; Tue, 23 May 2017 12:31:31 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OQE003QBLC1VWB0@eusync3.samsung.com>; Tue, 23 May 2017 12:31:30 +0100 (BST) X-AuditID: cbfec7f5-f792f6d0000063e9-2e-59241d93c0e4 From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Tue, 23 May 2017 14:31:09 +0300 Message-id: <1495539071-12995-9-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1495539071-12995-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJIsWRmVeSWpSXmKPExsWy7djP87qTZVUiDR5tM7eYe/c8i0Xvtnvs FhPfrme1uNL+k91iy/5v7BbHe3ewOLB5PLm2mcnj/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E767TzCA1zALNjBKtq9vYQGqEBTwlzs2wAzFZBFQlJj1mBCnnFXCX eDp5OTPELjmJk8cms4LYnAIeEu8O32MBsYWAak5PvM46gZF3ASPDKkaR1NLi3PTcYiO94sTc 4tK8dL3k/NxNjMBQ3Xbs55YdjF3vgg8xCnAwKvHwajxWihRiTSwrrsw9xCjBwawkwusjpBIp xJuSWFmVWpQfX1Sak1p8iNEU6KaJzFKiyfnAOMoriTc0MTS3NDQytrAwNzJSEued+uFKuJBA emJJanZqakFqEUwfEwenVANjRIyXxUYeJjaelRfy/kzSu//xpKe/UdouZ0c7bitul60TX3WW xi1/wr5wzf/tk5981kiI+N/f/X4Zy6MQhTz21msMPrbL72+7kvp2oVfJtLADTLZK3LU7/rEb 8yctTrzFtSiUiVND7JH9/S/9nvrzGQvTJsdc52U7HLt3Rtpvnj+cRlPC68OUWIozEg21mIuK EwG40bH0awIAAA== X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170523113131eucas1p24a041de6004237e437f97a24340507e2 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-HopCount: 7 X-CMS-RootMailID: 20170523113131eucas1p24a041de6004237e437f97a24340507e2 X-RootMTR: 20170523113131eucas1p24a041de6004237e437f97a24340507e2 References: <1495539071-12995-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.14 Subject: [Qemu-devel] [PATCH V6 08/10] 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: i.maximets@samsung.com, dgilbert@redhat.com, peterx@redhat.com, Alexey Perevalov 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 | 102 +++++++++++++++++++++++++++++++++++++++++++= +++- migration/trace-events | 5 ++- 2 files changed, 105 insertions(+), 2 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index d647769..e70c44b 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -23,6 +23,7 @@ #include "postcopy-ram.h" #include "sysemu/sysemu.h" #include "sysemu/balloon.h" +#include #include "qemu/error-report.h" #include "trace.h" =20 @@ -577,6 +578,101 @@ 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) { + return cpu_iter->cpu_index; + } + } + trace_get_mem_fault_cpu_index(pid); + return -1; +} + +static void mark_postcopy_blocktime_begin(uint64_t addr, uint32_t ptid, + RAMBlock *rb) +{ + int cpu; + unsigned long int nr_bit; + 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; + } + nr_bit =3D get_copied_bit_offset(addr); + if (test_bit(nr_bit, mis->copied_pages)) { + 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->vcpu_addr[cpu], addr); + atomic_xchg__nocheck(&dc->last_begin, now_ms); + atomic_xchg__nocheck(&dc->page_fault_vcpu_time[cpu], now_ms); + + trace_mark_postcopy_blocktime_begin(addr, dc, dc->page_fault_vcpu_time= [cpu], + cpu); +} + +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; + unsigned long int nr_bit; + + if (!dc) { + return; + } + /* mark that page as copied */ + nr_bit =3D get_copied_bit_offset(addr); + set_bit_atomic(nr_bit, mis->copied_pages); + + 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) { + 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); +} + /* * Handle faults detected by the USERFAULT markings */ @@ -654,8 +750,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) @@ -750,6 +849,7 @@ int postcopy_place_page(MigrationIncomingState *mis, vo= id *host, void *from, =20 return -e; } + mark_postcopy_blocktime_end((uint64_t)(uintptr_t)host); =20 trace_postcopy_place_page(host); return 0; diff --git a/migration/trace-events b/migration/trace-events index 5b8ccf3..7bdadbb 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -112,6 +112,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) "addr 0x%" PRIx64 " dd %p time %" PRId64 " cpu %d" +mark_postcopy_blocktime_end(uint64_t addr, void *dd, int64_t time) "addr 0= x%" PRIx64 " dd %p time %" PRId64 =20 # migration/rdma.c qemu_rdma_accept_incoming_migration(void) "" @@ -188,7 +190,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=3D%" PRIx64 " rb=3D%s offset=3D%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 %u" postcopy_ram_incoming_cleanup_closeuf(void) "" postcopy_ram_incoming_cleanup_entry(void) "" postcopy_ram_incoming_cleanup_exit(void) "" @@ -197,6 +199,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(uint32_t pid) "pid %u is not vCPU" =20 # migration/exec.c migration_exec_outgoing(const char *cmd) "cmd=3D%s" --=20 1.8.3.1 From nobody Mon Apr 29 08:22:02 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.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 149554005980231.595349175624506; Tue, 23 May 2017 04:47:39 -0700 (PDT) Received: from localhost ([::1]:47914 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD8Hq-0003J6-7z for importer@patchew.org; Tue, 23 May 2017 07:47:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD82L-0006m2-In for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dD82I-0003gM-27 for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:37 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:54528) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dD82H-0003eh-SQ for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:33 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OQE003ZQLCKDH60@mailout4.w1.samsung.com> for qemu-devel@nongnu.org; Tue, 23 May 2017 12:31:32 +0100 (BST) Received: from eusmges4.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170523113132eucas1p2e1a912b21d34d0beaaa5a33dc4b90a9c~BOOGJMX8j0956409564eucas1p2Y; Tue, 23 May 2017 11:31:32 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges4.samsung.com (EUCPMTA) with SMTP id 72.D2.04729.49D14295; Tue, 23 May 2017 12:31:32 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170523113131eucas1p1ec4e059c13ce977e3a3872c343e6b858~BOOFh0Tu90479904799eucas1p1L; Tue, 23 May 2017 11:31:31 +0000 (GMT) Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id D5.D1.20206.39D14295; Tue, 23 May 2017 12:31:31 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OQE003QBLC1VWB0@eusync3.samsung.com>; Tue, 23 May 2017 12:31:31 +0100 (BST) X-AuditID: cbfec7f4-f79806d000001279-c4-59241d940103 From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Tue, 23 May 2017 14:31:10 +0300 Message-id: <1495539071-12995-10-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1495539071-12995-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrNIsWRmVeSWpSXmKPExsWy7djPc7pTZFUiDU7+EraYe/c8i0Xvtnvs FhPfrme1uNL+k91iy/5v7BbHe3ewOLB5PLm2mcnj/b6rbB59W1YxBjBHcdmkpOZklqUW6dsl cGWs+t7LXLDHq+L9mvWMDYw3LbsYOTkkBEwkJl9dwgphi0lcuLeerYuRi0NIYCmjxJaWzYwQ zmdGid+HjrPCdPxb8JkVIrGMUeLNpetQVd1MEvdn7mPpYuTgYBMwkNh3zxakQURAUuJ312lm kBpmgWZGiUOPfzKD1AgLhEl8vMwCUsMioCqx4c4XNhCbV8BD4s/kP0wQy+QkTh6bDLaYEyj+ 7vA9FpA5EgL32STeTHwNNkdCQFZi0wFmiHoXiTcti6BsYYlXx7ewQ9gyEpcnd0P1tjNKdO/s ZIVwJjBKnJn+F6rKXuLUzatgm5kF+CQmbZsOtYBXoqNNCML0kLj1QA+i2lHiwfblTBC/z2aU mLbgB9MERpkFjAyrGEVSS4tz01OLTfSKE3OLS/PS9ZLzczcxAqP09L/jX3YwLj5mdYhRgINR iYdX67FSpBBrYllxZe4hRgkOZiURXh8hlUgh3pTEyqrUovz4otKc1OJDjNIcLErivFynrkUI CaQnlqRmp6YWpBbBZJk4OKUaGNczTsq/vnzKUr01+0LrOAJefV4UGtcp0rdt9uzGaYmW7hdq 2ExML+tZvXZ2PL5xD4vu2h8Lcg926wle/bez9p5KV7Xy6cK2P1axpUpcC+XyvxlUrfLovK7R t3LaXaUfu/dE8c/T+79kItMvPnnbCYvnJx9wEHp/gKfG1K7r8meXFa/f8qx1EFBiKc5INNRi LipOBAB14njhzgIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrFLMWRmVeSWpSXmKPExsVy+t/xq7qTZVUiDWa+0rCYe/c8i0Xvtnvs FhPfrme1uNL+k91iy/5v7BbHe3ewOLB5PLm2mcnj/b6rbB59W1YxBjBHudlkpCampBYppOYl 56dk5qXbKoWGuOlaKCnkJeam2ipF6PqGBCkplCXmlAJ5RgZowME5wD1YSd8uwS1j1fde5oI9 XhXv16xnbGC8adnFyMkhIWAi8W/BZ1YIW0ziwr31bF2MXBxCAksYJa72L2aCcHqZJB7MawXK cHCwCRhI7LtnC9IgIiAp8bvrNDNIDbNAM6NE6+o2sBphgTCJj5dZQGpYBFQlNtz5wgZi8wp4 SPyZ/IcJYpmcxMljk8EWcwLF3x2+B1YvJOAucXriddYJjLwLGBlWMYqklhbnpucWG+kVJ+YW l+al6yXn525iBIbrtmM/t+xg7HoXfIhRgINRiYdX47FSpBBrYllxZe4hRgkOZiURXh8hlUgh 3pTEyqrUovz4otKc1OJDjKZAR01klhJNzgfGUl5JvKGJobmloZGxhYW5kZGSOO/UD1fChQTS E0tSs1NTC1KLYPqYODilGhiveF9P4eVokl8pJ/CT9Uf04QdHf5ka3dQ4L1IfM63rp79F4xWB nOruGTEv8lnyJ7a3rr/EtMvmRebZo7O/K8ZmX0u76DCB9c+aymlPHy99c2FlErvlO5ndU+fM UDgoF8J1n23qy7laTy0+sCrdnP1TskVCtiCd+9FBxsA441OPD3r/92hWSPNWYinOSDTUYi4q TgQAnz4Num0CAAA= X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170523113131eucas1p1ec4e059c13ce977e3a3872c343e6b858 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-HopCount: 7 X-CMS-RootMailID: 20170523113131eucas1p1ec4e059c13ce977e3a3872c343e6b858 X-RootMTR: 20170523113131eucas1p1ec4e059c13ce977e3a3872c343e6b858 References: <1495539071-12995-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.14 Subject: [Qemu-devel] [PATCH V6 09/10] 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, Alexey Perevalov 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. Signed-off-by: Alexey Perevalov Reviewed-by: Dr. David Alan Gilbert --- hmp.c | 15 +++++++++ include/migration/migration.h | 4 +++ migration/migration.c | 40 +++++++++++++++++++++-- migration/postcopy-ram.c | 75 +++++++++++++++++++++++++++++++++++++++= ++++ migration/trace-events | 1 + qapi-schema.json | 9 +++++- 6 files changed, 140 insertions(+), 4 deletions(-) diff --git a/hmp.c b/hmp.c index 3dceaf8..25135e7 100644 --- a/hmp.c +++ b/hmp.c @@ -260,6 +260,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/include/migration/migration.h b/include/migration/migration.h index 4e05c83..c9d4954 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -123,6 +123,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 e10284e..4da0c20 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -651,14 +651,15 @@ static void populate_ram_info(MigrationInfo *info, Mi= grationState *s) } } =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; @@ -744,10 +745,43 @@ MigrationInfo *qmp_query_migrate(Error **errp) break; } info->status =3D s->state; +} =20 - return info; +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; } =20 +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/postcopy-ram.c b/migration/postcopy-ram.c index e70c44b..3dc3869 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -139,6 +139,73 @@ 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(); + 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. @@ -497,6 +564,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) { @@ -926,6 +996,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 7bdadbb..55a3b6e 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -195,6 +195,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 78617fe..4be0b09 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -712,6 +712,11 @@ # @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.10) +# +# @postcopy-vcpu-blocktime: list of the postcopy blocktime per vCPU (Since= 2.10) +# # Since: 0.14.0 ## { 'struct': 'MigrationInfo', @@ -723,7 +728,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.8.3.1 From nobody Mon Apr 29 08:22:02 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.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 149554034814128.328486028116686; Tue, 23 May 2017 04:52:28 -0700 (PDT) Received: from localhost ([::1]:47959 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD8MT-0007Of-UP for importer@patchew.org; Tue, 23 May 2017 07:52:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48876) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD82P-0006pK-9p for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dD82K-0003hq-AW for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:41 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:54537) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dD82K-0003hW-5a for qemu-devel@nongnu.org; Tue, 23 May 2017 07:31:36 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OQE0031OLCMDF70@mailout4.w1.samsung.com> for qemu-devel@nongnu.org; Tue, 23 May 2017 12:31:34 +0100 (BST) Received: from eusmges4.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170523113133eucas1p2d08db5911e88bf62080e1fce4835ea8c~BOOGxoizz1491014910eucas1p2e; Tue, 23 May 2017 11:31:33 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges4.samsung.com (EUCPMTA) with SMTP id 14.D2.04729.49D14295; Tue, 23 May 2017 12:31:33 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170523113132eucas1p19143aceccbb30a0051635cddcf376bb6~BOOGH0Kjw0480404804eucas1p1N; Tue, 23 May 2017 11:31:32 +0000 (GMT) Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id F6.D1.20206.49D14295; Tue, 23 May 2017 12:31:32 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OQE003QBLC1VWB0@eusync3.samsung.com>; Tue, 23 May 2017 12:31:32 +0100 (BST) X-AuditID: cbfec7f4-f79806d000001279-c8-59241d944dd1 From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Tue, 23 May 2017 14:31:11 +0300 Message-id: <1495539071-12995-11-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1495539071-12995-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJIsWRmVeSWpSXmKPExsWy7djPc7pTZVUiDc55Wcy9e57FonfbPXaL iW/Xs1pcaf/JbrFl/zd2i+O9O1gc2DyeXNvM5PF+31U2j74tqxgDmKO4bFJSczLLUov07RK4 Mu7N+MtScJSjYsHaX8wNjF3sXYycHBICJhIT385ihbDFJC7cW88GYgsJLGWUeNaR0cXIBWR/ ZpRY/6ubDabh/9d9TBCJZYwSvy9NYYZwupkktt/6CjSKg4NNwEBi3z1bkAYRAUmJ312nwWqY BZoZJQ49/skMkhAWcJW4+3UKE4jNIqAq8WDmabAzeAU8JPZO74c6T07i5LHJYHFOoPi7w/dY QAZJCNxnkzj0tYsJZJmEgKzEpgPMEPUuEje2fGKEsIUlXh3fAjVHRuLy5G6o3nZGie6dnawQ zgRGiTPT/0JV2UucunkV7CJmAT6JSdumM0Ms4JXoaBOCMD0kHvWqQpiOEqcmO0P8PptRYtb2 d4wTGGUWMDKsYhRJLS3OTU8tNtErTswtLs1L10vOz93ECIzQ0/+Of9nBuPiY1SFGAQ5GJR5e rcdKkUKsiWXFlbmHGCU4mJVEeH2EVCKFeFMSK6tSi/Lji0pzUosPMUpzsCiJ83KduhYhJJCe WJKanZpakFoEk2Xi4JRqYFR/9i565+co+WmcFTlxLpMmL+/9FP+rOsry7Yw7NdGvEyf0Owm/ Vvlt1n6xPGj9sq0xPhyzrq/x+rX/2s47Pn/CqxbMVNudNcem5e67Aq1jO+ccSgrM7Qyec++V qZytJuehF+2cX7LFHWt3V4syxCy4sb80c6dm0I7JcaU3j5VwaNSeCruyO0+JpTgj0VCLuag4 EQBqTX/YzAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrNLMWRmVeSWpSXmKPExsVy+t/xq7pTZFUiDS5MFbaYe/c8i0Xvtnvs FhPfrme1uNL+k91iy/5v7BbHe3ewOLB5PLm2mcnj/b6rbB59W1YxBjBHudlkpCampBYppOYl 56dk5qXbKoWGuOlaKCnkJeam2ipF6PqGBCkplCXmlAJ5RgZowME5wD1YSd8uwS3j3oy/LAVH OSoWrP3F3MDYxd7FyMkhIWAi8f/rPiYIW0ziwr31bF2MXBxCAksYJSa2H2GCcHqZJE7e283Y xcjBwSZgILHvni1Ig4iApMTvrtPMIDXMAs2MEq2r29hAEsICrhJ3v04Bm8oioCrxYOZpVhCb V8BDYu/0fqjNchInj00Gi3MCxd8dvscCYgsJuEucnniddQIj7wJGhlWMIqmlxbnpucVGesWJ ucWleel6yfm5mxiBAbvt2M8tOxi73gUfYhTgYFTi4dV4rBQpxJpYVlyZe4hRgoNZSYTXR0gl Uog3JbGyKrUoP76oNCe1+BCjKdBRE5mlRJPzgdGUVxJvaGJobmloZGxhYW5kpCTOO/XDlXAh gfTEktTs1NSC1CKYPiYOTqkGRtfZGteUuItaVDh6uR2TvqtEnfXgu3hT5nBphknDnl/5e12e Ja1XSwrvWNrf8ODxy6uTTJSsZFzefIz5wR8tH7BTXOvo0jzd63XpFpV/Dl916Gdzr1Xb/W8f 441Pq2covC7Yppu05qBmT+cOy7cHKnQMn+buy+TcOcd7FVvkO1Wbxzf6mUJfKbEUZyQaajEX FScCAJ+ZyHduAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170523113132eucas1p19143aceccbb30a0051635cddcf376bb6 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-HopCount: 7 X-CMS-RootMailID: 20170523113132eucas1p19143aceccbb30a0051635cddcf376bb6 X-RootMTR: 20170523113132eucas1p19143aceccbb30a0051635cddcf376bb6 References: <1495539071-12995-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.14 Subject: [Qemu-devel] [PATCH V6 10/10] 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: i.maximets@samsung.com, dgilbert@redhat.com, peterx@redhat.com, Alexey Perevalov 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" Signed-off-by: Alexey Perevalov Reviewed-by: Dr. David Alan Gilbert --- docs/migration.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/migration.txt b/docs/migration.txt index 1b940a8..2207c6d 100644 --- a/docs/migration.txt +++ b/docs/migration.txt @@ -402,6 +402,16 @@ 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 source vCPU was in state of interruptable sleep due to pagefa= ult. +This value is 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. + 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 1.8.3.1