All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: Andrew Rybchenko <arybchenko@solarflare.com>
Cc: ferruh.yigit@intel.com, dev@dpdk.org, ophirmu@mellanox.com
Subject: Re: [PATCH v3 2/2] ethdev: complete closing of port
Date: Tue, 16 Oct 2018 14:25:31 +0200	[thread overview]
Message-ID: <3636040.QE9XrHhWxf@xps> (raw)
In-Reply-To: <96ba9604-6cc1-6716-c783-facb44161117@solarflare.com>

16/10/2018 13:24, Andrew Rybchenko:
> On 10/15/18 2:20 AM, Thomas Monjalon wrote:
> > After closing a port, it cannot be restarted.
> > So there is no reason to not free all associated resources.
> >
> > The last step was done with rte_eth_dev_detach() which is deprecated.
> > Instead of blindly removing the associated rte_device, the driver should
> > check if no more port (ethdev, cryptodev, etc) is open for the device.
> >
> > The last ethdev freeing which were done by rte_eth_dev_detach(),
> > are now done at the end of rte_eth_dev_close().
> >
> > If the driver is trying to free the port again, the function
> > rte_eth_dev_release_port() will abort with -ENODEV error.
> >
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> > ---
> >   drivers/net/bnxt/bnxt_ethdev.c    | 4 ----
> >   drivers/net/vhost/rte_eth_vhost.c | 4 ----
> >   lib/librte_ethdev/rte_ethdev.c    | 9 +++------
> >   lib/librte_ethdev/rte_ethdev.h    | 3 +--
> >   4 files changed, 4 insertions(+), 16 deletions(-)
> >
> > diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
> > index ff41cb0fa..183b40821 100644
> > --- a/drivers/net/bnxt/bnxt_ethdev.c
> > +++ b/drivers/net/bnxt/bnxt_ethdev.c
> > @@ -712,10 +712,6 @@ static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev)
> >   	if (bp->dev_stopped == 0)
> >   		bnxt_dev_stop_op(eth_dev);
> >   
> > -	if (eth_dev->data->mac_addrs != NULL) {
> > -		rte_free(eth_dev->data->mac_addrs);
> > -		eth_dev->data->mac_addrs = NULL;
> > -	}
> >   	if (bp->grp_info != NULL) {
> >   		rte_free(bp->grp_info);
> >   		bp->grp_info = NULL;
> > diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
> > index 986bf9633..b9cefbbe5 100644
> > --- a/drivers/net/vhost/rte_eth_vhost.c
> > +++ b/drivers/net/vhost/rte_eth_vhost.c
> > @@ -998,12 +998,8 @@ eth_dev_close(struct rte_eth_dev *dev)
> >   		for (i = 0; i < dev->data->nb_tx_queues; i++)
> >   			rte_free(dev->data->tx_queues[i]);
> >   
> > -	rte_free(dev->data->mac_addrs);
> >   	free(internal->dev_name);
> >   	free(internal->iface_name);
> > -	rte_free(internal);
> > -
> > -	dev->data->dev_private = NULL;
> >   }
> >   
> >   static int
> 
> It looks like above snippets should be a part of previous changeset.

No, this is related to close function.

> > --- a/lib/librte_ethdev/rte_ethdev.c
> > +++ b/lib/librte_ethdev/rte_ethdev.c
> > @@ -367,6 +367,8 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
> >   {
> >   	if (eth_dev == NULL)
> >   		return -EINVAL;
> > +	if (eth_dev->state == RTE_ETH_DEV_UNUSED)
> > +		return -ENODEV;
> >   
> >   	rte_eth_dev_shared_data_prepare();
> >   
> > @@ -1384,12 +1386,7 @@ rte_eth_dev_close(uint16_t port_id)
> >   	dev->data->dev_started = 0;
> >   	(*dev->dev_ops->dev_close)(dev);
> >   
> > -	dev->data->nb_rx_queues = 0;
> > -	rte_free(dev->data->rx_queues);
> > -	dev->data->rx_queues = NULL;
> > -	dev->data->nb_tx_queues = 0;
> > -	rte_free(dev->data->tx_queues);
> > -	dev->data->tx_queues = NULL;
> > +	rte_eth_dev_release_port(dev);
> >   }
> >   
> >   int
> 
> Right now it introduces resource leak for resources which are
> freed by PCI drivers in uninit.

No, these resources are freed by rte_eth_dev_release_port.

  reply	other threads:[~2018-10-16 12:25 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-07 23:39 [RFC] ethdev: complete closing to free all resources Thomas Monjalon
2018-09-10  8:03 ` Andrew Rybchenko
2018-09-10  8:42   ` Thomas Monjalon
2018-09-10  8:54     ` Andrew Rybchenko
2018-09-12 14:57       ` Thomas Monjalon
2018-09-12 15:44         ` Andrew Rybchenko
2018-09-28 12:46 ` Ferruh Yigit
2018-10-09 22:00   ` Thomas Monjalon
2018-10-09 22:17 ` [PATCH v2] ethdev: complete closing of port Thomas Monjalon
2018-10-10  6:15   ` Andrew Rybchenko
2018-10-10  7:44     ` Thomas Monjalon
2018-10-10  7:50       ` Andrew Rybchenko
2018-10-10  8:39         ` Thomas Monjalon
2018-10-10 15:01           ` Andrew Rybchenko
2018-10-10 16:43             ` Thomas Monjalon
2018-10-10 18:01               ` Andrew Rybchenko
2018-10-10 19:03                 ` Thomas Monjalon
2018-10-14 23:20 ` [PATCH v3 0/2] ethdev port freeing Thomas Monjalon
2018-10-14 23:20   ` [PATCH v3 1/2] ethdev: free all common data when releasing port Thomas Monjalon
2018-10-16 11:16     ` Andrew Rybchenko
2018-10-16 12:22       ` Thomas Monjalon
2018-10-16 12:47         ` Andrew Rybchenko
2018-10-16 12:52           ` Thomas Monjalon
2018-10-16 12:55             ` Andrew Rybchenko
2018-10-14 23:20   ` [PATCH v3 2/2] ethdev: complete closing of port Thomas Monjalon
2018-10-16 11:24     ` Andrew Rybchenko
2018-10-16 12:25       ` Thomas Monjalon [this message]
2018-10-17  1:54 ` [PATCH v3 0/4] ethdev port freeing Thomas Monjalon
2018-10-17  1:54   ` [PATCH v3 1/4] app/testpmd: allow detaching a port not closed Thomas Monjalon
2018-10-17  2:06     ` Thomas Monjalon
2018-10-17  6:26     ` Andrew Rybchenko
2018-10-17  8:20       ` Thomas Monjalon
2018-10-17 10:30         ` Iremonger, Bernard
2018-10-17 11:33           ` Thomas Monjalon
2018-10-17  1:54   ` [PATCH v3 2/4] ethdev: free all common data when releasing port Thomas Monjalon
2018-10-17  7:13     ` Andrew Rybchenko
2018-10-17  8:22       ` Thomas Monjalon
2018-10-17  1:54   ` [PATCH v3 3/4] ethdev: remove release function for secondary process Thomas Monjalon
2018-10-17  7:25     ` Andrew Rybchenko
2018-10-17  9:27       ` Thomas Monjalon
2018-10-17  1:54   ` [PATCH v3 4/4] ethdev: complete closing of port Thomas Monjalon
2018-10-17  2:12     ` Thomas Monjalon
2018-10-17 10:24   ` [PATCH v3 0/4] ethdev port freeing Shreyansh Jain
2018-10-17 11:31     ` Thomas Monjalon
2018-10-18  1:23 ` [PATCH v5 0/6] " Thomas Monjalon
2018-10-18  1:23   ` [PATCH v5 1/6] app/testpmd: fix ports list after removing several at once Thomas Monjalon
2018-10-18 10:40     ` Iremonger, Bernard
2018-10-18 11:29       ` Thomas Monjalon
2018-10-18 11:41         ` Iremonger, Bernard
2018-10-18 14:21           ` Thomas Monjalon
2018-10-18 16:42             ` Iremonger, Bernard
2018-10-18 17:06               ` Thomas Monjalon
2018-10-18 11:49         ` Wisam Monther
2018-10-18 13:22           ` Iremonger, Bernard
2018-10-18  1:23   ` [PATCH v5 2/6] app/testpmd: allow detaching a port not closed Thomas Monjalon
2018-10-18  7:45     ` Andrew Rybchenko
2018-10-18 10:51       ` Iremonger, Bernard
2018-10-18 11:24         ` Thomas Monjalon
2018-10-18  1:23   ` [PATCH v5 3/6] ethdev: fix doxygen comments of shared data fields Thomas Monjalon
2018-10-18  7:11     ` Andrew Rybchenko
2018-10-18  1:24   ` [PATCH v5 4/6] ethdev: free all common data when releasing port Thomas Monjalon
2018-10-18  7:13     ` Andrew Rybchenko
2018-10-18  1:24   ` [PATCH v5 5/6] ethdev: remove release function for secondary process Thomas Monjalon
2018-10-18  7:15     ` Andrew Rybchenko
2018-10-18  1:24   ` [PATCH v5 6/6] ethdev: complete closing of port Thomas Monjalon
2018-10-18  8:33     ` Andrew Rybchenko
2018-10-18  9:32       ` Thomas Monjalon
2018-10-19  2:07 ` [PATCH v6 0/6] ethdev port freeing Thomas Monjalon
2018-10-19  2:07   ` [PATCH v6 1/6] app/testpmd: update port list for multiple removals Thomas Monjalon
2018-10-19 14:32     ` Iremonger, Bernard
2018-10-19  2:07   ` [PATCH v6 2/6] app/testpmd: allow detaching a port not closed Thomas Monjalon
2018-10-19 14:32     ` Iremonger, Bernard
2018-10-19  2:07   ` [PATCH v6 3/6] ethdev: fix doxygen comments of shared data fields Thomas Monjalon
2018-10-19  2:07   ` [PATCH v6 4/6] ethdev: free all common data when releasing port Thomas Monjalon
2018-10-19  2:07   ` [PATCH v6 5/6] ethdev: remove release function for secondary process Thomas Monjalon
2018-10-19  2:07   ` [PATCH v6 6/6] ethdev: complete closing of port Thomas Monjalon
2018-10-19 10:13     ` Andrew Rybchenko
2018-10-22 15:43   ` [PATCH v6 0/6] ethdev port freeing Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3636040.QE9XrHhWxf@xps \
    --to=thomas@monjalon.net \
    --cc=arybchenko@solarflare.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=ophirmu@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.