From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Qiu, Michael" Subject: Re: [PATCH v2] librte_ether: release memory in uninit function. Date: Mon, 29 Jun 2015 15:22:04 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286046A6ED8@SHSMSX101.ccr.corp.intel.com> References: <1435311160-8679-1-git-send-email-bernard.iremonger@intel.com> <533710CFB86FA344BFBF2D6802E60286046A625A@SHSMSX101.ccr.corp.intel.com> <8CEF83825BEC744B83065625E567D7C204A42C88@IRSMSX108.ger.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable To: "Iremonger, Bernard" , "dev@dpdk.org" Return-path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 1D345C376 for ; Mon, 29 Jun 2015 17:22:10 +0200 (CEST) Content-Language: en-US List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 2015/6/29 18:20, Iremonger, Bernard wrote:=0A= >=0A= >> -----Original Message-----=0A= >> From: Qiu, Michael=0A= >> Sent: Monday, June 29, 2015 9:55 AM=0A= >> To: Iremonger, Bernard; dev@dpdk.org=0A= >> Cc: Zhang, Helin; Ananyev, Konstantin; mukawa@igel.co.jp; Stephen=0A= >> Hemminger=0A= >> Subject: Re: [PATCH v2] librte_ether: release memory in uninit function.= =0A= >>=0A= >> On 6/26/2015 5:32 PM, Iremonger, Bernard wrote:=0A= >>> Changes in v2:=0A= >>> do not free mac_addrs and hash_mac_addrs here.=0A= >>>=0A= >>> Signed-off-by: Bernard Iremonger =0A= >>> ---=0A= >>> lib/librte_ether/rte_ethdev.c | 6 +++++-=0A= >>> 1 files changed, 5 insertions(+), 1 deletions(-)=0A= >>>=0A= >>> diff --git a/lib/librte_ether/rte_ethdev.c=0A= >>> b/lib/librte_ether/rte_ethdev.c index e13fde5..7ae101a 100644=0A= >>> --- a/lib/librte_ether/rte_ethdev.c=0A= >>> +++ b/lib/librte_ether/rte_ethdev.c=0A= >>> @@ -369,8 +369,12 @@ rte_eth_dev_uninit(struct rte_pci_device=0A= >> *pci_dev)=0A= >>> /* free ether device */=0A= >>> rte_eth_dev_release_port(eth_dev);=0A= >>>=0A= >>> - if (rte_eal_process_type() =3D=3D RTE_PROC_PRIMARY)=0A= >>> + if (rte_eal_process_type() =3D=3D RTE_PROC_PRIMARY) {=0A= >>> + rte_free(eth_dev->data->rx_queues);=0A= >>> + rte_free(eth_dev->data->tx_queues);=0A= >>> rte_free(eth_dev->data->dev_private);=0A= >>> + memset(eth_dev->data, 0, sizeof(struct=0A= >> rte_eth_dev_data));=0A= >>> + }=0A= >>>=0A= >>> eth_dev->pci_dev =3D NULL;=0A= >>> eth_dev->driver =3D NULL;=0A= >>=0A= >> Actually, This could be put in rte_eth_dev_close() becasue queues should= be=0A= >> released when closed.=0A= >>=0A= >> Also before free dev->data->rx_queues you should make sure=0A= >> dev->data->rx_queues[i] has been freed in PMD close() function, So this= =0A= >> two should be better done at the same time, ether in=0A= >> rte_eth_dev_close() or in PMD close() function. For hotplug in fm10k, I = put it=0A= >> in PMD close() function.=0A= >>=0A= >> Thanks,=0A= >> Michael=0A= > Hi Michael,=0A= > =0A= > The consensus is that the rx_queue and tx_queue memory should not be rele= ased in the PMD as it is not allocated by the PMD. The memory is allocated = in rte_eth_dev_rx_queue_config() and rte_eth_dev_tx_queue_config(), which a= re both called from rte_eth_dev_configure() which is called by the applicat= ion (for example test_pmd). So it seems to make sense to free this memory = in rte_eth_dev_uninit().=0A= =0A= It really make sense to free memory in rte_ether level, but when close a=0A= port with out detached? just as stop --> close() --> quit(), the memory=0A= will not be released :)=0A= =0A= Thanks,=0A= Michael=0A= =0A= >=0A= > Regards,=0A= >=0A= > Bernard.=0A= >=0A= >=0A= >=0A= >=0A= >=0A= =0A=