From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpbgau1.qq.com (smtpbgau1.qq.com [54.206.16.166]) by dpdk.org (Postfix) with ESMTP id 13949100F for ; Wed, 18 Jan 2017 02:37:25 +0100 (CET) X-QQ-mid: bizesmtp13t1484703438tz2swpr6 Received: from [10.0.117.171] (unknown [106.120.127.11]) by esmtp4.qq.com (ESMTP) with id ; Wed, 18 Jan 2017 09:37:17 +0800 (CST) X-QQ-SSF: 01100000000000F0F970B00A0000000 X-QQ-FEAT: wWM71EMDyA9HetxqN/W8GMcn0pGY6ybDwWPhtg28KV8oBNUVnW3wajpZvj8u9 3uYn/yqwklqf1DeyfI9mRvWz1S+jJVJDC6Z1sNctF03ENJBuffs0wbeAdnRPodcOxRvgdt2 z6zG2LqCRgWbGmnsSUlAgKuP1CloxHzhwcHrIz8IOvsr9eBWmKc3flpPwcFe2K4x7bCaF9G kvO4NkSVcYcp1vUryKviOk30oxcUCKoROq5d7ouL2pgyq24Hk3hINbS/F8B6e8yurvh8BkQ /ZWBNCvOt8XjUTkExNiiyGXvwdXhiKZNHHRg== X-QQ-GoodBg: 0 From: nickcooper-zhangtonghao Message-Id: Mime-Version: 1.0 (Mac OS X Mail 10.0 \(3226\)) Date: Wed, 18 Jan 2017 09:37:19 +0800 In-Reply-To: Cc: "ferruh.yigit@intel.com" , "dev@dpdk.org" To: Yong Wang References: <1483930780-7064-1-git-send-email-nic@opencloud.tech> X-Mailer: Apple Mail (2.3226) X-QQ-SENDSIZE: 520 X-QQ-Bgrelay: 1 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH v3 1/4] vmxnet3: Avoid memory leak in vmxnet3_dev_rx_queue_setup. 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: Wed, 18 Jan 2017 01:37:27 -0000 > On Jan 18, 2017, at 4:15 AM, Yong Wang wrote: >=20 >> -----Original Message----- >> From: Nick Zhang [mailto:nic@opencloud.tech = ] >> Sent: Sunday, January 8, 2017 7:00 PM >> To: Yong Wang > >> Cc: ferruh.yigit@intel.com ; = dev@dpdk.org ; Nick Zhang > >> Subject: [PATCH v3 1/4] vmxnet3: Avoid memory leak in >> vmxnet3_dev_rx_queue_setup. >>=20 >> This patch will check the "nb_desc" parameter for rx queue. >> Rx vmxnet rings length should be between 128-4096. >> The patch will release the rxq and re-allocation it soon >> for different "nb_desc". >>=20 >> Signed-off-by: Nick Zhang >> --- >> drivers/net/vmxnet3/vmxnet3_rxtx.c | 30 = ++++++++++++++++++------------ >> 1 file changed, 18 insertions(+), 12 deletions(-) >>=20 >> diff --git a/drivers/net/vmxnet3/vmxnet3_rxtx.c >> b/drivers/net/vmxnet3/vmxnet3_rxtx.c >> index b109168..e77374f 100644 >> --- a/drivers/net/vmxnet3/vmxnet3_rxtx.c >> +++ b/drivers/net/vmxnet3/vmxnet3_rxtx.c >> @@ -926,6 +926,21 @@ >>=20 >> PMD_INIT_FUNC_TRACE(); >>=20 >> + /* Rx vmxnet rings length should be between 128-4096 */ >> + if (nb_desc < VMXNET3_DEF_RX_RING_SIZE) { >> + PMD_INIT_LOG(ERR, "VMXNET3 Rx Ring Size Min: 128"); >> + return -EINVAL; >> + } else if (nb_desc > VMXNET3_RX_RING_MAX_SIZE) { >> + PMD_INIT_LOG(ERR, "VMXNET3 Rx Ring Size Max: 4096"); >> + return -EINVAL; >> + } >> + >> + /* Free memory prior to re-allocation if needed. */ >> + if (dev->data->rx_queues[queue_idx] !=3D NULL) { >> + = vmxnet3_dev_rx_queue_release(dev->data->rx_queues[queue_idx]); >=20 > Currently vmxnet3_dev_rx_queue_release() does not free device ring = memory. As a result, the same device ring memory allocated based on the = previous descriptor size will be used and that should also explain why = you are observing seg fault with an increased ring size. If you handle = the device ring memory free in vmxnet3_dev_rx_queue_release(), I think = the pre-allocation of ring with max size will not be needed any more. Yes, we should not free the pre-allocation of ring, but alloc only once = ring with max size. I will submit v4. Thank you.