From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 37DECF72; Thu, 16 Aug 2018 07:32:08 +0200 (CEST) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Aug 2018 22:32:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,246,1531810800"; d="scan'208";a="83747604" Received: from debian.sh.intel.com (HELO debian) ([10.67.104.194]) by orsmga002.jf.intel.com with ESMTP; 15 Aug 2018 22:31:49 -0700 Date: Thu, 16 Aug 2018 13:31:08 +0800 From: Tiwei Bie To: Ilya Maximets Cc: dev@dpdk.org, Maxime Coquelin , Zhihong Wang , Junjie Chen , stable@dpdk.org Message-ID: <20180816053108.GA8252@debian> References: <20180815145439.2513-1-i.maximets@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180815145439.2513-1-i.maximets@samsung.com> User-Agent: Mutt/1.10.1 (2018-07-13) Subject: Re: [dpdk-dev] [PATCH] vhost: fix zmbufs array leak after NUMA realloc 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, 16 Aug 2018 05:32:09 -0000 On Wed, Aug 15, 2018 at 05:54:39PM +0300, Ilya Maximets wrote: > 'numa_realloc()' allocates 'zmbufs' even if zero copy mode > is not configured. This leads to memory leak, because array > is freed only for zero copy case. > > Fixes: 2651726defb7 ("vhost: do deep copy while reallocating queue") > CC: stable@dpdk.org > > Signed-off-by: Ilya Maximets > --- > lib/librte_vhost/vhost_user.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c > index a2d4c9ffc..9aa1ce118 100644 > --- a/lib/librte_vhost/vhost_user.c > +++ b/lib/librte_vhost/vhost_user.c > @@ -357,11 +357,13 @@ numa_realloc(struct virtio_net *dev, int index) > memcpy(vq, old_vq, sizeof(*vq)); > TAILQ_INIT(&vq->zmbuf_list); > > - new_zmbuf = rte_malloc_socket(NULL, vq->zmbuf_size * > - sizeof(struct zcopy_mbuf), 0, newnode); > - if (new_zmbuf) { > - rte_free(vq->zmbufs); > - vq->zmbufs = new_zmbuf; > + if (dev->dequeue_zero_copy) { > + new_zmbuf = rte_malloc_socket(NULL, vq->zmbuf_size * > + sizeof(struct zcopy_mbuf), 0, newnode); > + if (new_zmbuf) { > + rte_free(vq->zmbufs); > + vq->zmbufs = new_zmbuf; > + } > } > > if (vq_is_packed(dev)) { > -- > 2.17.1 > Reviewed-by: Tiwei Bie Thanks!