From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 9DD9E37AA for ; Mon, 18 Jan 2016 08:56:11 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP; 17 Jan 2016 23:56:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,311,1449561600"; d="scan'208";a="892831304" Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.66.49]) by orsmga002.jf.intel.com with ESMTP; 17 Jan 2016 23:56:10 -0800 Date: Mon, 18 Jan 2016 15:58:08 +0800 From: Yuanhan Liu To: Rich Lane Message-ID: <20160118075808.GZ19531@yliu-dev.sh.intel.com> References: <1452032049-94324-1-git-send-email-rlane@bigswitch.com> <1453060638-58510-1-git-send-email-rlane@bigswitch.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1453060638-58510-1-git-send-email-rlane@bigswitch.com> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH v2 1/1] vhost: fix leak of fds and mmaps X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jan 2016 07:56:12 -0000 On Sun, Jan 17, 2016 at 11:57:18AM -0800, Rich Lane wrote: > The common vhost code only supported a single mmap per device. vhost-user > worked around this by saving the address/length/fd of each mmap after the end > of the rte_virtio_memory struct. This only works if the vhost-user code frees > dev->mem, since the common code is unaware of the extra info. The > VHOST_USER_RESET_OWNER message is one situation where the common code frees > dev->mem and leaks the fds and mappings. This happens every time I shut down a > VM. > > The new code calls back into the implementation (vhost-user or vhost-cuse) to > clean up these resources. > > The vhost-cuse changes are only compile tested. > > Signed-off-by: Rich Lane > --- > v1->v2: > - Call into vhost-user/vhost-cuse to free mmaps. > > lib/librte_vhost/vhost-net.h | 6 ++++++ > lib/librte_vhost/vhost_cuse/virtio-net-cdev.c | 12 ++++++++++++ > lib/librte_vhost/vhost_user/vhost-net-user.c | 1 - > lib/librte_vhost/vhost_user/virtio-net-user.c | 25 ++++++++++--------------- > lib/librte_vhost/vhost_user/virtio-net-user.h | 1 - > lib/librte_vhost/virtio-net.c | 8 +------- > 6 files changed, 29 insertions(+), 24 deletions(-) > > diff --git a/lib/librte_vhost/vhost-net.h b/lib/librte_vhost/vhost-net.h > index c69b60b..e8d7477 100644 > --- a/lib/librte_vhost/vhost-net.h > +++ b/lib/librte_vhost/vhost-net.h > @@ -115,4 +115,10 @@ struct vhost_net_device_ops { > > > struct vhost_net_device_ops const *get_virtio_net_callbacks(void); > + > +/* > + * Implementation-specific cleanup. Defined by vhost-cuse and vhost-user. > + */ > +void vhost_impl_cleanup(struct virtio_net *dev); TBH, I am not quite like "_impl_"; maybe "_backend_" is better? OTOH, what I thought of has slight difference than yours: not necessary to export a function, but instead, call the vhost backend specific unmap function inside the backend itself. Say, call vhost_user_unmap() on RESET_OWNER and connection close. What do you think of that? --yliu