From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 5090323D for ; Fri, 5 Oct 2018 13:55:43 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20181005115543euoutp011de34e3f69328cb65da69515f432e26b~atF8RIxs61116511165euoutp01O for ; Fri, 5 Oct 2018 11:55:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20181005115543euoutp011de34e3f69328cb65da69515f432e26b~atF8RIxs61116511165euoutp01O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1538740543; bh=AE0n/GwUG4yoXXTaxpr6kkH2FIiGNfsx1in/HTQrYbc=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=JIjgeS5OsdJJrtkeHB+On8lAoFgITh9tESNQG+EV0dKh8xl5nuatfhGMsMN98qvl0 JkksqUzj7csyBEnuZzb4X3lf7Rw15pXXCSPEanhlsUdcP3/n9uJd+FM4eCzHedzkcj K1+KrRnzV2aqsHladS7/NzfQLx++rnfwOyK0TMGY= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181005115542eucas1p2f19bb7daa1196f4b394cfa46a5cbe11a~atF7w7Y9o2553025530eucas1p2f; Fri, 5 Oct 2018 11:55:42 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id FD.CB.04806.E3157BB5; Fri, 5 Oct 2018 12:55:42 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20181005115541eucas1p1893250ad7dc2d2ab3c7da5000a68b199~atF62GFUW1471914719eucas1p1O; Fri, 5 Oct 2018 11:55:41 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20181005115541eusmtrp1a8a5c510f9b6d41a7d5561df3c33eaca~atF6k-POt0158101581eusmtrp1I; Fri, 5 Oct 2018 11:55:41 +0000 (GMT) X-AuditID: cbfec7f5-34dff700000012c6-37-5bb7513e1e86 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 3D.B7.04284.D3157BB5; Fri, 5 Oct 2018 12:55:41 +0100 (BST) Received: from [106.109.129.180] (unknown [106.109.129.180]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20181005115540eusmtip1d74ec74a50af870d800363ec7671cf95~atF56gnho3139731397eusmtip1h; Fri, 5 Oct 2018 11:55:40 +0000 (GMT) To: Maxime Coquelin , dev@dpdk.org, tiwei.bie@intel.com, zhihong.wang@intel.com, jfreimann@redhat.com, nicknickolaev@gmail.com, bruce.richardson@intel.com, alejandro.lucero@netronome.com Cc: dgilbert@redhat.com, stable@dpdk.org From: Ilya Maximets Date: Fri, 5 Oct 2018 14:58:01 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181004081403.8039-12-maxime.coquelin@redhat.com> Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA02SeyyVcRjH/d73Ped90eHn0DzR1pysldUR+uNdM5et2VltXdamljWd8obh 0Dku8UfMUofcYiaHFRkKi1wO5ZaTXGKnKSSrqFmh0dxHOnK8LP99fs/3eb7P99l+DCnWCeyY YEUkp1TIQyVCM0rbufLuiMe5Br+jo20CVj9XSrDD5Z7szFwDwaZpv9LswN0VmtVXllBsZ3Iz xfYWDVGsQb1Gs/UJ6wRb259FeJnLVgtLBLIXmi+0rLh5kpDl3vtGyn63Dgpl6XXl6Kzwkpl7 AB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ZQRLCAh4SD169YgJJiAjc YZTYMusMI0iCWUBDYv3VJ4wQHScYJe5tOA42lk1AR+LU6iNgRbwCdhJLPlwDmsTBwSKgIrH/ mj5IWFQgQmL18hesECWCEidnPmEBsTkFHCTu/zrGDDFfXeLPvEtQtrhE05eVrBC2vMT2t3OY JzAKzULSPgtJyywkLbOQtCxgZFnFKJJaWpybnltsqFecmFtcmpeul5yfu4kRGKfbjv3cvIPx 0sbgQ4wCHIxKPLwvlLdFC7EmlhVX5h5ilOBgVhLhdfTYHi3Em5JYWZValB9fVJqTWnyI0RTo t4nMUqLJ+cAUklcSb2hqaG5haWhubG5sZqEkznveoDJKSCA9sSQ1OzW1ILUIpo+Jg1OqgdHG f1fYFJXNRYecnztWfijX7PBe4tmuNkne9Ki8rOiCyR17FR5uXtrdsHHq0dPsPaeudtuk2gpz PvIXk1/0+4jn8tjj7/R0Yw7KCuznrDK4HGh17oJq5/6/842OnEyZ4jDd+36Aw3Plm6zPk/Qv eHSxuyzYMfnYzFlhrbrTjwjoRam0H37Q6anEUpyRaKjFXFScCAAAj55/6QIAAA== Message-Id: <20181005115541eucas1p1893250ad7dc2d2ab3c7da5000a68b199~atF62GFUW1471914719eucas1p1O@eucas1p1.samsung.com> X-CMS-MailID: 20181005115541eucas1p1893250ad7dc2d2ab3c7da5000a68b199 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20181004081542epcas5p4814e536c174c10ce76e6120b55a24f41 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181004081542epcas5p4814e536c174c10ce76e6120b55a24f41 References: <20181004081403.8039-1-maxime.coquelin@redhat.com> <20181004081403.8039-12-maxime.coquelin@redhat.com> Subject: Re: [dpdk-dev] [PATCH v3 11/19] vhost: introduce postcopy's advise message X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Oct 2018 11:55:43 -0000 Cleanup part is missing in this patch. We should close and clear postcopy_ufd in vhost_backend_cleanup(). Best regards, Ilya Maximets. On 04.10.2018 11:13, Maxime Coquelin wrote: > This patch opens a userfaultfd and sends it back to Qemu's > VHOST_USER_POSTCOPY_ADVISE request. > > Signed-off-by: Dr. David Alan Gilbert > Signed-off-by: Maxime Coquelin > --- > lib/librte_vhost/vhost.h | 2 ++ > lib/librte_vhost/vhost_user.c | 44 +++++++++++++++++++++++++++++++++++ > lib/librte_vhost/vhost_user.h | 3 ++- > 3 files changed, 48 insertions(+), 1 deletion(-) > > diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h > index 25ffd7614..21722d8a8 100644 > --- a/lib/librte_vhost/vhost.h > +++ b/lib/librte_vhost/vhost.h > @@ -363,6 +363,8 @@ struct virtio_net { > int slave_req_fd; > rte_spinlock_t slave_req_lock; > > + int postcopy_ufd; > + > /* > * Device id to identify a specific backend device. > * It's set to -1 for the default software implementation. > diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c > index 0a1934649..3d4fc60fc 100644 > --- a/lib/librte_vhost/vhost_user.c > +++ b/lib/librte_vhost/vhost_user.c > @@ -24,13 +24,19 @@ > #include > #include > #include > +#include > +#include > #include > #include > #include > +#include > #include > #ifdef RTE_LIBRTE_VHOST_NUMA > #include > #endif > +#ifdef RTE_LIBRTE_VHOST_POSTCOPY > +#include > +#endif > > #include > #include > @@ -69,6 +75,7 @@ static const char *vhost_message_str[VHOST_USER_MAX] = { > [VHOST_USER_IOTLB_MSG] = "VHOST_USER_IOTLB_MSG", > [VHOST_USER_CRYPTO_CREATE_SESS] = "VHOST_USER_CRYPTO_CREATE_SESS", > [VHOST_USER_CRYPTO_CLOSE_SESS] = "VHOST_USER_CRYPTO_CLOSE_SESS", > + [VHOST_USER_POSTCOPY_ADVISE] = "VHOST_USER_POSTCOPY_ADVISE", > }; > > /* The possible results of a message handling function */ > @@ -1509,6 +1516,42 @@ vhost_user_iotlb_msg(struct virtio_net **pdev, struct VhostUserMsg *msg, > return VH_RESULT_OK; > } > > +static int > +vhost_user_set_postcopy_advise(struct virtio_net **pdev, > + struct VhostUserMsg *msg, > + int main_fd __rte_unused) > +{ > + struct virtio_net *dev = *pdev; > +#ifdef RTE_LIBRTE_VHOST_POSTCOPY > + struct uffdio_api api_struct; > + > + dev->postcopy_ufd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK); > + > + if (dev->postcopy_ufd == -1) { > + RTE_LOG(ERR, VHOST_CONFIG, "Userfaultfd not available: %s\n", > + strerror(errno)); > + return VH_RESULT_ERR; > + } > + api_struct.api = UFFD_API; > + api_struct.features = 0; > + if (ioctl(dev->postcopy_ufd, UFFDIO_API, &api_struct)) { > + RTE_LOG(ERR, VHOST_CONFIG, "UFFDIO_API ioctl failure: %s\n", > + strerror(errno)); > + close(dev->postcopy_ufd); > + return VH_RESULT_ERR; > + } > + msg->fds[0] = dev->postcopy_ufd; > + msg->fd_num = 1; > + > + return VH_RESULT_REPLY; > +#else > + dev->postcopy_ufd = -1; > + msg->fd_num = 0; > + > + return VH_RESULT_ERR; > +#endif > +} > + > typedef int (*vhost_message_handler_t)(struct virtio_net **pdev, > struct VhostUserMsg *msg, > int main_fd); > @@ -1536,6 +1579,7 @@ static vhost_message_handler_t vhost_message_handlers[VHOST_USER_MAX] = { > [VHOST_USER_NET_SET_MTU] = vhost_user_net_set_mtu, > [VHOST_USER_SET_SLAVE_REQ_FD] = vhost_user_set_req_fd, > [VHOST_USER_IOTLB_MSG] = vhost_user_iotlb_msg, > + [VHOST_USER_POSTCOPY_ADVISE] = vhost_user_set_postcopy_advise, > }; > > > diff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h > index dd0262f8f..2030b40a5 100644 > --- a/lib/librte_vhost/vhost_user.h > +++ b/lib/librte_vhost/vhost_user.h > @@ -50,7 +50,8 @@ typedef enum VhostUserRequest { > VHOST_USER_IOTLB_MSG = 22, > VHOST_USER_CRYPTO_CREATE_SESS = 26, > VHOST_USER_CRYPTO_CLOSE_SESS = 27, > - VHOST_USER_MAX = 28 > + VHOST_USER_POSTCOPY_ADVISE = 28, > + VHOST_USER_MAX = 29 > } VhostUserRequest; > > typedef enum VhostUserSlaveRequest { >