[dpdk-dev] [PATCH v2] librte_ether: release memory in uninit function.

Iremonger, Bernard bernard.iremonger at intel.com
Mon Jun 29 12:20:20 CEST 2015



> -----Original Message-----
> From: Qiu, Michael
> Sent: Monday, June 29, 2015 9:55 AM
> To: Iremonger, Bernard; dev at dpdk.org
> Cc: Zhang, Helin; Ananyev, Konstantin; mukawa at igel.co.jp; Stephen
> Hemminger
> Subject: Re: [PATCH v2] librte_ether: release memory in uninit function.
> 
> On 6/26/2015 5:32 PM, Iremonger, Bernard wrote:
> > Changes in v2:
> > do not free mac_addrs and hash_mac_addrs here.
> >
> > Signed-off-by: Bernard Iremonger <bernard.iremonger at intel.com>
> > ---
> >  lib/librte_ether/rte_ethdev.c |    6 +++++-
> >  1 files changed, 5 insertions(+), 1 deletions(-)
> >
> > diff --git a/lib/librte_ether/rte_ethdev.c
> > b/lib/librte_ether/rte_ethdev.c index e13fde5..7ae101a 100644
> > --- a/lib/librte_ether/rte_ethdev.c
> > +++ b/lib/librte_ether/rte_ethdev.c
> > @@ -369,8 +369,12 @@ rte_eth_dev_uninit(struct rte_pci_device
> *pci_dev)
> >  	/* free ether device */
> >  	rte_eth_dev_release_port(eth_dev);
> >
> > -	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
> > +	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
> > +		rte_free(eth_dev->data->rx_queues);
> > +		rte_free(eth_dev->data->tx_queues);
> >  		rte_free(eth_dev->data->dev_private);
> > +		memset(eth_dev->data, 0, sizeof(struct
> rte_eth_dev_data));
> > +	}
> >
> >  	eth_dev->pci_dev = NULL;
> >  	eth_dev->driver = NULL;
> 
> 
> Actually, This could be put in rte_eth_dev_close() becasue queues should be
> released when closed.
> 
> Also before free dev->data->rx_queues you should make sure
> dev->data->rx_queues[i] has been freed in PMD close() function, So this
> two should be better done at the same time, ether in
> rte_eth_dev_close() or in PMD close() function. For hotplug in fm10k, I put it
> in PMD close() function.
> 
> Thanks,
> Michael
Hi Michael,
 
The consensus is that the rx_queue and tx_queue memory should not be released 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 are both called from rte_eth_dev_configure() which is called by the application (for example test_pmd). So it seems to make sense to free this memory  in rte_eth_dev_uninit().

Regards,

Bernard.






More information about the dev mailing list