From nobody Mon Feb 9 09:53:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1497640229712522.3177982153586; Fri, 16 Jun 2017 12:10:29 -0700 (PDT) Received: from localhost ([::1]:60434 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLwdX-0005dH-Kb for importer@patchew.org; Fri, 16 Jun 2017 15:10:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48339) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLwcB-0004jR-8Y for qemu-devel@nongnu.org; Fri, 16 Jun 2017 15:09:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dLwc6-0004Ya-4r for qemu-devel@nongnu.org; Fri, 16 Jun 2017 15:09:03 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:51904) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dLwc5-0004VC-SV for qemu-devel@nongnu.org; Fri, 16 Jun 2017 15:08:58 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0ORN00KTHMITSQ40@mailout1.w1.samsung.com> for qemu-devel@nongnu.org; Fri, 16 Jun 2017 20:08:53 +0100 (BST) Received: from eusmges1.samsung.com (unknown [203.254.199.239]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170616190853eucas1p1161c4fae87d7264d5279caf1bf34bf87~Ir8Qh2NEH0582305823eucas1p1l; Fri, 16 Jun 2017 19:08:53 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1.samsung.com (EUCPMTA) with SMTP id 64.B8.14140.7CC24495; Fri, 16 Jun 2017 20:08:55 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170616190852eucas1p25223609a18a68b900540094697e88f54~Ir8P4tls80511005110eucas1p2x; Fri, 16 Jun 2017 19:08:52 +0000 (GMT) Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id DC.C5.20206.4CC24495; Fri, 16 Jun 2017 20:08:52 +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 <0ORN00D34MIKUY80@eusync4.samsung.com>; Fri, 16 Jun 2017 20:08:52 +0100 (BST) X-AuditID: cbfec7ef-f796a6d00000373c-b6-59442cc73ad4 From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Fri, 16 Jun 2017 22:08:39 +0300 Message-id: <1497640120-10729-3-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1497640120-10729-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrFIsWRmVeSWpSXmKPExsWy7djP87rHdVwiDVZuErOYe/c8i0Xvtnvs Flfaf7JbbNn/jd3ieO8OFos7W/qYHNg8nlzbzOTxft9VNo++LasYA5ijuGxSUnMyy1KL9O0S uDLmv1jLWLBCsmJ2p2UD41bhLkZODgkBE4k/k9eyQthiEhfurWfrYuTiEBJYxigxe+sSFgjn M6PEnG0/WWA6/r7pYYWrOvloDZTTzSTx6EIHcxcjBwebgIHEvnu2IA0iApISv7t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Eo8vJF3nSOFWBPLiitzDzFKcDArifDaA4NdiDcl sbIqtSg/vqg0J7X4EKMp0FETmaVEk/OBsZRXEm9oYmhuaWhkbGFhbmSkJM479cOVcCGB9MSS 1OzU1ILUIpg+Jg5OqQZGBze2YycDCrOaOc+ZaLPLLHewm2/+Y8ZBm9W3JEIP6zp1XtprsFRH ZEpD9smeBmnpcGn5G2EXDyjZNM9c4GAeszPR5++XnSpzimyvP5L0vJSmePDRNCalGAPuGZN7 EzdMVHL19o71fuc2WXdT5srwLU/lfF7e9zePtwlPvKiue1Lu/fy1bJeUWIozEg21mIuKEwH9 v5IobQIAAA== X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170616190852eucas1p25223609a18a68b900540094697e88f54 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: 20170616190852eucas1p25223609a18a68b900540094697e88f54 X-RootMTR: 20170616190852eucas1p25223609a18a68b900540094697e88f54 References: <1497640120-10729-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 v3 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: i.maximets@samsung.com, dgilbert@redhat.com, Alexey Perevalov , peterx@redhat.com, quintela@redhat.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: Dr. David Alan Gilbert Reviewed-by: Peter Xu Signed-off-by: Alexey Perevalov Reviewed-by: Juan Quintela --- 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 dae41b5..d1af2c1 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -561,6 +561,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 @@ -568,20 +587,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); @@ -603,12 +616,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, 0, getpagesize())= ) { int e =3D errno; error_report("%s: %s zero host: %p", __func__, strerror(e), host); --=20 1.8.3.1