From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 5A1615597 for ; Mon, 18 Apr 2016 20:13:26 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP; 18 Apr 2016 11:13:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,503,1455004800"; d="scan'208";a="961317387" Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.67.162]) by fmsmga002.fm.intel.com with ESMTP; 18 Apr 2016 11:13:24 -0700 Date: Mon, 18 Apr 2016 11:14:22 -0700 From: Yuanhan Liu To: Christian Ehrhardt Cc: dev , Daniele Di Proietto Message-ID: <20160418181422.GE2576@yliu-dev.sh.intel.com> References: <20160418174650.GD2576@yliu-dev.sh.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160418174650.GD2576@yliu-dev.sh.intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] Memory leak when adding/removing vhost_user ports 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 Apr 2016 18:13:26 -0000 On Mon, Apr 18, 2016 at 10:46:50AM -0700, Yuanhan Liu wrote: > On Mon, Apr 18, 2016 at 07:18:05PM +0200, Christian Ehrhardt wrote: > > I assume there is a leak somewhere on adding/removing vhost_user ports. > > Although it could also be "only" a fragmentation issue. > > > > Reproduction is easy: > > I set up a pair of nicely working OVS-DPDK connected KVM Guests. > > Then in a loop I > > - add up to more 512 ports > > - test connectivity between the two guests > > - remove up to 512 ports > > > > Depending on memory and the amount of multiqueue/rxq I use it seems to > > slightly change when exactly it breaks. But for my default setup of 4 > > queues and 5G Hugepages initialized by DPDK it always breaks at the sixth > > iteration. > > Here a link to the stack trace indicating a memory shortage (TBC): > > https://launchpadlibrarian.net/253916410/apport-retrace.log > > > > Known Todos: > > - I want to track it down more, and will try to come up with a non > > openvswitch based looping testcase that might show it as well to simplify > > debugging. > > - in use were Openvswitch-dpdk 2.5 and DPDK 2.2; Retest with DPDK 16.04 and > > Openvswitch master is planned. > > > > I will go on debugging this and let you know, but I wanted to give a heads > > up to everyone. > > Thanks for the report. > > > In case this is a known issue for some of you please let me know. > > Yeah, it might be. I'm wondering that virtio_net struct is not freed. > It will be freed only (if I'm not mistaken) when guest quits, by far. Would you try following diff and to see if it fix your issue? --yliu --- lib/librte_vhost/vhost_user/vhost-net-user.c | 6 ++++++ lib/librte_vhost/vhost_user/vhost-net-user.h | 1 + 2 files changed, 7 insertions(+) diff --git a/lib/librte_vhost/vhost_user/vhost-net-user.c b/lib/librte_vhost/vhost_user/vhost-net-user.c index df2bd64..8f7ebd7 100644 --- a/lib/librte_vhost/vhost_user/vhost-net-user.c +++ b/lib/librte_vhost/vhost_user/vhost-net-user.c @@ -309,6 +309,7 @@ vserver_new_vq_conn(int fd, void *dat, __rte_unused int *remove) } vdev_ctx.fh = fh; + vserver->fh = fh; size = strnlen(vserver->path, PATH_MAX); vhost_set_ifname(vdev_ctx, vserver->path, size); @@ -501,6 +502,11 @@ rte_vhost_driver_unregister(const char *path) for (i = 0; i < g_vhost_server.vserver_cnt; i++) { if (!strcmp(g_vhost_server.server[i]->path, path)) { + struct vhost_device_ctx ctx; + + ctx.fh = g_vhost_server.server[i]->fh; + vhost_destroy_device(ctx); + fdset_del(&g_vhost_server.fdset, g_vhost_server.server[i]->listenfd); diff --git a/lib/librte_vhost/vhost_user/vhost-net-user.h b/lib/librte_vhost/vhost_user/vhost-net-user.h index e3bb413..7cf21db 100644 --- a/lib/librte_vhost/vhost_user/vhost-net-user.h +++ b/lib/librte_vhost/vhost_user/vhost-net-user.h @@ -43,6 +43,7 @@ struct vhost_server { char *path; /**< The path the uds is bind to. */ int listenfd; /**< The listener sockfd. */ + uint32_t fh; }; /* refer to hw/virtio/vhost-user.c */ -- 1.9.3