[dpdk-dev] [PATCH v3 1/2] ethdev: free all common data when releasing port

Thomas Monjalon thomas at monjalon.net
Tue Oct 16 14:22:43 CEST 2018


16/10/2018 13:16, Andrew Rybchenko:
> On 10/15/18 2:20 AM, Thomas Monjalon wrote:
> > This is a clean-up of common ethdev data freeing.
> > All data freeing are moved to rte_eth_dev_release_port()
> > and done only in case of primary process.
> >
> > It is probably fixing some memory leaks for PMDs which were
> > not freeing all data.
[...]
> > --- a/drivers/net/softnic/rte_eth_softnic.c
> > +++ b/drivers/net/softnic/rte_eth_softnic.c
> > @@ -556,7 +556,6 @@ static int
> >   pmd_remove(struct rte_vdev_device *vdev)
> >   {
> >   	struct rte_eth_dev *dev = NULL;
> > -	struct pmd_internals *p;
> >   
> >   	if (!vdev)
> >   		return -EINVAL;
> > @@ -567,12 +566,11 @@ pmd_remove(struct rte_vdev_device *vdev)
> >   	dev = rte_eth_dev_allocated(rte_vdev_device_name(vdev));
> >   	if (dev == NULL)
> >   		return -ENODEV;
> > -	p = dev->data->dev_private;
> >   
> >   	/* Free device data structures*/
> > -	rte_free(dev->data);
> > +	pmd_free(dev->data->dev_private);
> > +	dev->data->dev_private = NULL;
> >   	rte_eth_dev_release_port(dev);
> > -	pmd_free(p);
> >   
> >   	return 0;
> >   }
> 
> The above basically violates approach used everywhere else. It is OK to 
> go, but should be reconsidered.

Yes, it is because pmd_free does more than freeing just dev_private.

[...]
> Not directly related to the patch, but I don't understand why does
> rte_eth_dev_pci_release () exist? It does nothing PCI specific.
> May be just for symmetry to rte_eth_dev_pci_allocate().
> Why is intr_handle set to NULL above? Is it PCI specific?
> It does not look so, since failsafe uses it.

I agree that all these functions must be reconsidered and reworked.
We should consider a big cleanup in ethdev for 19.02.

> In general it looks good, really big work, but ideally it should be
> acked by cxgbe maintainer as well.

Actually, after more thoughts, I think this patch is not correct.
It is freeing MAC adresses in ethdev, even if there was no specific
allocation done for it in the PMD. Only the PMD can know what are the
memory blocks to free.
And it is the same for data->dev_private: are we sure it has been malloc'ed?
Are we sure it has not been allocated as part of a bigger block?
Historically, ethdev was freeing data->dev_private in some cases.
So maybe we can keep this assumption.
Or we can move all data freeing to the PMD?





More information about the dev mailing list