From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 2CBEA7CDA for ; Thu, 27 Sep 2018 10:26:10 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180927082609euoutp028c348a77c7ef66119e33c98201172a7e~YNEsXdnL60471104711euoutp02T for ; Thu, 27 Sep 2018 08:26:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180927082609euoutp028c348a77c7ef66119e33c98201172a7e~YNEsXdnL60471104711euoutp02T DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1538036769; bh=Jpq2O3fJWwAqDvUOSVwjE52WFPv/YjORS2kP/36ZlPc=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=f0ZEgmZWEDhXm19gfoxcvZKXbZiEqLqmTXOLlCEmqLbPxgaeDLcPz9/NBF2wYM0W4 YiBCtk6DPrnf0vERcZBY/Jumj6G246S8B/ztBFQYumvYaM9vYUJoJ78jJwxQo0RZDX Rwd4tgSKU3nMEngZGKlvGM+3M7wtLx/VW3KBOqK4= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180927082609eucas1p19f2628091953c360d567bd7a16bbd66f~YNEr6OSzq1463614636eucas1p1g; Thu, 27 Sep 2018 08:26:09 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 1E.D8.04294.1249CAB5; Thu, 27 Sep 2018 09:26:09 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20180927082608eucas1p17cd1d99e54134fb2a6de3151e52048f3~YNErH8Swu2138421384eucas1p1G; Thu, 27 Sep 2018 08:26:08 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20180927082608eusmtrp169e4aabd1e263bd690ef60339282ce6a~YNEq28Y3z1425014250eusmtrp1K; Thu, 27 Sep 2018 08:26:08 +0000 (GMT) X-AuditID: cbfec7f4-835ff700000010c6-aa-5bac94208cc7 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id B3.BD.04128.0249CAB5; Thu, 27 Sep 2018 09:26:08 +0100 (BST) Received: from [106.109.129.180] (unknown [106.109.129.180]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20180927082607eusmtip12302a2af62accd81c6685db2351e7193~YNEqUnID93250832508eusmtip1S; Thu, 27 Sep 2018 08:26:07 +0000 (GMT) To: Maxime Coquelin , dev@dpdk.org, tiwei.bie@intel.com, zhihong.wang@intel.com, jfreimann@redhat.com Cc: dgilbert@redhat.com, Thomas Monjalon From: Ilya Maximets Date: Thu, 27 Sep 2018 11:28:12 +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: <20180926072705.22641-5-maxime.coquelin@redhat.com> Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA02Sa0hTcRjG+Z9z5jkbbRyn4atF4kowUWcieqJSi6jVp5CCSLoc9aSSU9vx kvWh0UVNM0RNayi5xLzN1DInIpK6vCSNiiSFUPMSOJ2ZSmWa5naU/Pbwe9/n/T8P/ClcbhC5 UXEJyZwmgY1XOEiI5u4ls69HoSHCX2fFmNl5I8bkNg+TzKfMJZIxGyoIpvteG8HMj/YSzCvt Gsa8/JCPhVGqP2UVIlV52xSm6h4qIlXf2wccVA+aatAp0TnJwWguPi6V0yhDLkliq3P2Jxl3 XTOujCMtmoFsJKaADgTL7yrcpuV0FYK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kFi9/AUrRI2gxMmZT8Bq OAUcJBaemwzWyyygLvFn3iVmCFtcounLSlYIW15i+9s5zBMYhWYhaZ+FpGUWkpZZSFoWMLKs YhRJLS3OTc8tNtIrTswtLs1L10vOz93ECIy/bcd+btnB2PUu+BCjAAejEg/vho2ro4VYE8uK K3MPMUpwMCuJ8OYqrokW4k1JrKxKLcqPLyrNSS0+xGgK9NxEZinR5HxgasgriTc0NTS3sDQ0 NzY3NrNQEuc9b1AZJSSQnliSmp2aWpBaBNPHxMEp1cDottdx3yODoi1/LL62LRW/Ync4RyvN MDNx2aG599v0Gt2MirVmtzRYPfmyptJhztRPv/fWBj5nuhehvz/+K1/69v1xRrPZOhzfHtgR pncnw//B8SW/tK5WxrlxbFrI9dX2o0R2W+X6lbHZbnc+RZgX3emQPOuo7a957sblAwcEPLdk 5O643u6jxFKckWioxVxUnAgAWHifnNUCAAA= Message-Id: <20180927082608eucas1p17cd1d99e54134fb2a6de3151e52048f3~YNErH8Swu2138421384eucas1p1G@eucas1p1.samsung.com> X-CMS-MailID: 20180927082608eucas1p17cd1d99e54134fb2a6de3151e52048f3 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20180927082608eucas1p17cd1d99e54134fb2a6de3151e52048f3 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180927082608eucas1p17cd1d99e54134fb2a6de3151e52048f3 References: <20180926072705.22641-1-maxime.coquelin@redhat.com> <20180926072705.22641-5-maxime.coquelin@redhat.com> Subject: Re: [dpdk-dev] [04/12] 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: Thu, 27 Sep 2018 08:26:11 -0000 On 26.09.2018 10:26, 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 | 37 +++++++++++++++++++++++++++++++++++ > lib/librte_vhost/vhost_user.h | 3 ++- > 3 files changed, 41 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 a9b429598..bdfe2cac0 100644 > --- a/lib/librte_vhost/vhost_user.c > +++ b/lib/librte_vhost/vhost_user.c > @@ -24,9 +24,13 @@ > #include > #include > #include > +#include > +#include Maybe we need compile time check for this header existence? Otherwise, this will bump minimal kernel version for default linux build to something like 4.3. > +#include > #include > #include > #include > +#include > #include > #ifdef RTE_LIBRTE_VHOST_NUMA > #include > @@ -69,6 +73,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", > }; > > static uint64_t > @@ -1412,6 +1417,33 @@ vhost_user_iotlb_msg(struct virtio_net **pdev, struct VhostUserMsg *msg) > return 0; > } > > +static int > +vhost_user_set_postcopy_advise(struct virtio_net *dev, struct VhostUserMsg *msg) > +{ > + 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 -1; > + } > + 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 -1; > + } > + msg->fds[0] = dev->postcopy_ufd; > + msg->fd_num = 1; > + > + return 0; > +} > + > /* return bytes# of read on success or negative val on failure. */ > static int > read_vhost_message(int sockfd, struct VhostUserMsg *msg) > @@ -1756,6 +1788,11 @@ vhost_user_msg_handler(int vid, int fd) > ret = vhost_user_iotlb_msg(&dev, &msg); > break; > > + case VHOST_USER_POSTCOPY_ADVISE: > + vhost_user_set_postcopy_advise(dev, &msg); > + send_vhost_reply(fd, &msg); > + break; > + > default: > ret = -1; > break; > 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 { >