From nobody Sun May 5 08:38:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 15072021206801019.5254451503646; Thu, 5 Oct 2017 04:15:20 -0700 (PDT) Received: from localhost ([::1]:39103 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e047W-0002m5-Ko for importer@patchew.org; Thu, 05 Oct 2017 07:15:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35218) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0460-0001tl-7a for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:13:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e045w-00064V-T4 for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:13:40 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:56645) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e045w-00061S-Jf for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:13:36 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20171005111333euoutp0255a68d6d7464a8f4e24439d0ebfe7605~qqD7YdHmO2813728137euoutp02Z; Thu, 5 Oct 2017 11:13:33 +0000 (GMT) Received: from eusmges5.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171005111332eucas1p137e19bf34a4db69be27cc2aecbe12198~qqD699-RR1810618106eucas1p1q; Thu, 5 Oct 2017 11:13:32 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges5.samsung.com (EUCPMTA) with SMTP id 27.F2.12743.CD316D95; Thu, 5 Oct 2017 12:13:32 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171005111331eucas1p101ded202416dd25d9246876264938d55~qqD6G7Zum1838118381eucas1p1w; Thu, 5 Oct 2017 11:13:31 +0000 (GMT) Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id D2.33.20118.BD316D95; Thu, 5 Oct 2017 12:13:31 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OXC00MZ6KIBXN90@eusync4.samsung.com>; Thu, 05 Oct 2017 12:13:31 +0100 (BST) X-AuditID: cbfec7f5-f79d06d0000031c7-c7-59d613dc3d80 From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Thu, 05 Oct 2017 14:13:18 +0300 Message-id: <1507202000-22469-2-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 2.7.4 In-reply-to: <1507202000-22469-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrGIsWRmVeSWpSXmKPExsWy7djP87p3hK9FGsztkbWYe/c8i0Xvtnvs FtM+32a3uNL+k91iy/5v7BbHe3ewWNzZ0sfkwO7x5NpmJo/3+66yefRtWcUYwBzFZZOSmpNZ llqkb5fAlXF3/kL2gj6FikWrFrE2MPaKdTFyckgImEh8/tbIDmGLSVy4t56ti5GLQ0hgKaPE +yObmCGcz4wSF390scJ0LJq5DapqGaPEky3voZxuJomNjQ9Zuhg5ONgEDCT23bMFaRARkJT4 3XUabBKzwEJGiQcXe8D2CQu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OzU1ILUIpgs EwenVAPjzljmtUILGya8kf2eEjmhfp7B713mZ9kN1JpuiEx8qbDhxS2txpvRSzUPzUnsKV8x Ya/aDJHX7Skli2xaeEzfPp4s8b6G8UvEpSndu0VNrHJYvPjtzzSk5n1/cNZ1Q8iaab8+H2Ne 9Habuf2dCfP+szWVJa1Zt9F3y7yKl/J7Ttdk1h4x79Z1V2Ipzkg01GIuKk4EAMHp1O4cAgAA X-CMS-MailID: 20171005111331eucas1p101ded202416dd25d9246876264938d55 X-Msg-Generator: CA X-Sender-IP: 182.198.249.180 X-Local-Sender: =?UTF-8?B?QWxleGV5IFBlcmV2YWxvdhtTUlItVmlydHVhbGl6YXRpb24g?= =?UTF-8?B?TGFiG+yCvOyEseyghOyekBtTZW5pb3IgRW5naW5lZXI=?= X-Global-Sender: =?UTF-8?B?QWxleGV5IFBlcmV2YWxvdhtTUlItVmlydHVhbGl6YXRpb24g?= =?UTF-8?B?TGFiG1NhbXN1bmcgRWxlY3Ryb25pY3MbU2VuaW9yIEVuZ2luZWVy?= X-Sender-Code: =?UTF-8?B?QzEwG0NJU0hRG0MxMEdEMDFHRDAxMDE1NA==?= CMS-TYPE: 201P X-CMS-RootMailID: 20171005111331eucas1p101ded202416dd25d9246876264938d55 X-RootMTR: 20171005111331eucas1p101ded202416dd25d9246876264938d55 References: <1507202000-22469-1-git-send-email-a.perevalov@samsung.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 210.118.77.12 Subject: [Qemu-devel] [PATCH v10 1/3] migration: postcopy_place_page factoring out X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: heetae82.ahn@samsung.com, quintela@redhat.com, Alexey Perevalov , peterx@redhat.com, dgilbert@redhat.com, i.maximets@samsung.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Need to mark copied pages as closer as possible to the place where it tracks down. That will be necessary in futher patch. Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu Reviewed-by: Juan Quintela Signed-off-by: Alexey Perevalov --- migration/postcopy-ram.c | 13 +++++++------ migration/postcopy-ram.h | 4 ++-- migration/ram.c | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 0de68e8..d3073b9 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -646,9 +646,10 @@ int postcopy_ram_enable_notify(MigrationIncomingState = *mis) * returns 0 on success */ int postcopy_place_page(MigrationIncomingState *mis, void *host, void *fro= m, - size_t pagesize) + RAMBlock *rb) { struct uffdio_copy copy_struct; + size_t pagesize =3D qemu_ram_pagesize(rb); =20 copy_struct.dst =3D (uint64_t)(uintptr_t)host; copy_struct.src =3D (uint64_t)(uintptr_t)from; @@ -677,11 +678,11 @@ int postcopy_place_page(MigrationIncomingState *mis, = void *host, void *from, * returns 0 on success */ int postcopy_place_page_zero(MigrationIncomingState *mis, void *host, - size_t pagesize) + RAMBlock *rb) { trace_postcopy_place_page_zero(host); =20 - if (pagesize =3D=3D getpagesize()) { + if (qemu_ram_pagesize(rb) =3D=3D getpagesize()) { struct uffdio_zeropage zero_struct; zero_struct.range.start =3D (uint64_t)(uintptr_t)host; zero_struct.range.len =3D getpagesize(); @@ -711,7 +712,7 @@ int postcopy_place_page_zero(MigrationIncomingState *mi= s, void *host, memset(mis->postcopy_tmp_zero_page, '\0', mis->largest_page_si= ze); } return postcopy_place_page(mis, host, mis->postcopy_tmp_zero_page, - pagesize); + rb); } =20 return 0; @@ -774,14 +775,14 @@ int postcopy_ram_enable_notify(MigrationIncomingState= *mis) } =20 int postcopy_place_page(MigrationIncomingState *mis, void *host, void *fro= m, - size_t pagesize) + RAMBlock *rb) { assert(0); return -1; } =20 int postcopy_place_page_zero(MigrationIncomingState *mis, void *host, - size_t pagesize) + RAMBlock *rb) { assert(0); return -1; diff --git a/migration/postcopy-ram.h b/migration/postcopy-ram.h index 587a8b8..77ea0fd 100644 --- a/migration/postcopy-ram.h +++ b/migration/postcopy-ram.h @@ -72,14 +72,14 @@ void postcopy_discard_send_finish(MigrationState *ms, * returns 0 on success */ int postcopy_place_page(MigrationIncomingState *mis, void *host, void *fro= m, - size_t pagesize); + RAMBlock *rb); =20 /* * Place a zero page at (host) atomically * returns 0 on success */ int postcopy_place_page_zero(MigrationIncomingState *mis, void *host, - size_t pagesize); + RAMBlock *rb); =20 /* The current postcopy state is read/set by postcopy_state_get/set * which update it atomically. diff --git a/migration/ram.c b/migration/ram.c index b83f897..304ac59 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2680,10 +2680,10 @@ static int ram_load_postcopy(QEMUFile *f) =20 if (all_zero) { ret =3D postcopy_place_page_zero(mis, place_dest, - block->page_size); + block); } else { ret =3D postcopy_place_page(mis, place_dest, - place_source, block->page_size); + place_source, block); } } if (!ret) { --=20 2.7.4 From nobody Sun May 5 08:38:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507202114279251.92729232186696; Thu, 5 Oct 2017 04:15:14 -0700 (PDT) Received: from localhost ([::1]:39102 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e047T-0002ib-F5 for importer@patchew.org; Thu, 05 Oct 2017 07:15:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35216) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0460-0001tk-6k for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:13:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e045w-00064X-TM for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:13:40 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:42456) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e045w-000622-J9 for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:13:36 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20171005111333euoutp016c6ccf269ea37829f44d38a9ba7d15f5~qqD76cBAB1541215412euoutp01e; Thu, 5 Oct 2017 11:13:33 +0000 (GMT) Received: from eusmges4.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171005111333eucas1p1f271d547d60cb117f90718a83310c91f~qqD7Pm_f61747717477eucas1p1F; Thu, 5 Oct 2017 11:13:33 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges4.samsung.com (EUCPMTA) with SMTP id 1D.D8.12944.CD316D95; Thu, 5 Oct 2017 12:13:32 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171005111332eucas1p164cbc61ee4cb82c4bf6d592a32bba46b~qqD6p3Akt1810618106eucas1p1p; Thu, 5 Oct 2017 11:13:32 +0000 (GMT) Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 58.40.18832.CD316D95; Thu, 5 Oct 2017 12:13:32 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OXC00MZ6KIBXN90@eusync4.samsung.com>; Thu, 05 Oct 2017 12:13:32 +0100 (BST) X-AuditID: cbfec7f4-f79ab6d000003290-49-59d613dc2276 From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Thu, 05 Oct 2017 14:13:19 +0300 Message-id: <1507202000-22469-3-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 2.7.4 In-reply-to: <1507202000-22469-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrEIsWRmVeSWpSXmKPExsWy7djP87p3hK9FGjzdoG8x9+55FovebffY LaZ9vs1ucaX9J7vFlv3f2C2O9+5gsbizpY/Jgd3jybXNTB7v911l8+jbsooxgDmKyyYlNSez LLVI3y6BK+Ppwzb2gtuSFS2Nr9gaGB8LdzFyckgImEhcXr2cGcIWk7hwbz1bFyMXh5DAUkaJ E4evsEI4nxklTv+7wAbTMannNJgtJLCMUeJjRxiE3c0k8eWNSxcjBwebgIHEvnu2IGERAUmJ 312nmUHmMAssZJR4cLGHHaRGWMBD4tNuN5AaFgFViVcfr4GN5BVwl3jwcgfUKjmJm+c6wY7j BCo/tKaRESL+l1Xi2co4CNtFYtOp31BxYYlXx7ewQ9gyEp0dB5lA9koItDNKdO/sZIVwJjBK nJn+F6rKXuLUzatMIDazAJ/EpG3TmUGOkxDglehoE4Io8ZBY9PUcVNgR6EUWSJjMZpR48+UD 8wRG6QWMDKsYRVJLi3PTU4tN9IoTc4tL89L1kvNzNzECY/L0v+NfdjAuPmZ1iFGAg1GJh5fh wZVIIdbEsuLK3EOMEhzMSiK8Sv+vRgrxpiRWVqUW5ccXleakFh9ilOZgURLntY1qixQSSE8s Sc1OTS1ILYLJMnFwSjUwrqhv/7n9vTerhbSH+YHWcr3u7IpJAlrfdv3qfaIZ3KW6ViTmatBp u+uveiaaHa0x4rnd0+0ZX7s6dc1vv5C3jw9Gn5lafq/xaNS1pA8FgT51l7V7hW//K/h7Q2Ht +rj0ePu3obHPhQr2zHzNe4Iv76GUxCfvs2rT38fIJz96t/7Q7n0PTzRMVGIpzkg01GIuKk4E AKSw3KfFAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkluLIzCtJLcpLzFFi42I5/e/4Nd07wtciDX79ErOYe/c8i0Xvtnvs FtM+32a3uNL+k91iy/5v7BbHe3ewWNzZ0sfkwO7x5NpmJo/3+66yefRtWcUYwBzFZZOSmpNZ llqkb5fAlfH0YRt7wW3JipbGV2wNjI+Fuxg5OSQETCQm9Zxmg7DFJC7cWw9kc3EICSxhlHj4 /xwjhNPLJLHg1Dogh4ODTcBAYt89W5AGEQFJid9dp5lBapgFFjJKzJn6BKxGWMBD4tNuN5Aa FgFViVcfr4Et4BVwl3jwcgfUMjmJm+c6mUFsTqDyQ2saGUFsIaCa44vOME5g5F3AyLCKUSS1 tDg3PbfYUK84Mbe4NC9dLzk/dxMjMIC2Hfu5eQfjpY3BhxgFOBiVeHg9tl6NFGJNLCuuzD3E KMHBrCTCq/QfKMSbklhZlVqUH19UmpNafIhRmoNFSZy3d8/qSCGB9MSS1OzU1ILUIpgsEwen VAMja4OHYEHuD6tFz5sXsvZlP/Ks53gewfJ9t9r0a/NXuhotuah8Pq3+2MenIiIN27j8/n1n uOpyc3aKwz6Hh24Fq868uNS0TumtxpU9jJIdxYVHCw/P/9lo79Ii5B9bK+Jr1xsYcII77lBE 9turmmFBBm6/cyflyrlL/eT2nflyxvb9+20/vH6nxFKckWioxVxUnAgAOD0whRwCAAA= X-CMS-MailID: 20171005111332eucas1p164cbc61ee4cb82c4bf6d592a32bba46b X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?QWxleGV5IFBlcmV2YWxvdhtTUlItVmlydHVhbGl6YXRpb24g?= =?UTF-8?B?TGFiG+yCvOyEseyghOyekBtTZW5pb3IgRW5naW5lZXI=?= X-Global-Sender: =?UTF-8?B?QWxleGV5IFBlcmV2YWxvdhtTUlItVmlydHVhbGl6YXRpb24g?= =?UTF-8?B?TGFiG1NhbXN1bmcgRWxlY3Ryb25pY3MbU2VuaW9yIEVuZ2luZWVy?= X-Sender-Code: =?UTF-8?B?QzEwG0NJU0hRG0MxMEdEMDFHRDAxMDE1NA==?= CMS-TYPE: 201P X-CMS-RootMailID: 20171005111332eucas1p164cbc61ee4cb82c4bf6d592a32bba46b X-RootMTR: 20171005111332eucas1p164cbc61ee4cb82c4bf6d592a32bba46b References: <1507202000-22469-1-git-send-email-a.perevalov@samsung.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 210.118.77.11 Subject: [Qemu-devel] [PATCH v10 2/3] migration: introduce qemu_ufd_copy_ioctl helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: heetae82.ahn@samsung.com, quintela@redhat.com, Alexey Perevalov , peterx@redhat.com, dgilbert@redhat.com, i.maximets@samsung.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Just for placing auxilary operations inside helper, auxilary operations like: track received pages, notify about copying operation in futher patches. Reviewed-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu Signed-off-by: Alexey Perevalov --- migration/postcopy-ram.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index d3073b9..8bf6432 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -641,6 +641,25 @@ int postcopy_ram_enable_notify(MigrationIncomingState = *mis) return 0; } =20 +static int qemu_ufd_copy_ioctl(int userfault_fd, void *host_addr, + void *from_addr, uint64_t pagesize) +{ + if (from_addr) { + struct uffdio_copy copy_struct; + copy_struct.dst =3D (uint64_t)(uintptr_t)host_addr; + copy_struct.src =3D (uint64_t)(uintptr_t)from_addr; + copy_struct.len =3D pagesize; + copy_struct.mode =3D 0; + return ioctl(userfault_fd, UFFDIO_COPY, ©_struct); + } else { + struct uffdio_zeropage zero_struct; + zero_struct.range.start =3D (uint64_t)(uintptr_t)host_addr; + zero_struct.range.len =3D pagesize; + zero_struct.mode =3D 0; + return ioctl(userfault_fd, UFFDIO_ZEROPAGE, &zero_struct); + } +} + /* * Place a host page (from) at (host) atomically * returns 0 on success @@ -648,20 +667,14 @@ int postcopy_ram_enable_notify(MigrationIncomingState= *mis) int postcopy_place_page(MigrationIncomingState *mis, void *host, void *fro= m, RAMBlock *rb) { - struct uffdio_copy copy_struct; size_t pagesize =3D qemu_ram_pagesize(rb); =20 - copy_struct.dst =3D (uint64_t)(uintptr_t)host; - copy_struct.src =3D (uint64_t)(uintptr_t)from; - copy_struct.len =3D pagesize; - copy_struct.mode =3D 0; - /* copy also acks to the kernel waking the stalled thread up * TODO: We can inhibit that ack and only do it if it was requested * which would be slightly cheaper, but we'd have to be careful * of the order of updating our page state. */ - if (ioctl(mis->userfault_fd, UFFDIO_COPY, ©_struct)) { + if (qemu_ufd_copy_ioctl(mis->userfault_fd, host, from, pagesize)) { int e =3D errno; error_report("%s: %s copy host: %p from: %p (size: %zd)", __func__, strerror(e), host, from, pagesize); @@ -683,12 +696,7 @@ int postcopy_place_page_zero(MigrationIncomingState *m= is, void *host, trace_postcopy_place_page_zero(host); =20 if (qemu_ram_pagesize(rb) =3D=3D getpagesize()) { - struct uffdio_zeropage zero_struct; - zero_struct.range.start =3D (uint64_t)(uintptr_t)host; - zero_struct.range.len =3D getpagesize(); - zero_struct.mode =3D 0; - - if (ioctl(mis->userfault_fd, UFFDIO_ZEROPAGE, &zero_struct)) { + if (qemu_ufd_copy_ioctl(mis->userfault_fd, host, NULL, getpagesize= ())) { int e =3D errno; error_report("%s: %s zero host: %p", __func__, strerror(e), host); --=20 2.7.4 From nobody Sun May 5 08:38:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150720221520749.48640762641526; Thu, 5 Oct 2017 04:16:55 -0700 (PDT) Received: from localhost ([::1]:39111 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0494-0003vc-Og for importer@patchew.org; Thu, 05 Oct 2017 07:16:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0460-0001tm-Q9 for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:13:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e045x-000657-F9 for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:13:40 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:56652) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e045x-00062s-5j for qemu-devel@nongnu.org; Thu, 05 Oct 2017 07:13:37 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20171005111334euoutp027eea6adb6713375204c726e54796ee81~qqD8sRZLD2840428404euoutp02B; Thu, 5 Oct 2017 11:13:34 +0000 (GMT) Received: from eusmges1.samsung.com (unknown [203.254.199.239]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171005111333eucas1p2044c9857583c79802502e84d7ddd2dec~qqD8DCV0K0161101611eucas1p2D; Thu, 5 Oct 2017 11:13:33 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1.samsung.com (EUCPMTA) with SMTP id 0E.EF.12576.DD316D95; Thu, 5 Oct 2017 12:13:33 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171005111333eucas1p1c3c8d82ae9e35e6f4a6d610fbe375932~qqD7a8r9H1747717477eucas1p1H; Thu, 5 Oct 2017 11:13:33 +0000 (GMT) Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 89.40.18832.DD316D95; Thu, 5 Oct 2017 12:13:33 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OXC00MZ6KIBXN90@eusync4.samsung.com>; Thu, 05 Oct 2017 12:13:33 +0100 (BST) X-AuditID: cbfec7ef-f79ee6d000003120-37-59d613ddec8f From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Thu, 05 Oct 2017 14:13:20 +0300 Message-id: <1507202000-22469-4-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 2.7.4 In-reply-to: <1507202000-22469-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMIsWRmVeSWpSXmKPExsWy7djPc7p3ha9FGnQ/V7OYe/c8i0Xvtnvs FtM+32a3uNL+k91iy/5v7BbHe3ewWNzZ0sfkwO7x5NpmJo/3+66yefRtWcUYwBzFZZOSmpNZ llqkb5fAlfH+wAWWgjvWFZ09r9kaGDfqdjFycEgImEisXWHbxcgJZIpJXLi3nq2LkYtDSGAZ o8Sm2adZIJzPjBLvzx5khagykfg9/T8TXNXWPduYIZxu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v0n+gEG9KYmVValF+fFFpTmrxIUZpDhYlcd7ePasjhQTSE0tSs1NTC1KL YLJMHJxSDYwLnI7evMz15d7rW70Kiw6ZHZPan9B5fs+Fp3UNT5/lMT+tMmAMYrc5zDF3+X/F PUwzYg1V731zP26YYfnE4UuqtlpnmrBHZu3RT9GSzuntkyvevlM2uJ/FqBXhfH61/481h51/ 6i0pYeLKeOK32+Kgwvsrz8xNljd8kr7kfMmhXJ7rM9fVD8VKLMUZiYZazEXFiQBRImgrGwIA AA== X-CMS-MailID: 20171005111333eucas1p1c3c8d82ae9e35e6f4a6d610fbe375932 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?QWxleGV5IFBlcmV2YWxvdhtTUlItVmlydHVhbGl6YXRpb24g?= =?UTF-8?B?TGFiG+yCvOyEseyghOyekBtTZW5pb3IgRW5naW5lZXI=?= X-Global-Sender: =?UTF-8?B?QWxleGV5IFBlcmV2YWxvdhtTUlItVmlydHVhbGl6YXRpb24g?= =?UTF-8?B?TGFiG1NhbXN1bmcgRWxlY3Ryb25pY3MbU2VuaW9yIEVuZ2luZWVy?= X-Sender-Code: =?UTF-8?B?QzEwG0NJU0hRG0MxMEdEMDFHRDAxMDE1NA==?= CMS-TYPE: 201P X-CMS-RootMailID: 20171005111333eucas1p1c3c8d82ae9e35e6f4a6d610fbe375932 X-RootMTR: 20171005111333eucas1p1c3c8d82ae9e35e6f4a6d610fbe375932 References: <1507202000-22469-1-git-send-email-a.perevalov@samsung.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 210.118.77.12 Subject: [Qemu-devel] [PATCH v10 3/3] migration: add bitmap for received 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: heetae82.ahn@samsung.com, quintela@redhat.com, Alexey Perevalov , peterx@redhat.com, dgilbert@redhat.com, i.maximets@samsung.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch adds ability to track down already received pages, it's necessary for calculation vCPU block time in postcopy migration feature, and for recovery after postcopy migration failure. Also it's necessary to solve shared memory issue in postcopy livemigration. Information about received pages will be transferred to the software virtual bridge (e.g. OVS-VSWITCHD), to avoid fallocate (unmap) for already received pages. fallocate syscall is required for remmaped shared memory, due to remmaping itself blocks ioctl(UFFDIO_COPY, ioctl in this case will end with EEXIT error (struct page is exists after remmap). Bitmap is placed into RAMBlock as another postcopy/precopy related bitmaps. Reviewed-by: Peter Xu Signed-off-by: Peter Xu Signed-off-by: Alexey Perevalov Reviewed-by: Dr. David Alan Gilbert --- include/exec/ram_addr.h | 10 ++++++++++ migration/postcopy-ram.c | 17 ++++++++++++----- migration/ram.c | 40 ++++++++++++++++++++++++++++++++++++++++ migration/ram.h | 5 +++++ 4 files changed, 67 insertions(+), 5 deletions(-) diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index d017639..6cbc02a 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -47,6 +47,8 @@ struct RAMBlock { * of the postcopy phase */ unsigned long *unsentmap; + /* bitmap of already received pages in postcopy */ + unsigned long *receivedmap; }; =20 static inline bool offset_in_ramblock(RAMBlock *b, ram_addr_t offset) @@ -60,6 +62,14 @@ static inline void *ramblock_ptr(RAMBlock *block, ram_ad= dr_t offset) return (char *)block->host + offset; } =20 +static inline unsigned long int ramblock_recv_bitmap_offset(void *host_add= r, + RAMBlock *rb) +{ + uint64_t host_addr_offset =3D + (uint64_t)(uintptr_t)(host_addr - (void *)rb->host); + return host_addr_offset >> TARGET_PAGE_BITS; +} + long qemu_getrampagesize(void); unsigned long last_ram_page(void); RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr, diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 8bf6432..bec6c2c 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -642,22 +642,28 @@ int postcopy_ram_enable_notify(MigrationIncomingState= *mis) } =20 static int qemu_ufd_copy_ioctl(int userfault_fd, void *host_addr, - void *from_addr, uint64_t pagesize) + void *from_addr, uint64_t pagesize, RAMBloc= k *rb) { + int ret; if (from_addr) { struct uffdio_copy copy_struct; copy_struct.dst =3D (uint64_t)(uintptr_t)host_addr; copy_struct.src =3D (uint64_t)(uintptr_t)from_addr; copy_struct.len =3D pagesize; copy_struct.mode =3D 0; - return ioctl(userfault_fd, UFFDIO_COPY, ©_struct); + ret =3D ioctl(userfault_fd, UFFDIO_COPY, ©_struct); } else { struct uffdio_zeropage zero_struct; zero_struct.range.start =3D (uint64_t)(uintptr_t)host_addr; zero_struct.range.len =3D pagesize; zero_struct.mode =3D 0; - return ioctl(userfault_fd, UFFDIO_ZEROPAGE, &zero_struct); + ret =3D ioctl(userfault_fd, UFFDIO_ZEROPAGE, &zero_struct); + } + if (!ret) { + ramblock_recv_bitmap_set_range(rb, host_addr, + pagesize / qemu_target_page_size()); } + return ret; } =20 /* @@ -674,7 +680,7 @@ int postcopy_place_page(MigrationIncomingState *mis, vo= id *host, void *from, * which would be slightly cheaper, but we'd have to be careful * of the order of updating our page state. */ - if (qemu_ufd_copy_ioctl(mis->userfault_fd, host, from, pagesize)) { + if (qemu_ufd_copy_ioctl(mis->userfault_fd, host, from, pagesize, rb)) { int e =3D errno; error_report("%s: %s copy host: %p from: %p (size: %zd)", __func__, strerror(e), host, from, pagesize); @@ -696,7 +702,8 @@ int postcopy_place_page_zero(MigrationIncomingState *mi= s, void *host, trace_postcopy_place_page_zero(host); =20 if (qemu_ram_pagesize(rb) =3D=3D getpagesize()) { - if (qemu_ufd_copy_ioctl(mis->userfault_fd, host, NULL, getpagesize= ())) { + if (qemu_ufd_copy_ioctl(mis->userfault_fd, host, NULL, getpagesize= (), + rb)) { int e =3D errno; error_report("%s: %s zero host: %p", __func__, strerror(e), host); diff --git a/migration/ram.c b/migration/ram.c index 304ac59..c30db15 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -44,6 +44,7 @@ #include "qemu/error-report.h" #include "trace.h" #include "exec/ram_addr.h" +#include "exec/target_page.h" #include "qemu/rcu_queue.h" #include "migration/colo.h" #include "migration/block.h" @@ -148,6 +149,35 @@ out: return ret; } =20 +static void ramblock_recv_map_init(void) +{ + RAMBlock *rb; + + RAMBLOCK_FOREACH(rb) { + assert(!rb->receivedmap); + rb->receivedmap =3D bitmap_new(rb->max_length >> qemu_target_page_= bits()); + } +} + +int ramblock_recv_bitmap_test(RAMBlock *rb, void *host_addr) +{ + return test_bit(ramblock_recv_bitmap_offset(host_addr, rb), + rb->receivedmap); +} + +void ramblock_recv_bitmap_set(RAMBlock *rb, void *host_addr) +{ + set_bit_atomic(ramblock_recv_bitmap_offset(host_addr, rb), rb->receive= dmap); +} + +void ramblock_recv_bitmap_set_range(RAMBlock *rb, void *host_addr, + size_t nr) +{ + bitmap_set_atomic(rb->receivedmap, + ramblock_recv_bitmap_offset(host_addr, rb), + nr); +} + /* * An outstanding page request, on the source, having been received * and queued @@ -1999,6 +2029,8 @@ int ram_discard_range(const char *rbname, uint64_t st= art, size_t length) goto err; } =20 + bitmap_clear(rb->receivedmap, start >> qemu_target_page_bits(), + length >> qemu_target_page_bits()); ret =3D ram_block_discard_range(rb, start, length); =20 err: @@ -2534,13 +2566,20 @@ static int ram_load_setup(QEMUFile *f, void *opaque) { xbzrle_load_setup(); compress_threads_load_setup(); + ramblock_recv_map_init(); return 0; } =20 static int ram_load_cleanup(void *opaque) { + RAMBlock *rb; xbzrle_load_cleanup(); compress_threads_load_cleanup(); + + RAMBLOCK_FOREACH(rb) { + g_free(rb->receivedmap); + rb->receivedmap =3D NULL; + } return 0; } =20 @@ -2755,6 +2794,7 @@ static int ram_load(QEMUFile *f, void *opaque, int ve= rsion_id) ret =3D -EINVAL; break; } + ramblock_recv_bitmap_set(block, host); trace_ram_load_loop(block->idstr, (uint64_t)addr, flags, host); } =20 diff --git a/migration/ram.h b/migration/ram.h index 4a72d66..3f5dd23 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -57,4 +57,9 @@ int ram_discard_range(const char *block_name, uint64_t st= art, size_t length); int ram_postcopy_incoming_init(MigrationIncomingState *mis); =20 void ram_handle_compressed(void *host, uint8_t ch, uint64_t size); + +int ramblock_recv_bitmap_test(RAMBlock *rb, void *host_addr); +void ramblock_recv_bitmap_set(RAMBlock *rb, void *host_addr); +void ramblock_recv_bitmap_set_range(RAMBlock *rb, void *host_addr, size_t = nr); + #endif --=20 2.7.4