Skip to contentSkip to conversation

librte_ether: release memory in uninit function.

PATCH Superseded Bernard Iremonger 5 participants 20 messages Jun 26, 2015 – Jul 14, 2015

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 librte_ether: release memory in uninit function.

Changes in v2:
do not free mac_addrs and hash_mac_addrs here.

---
 lib/librte_ether/rte_ethdev.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
lib/librte_ether/rte_ethdev.c +5 -1
index e13fde5..7ae101a 100644
@@ -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;
Signature · 1 line
1.7.4.1
Acked-by on v2 1/1
#1 lore raw
Quoted 26 lines

-----Original Message-----
From: Iremonger, Bernard
Sent: Friday, June 26, 2015 10:33 AM
To: [email protected]
Cc: Zhang, Helin; Ananyev, Konstantin; Qiu, Michael; [email protected]; Iremonger, Bernard
Subject: [PATCH v2] librte_ether: release memory in uninit function.

Changes in v2:
do not free mac_addrs and hash_mac_addrs here.

---
 lib/librte_ether/rte_ethdev.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
lib/librte_ether/rte_ethdev.c +0 -1
index e13fde5..7ae101a 100644
@@ -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)

lib/librte_ether/rte_ethdev.c rte_eth_dev_uninit(struct rte_pci_device *pci_dev)

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +5 -1
+	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;
--
Quoted 1 line

1.7.4.1

#2 lore raw
In reply to Bernard Iremonger
Quoted 16 lines · Bernard

Changes in v2:
do not free mac_addrs and hash_mac_addrs here.

---
 lib/librte_ether/rte_ethdev.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
lib/librte_ether/rte_ethdev.c +0 -0
index e13fde5..7ae101a 100644
@@ -369,8 +369,12 @@ rte_eth_dev_uninit(struct rte_pci_device *pci_dev)
 	/* free ether device */
 	rte_eth_dev_release_port(eth_dev);
 

lib/librte_ether/rte_ethdev.c rte_eth_dev_uninit(struct rte_pci_device *pci_dev) · line 380

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +5 -1
-	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

#3 lore raw
Quoted 44 lines

-----Original Message-----
From: Qiu, Michael
Sent: Monday, June 29, 2015 9:55 AM
To: Iremonger, Bernard; [email protected]
Cc: Zhang, Helin; Ananyev, Konstantin; [email protected]; Stephen Hemminger
Subject: Re: [PATCH v2] librte_ether: release memory in uninit function.

lib/librte_ether/rte_ethdev.c rte_eth_dev_uninit(struct rte_pci_device

Quoted 13 lines · Bernard

Changes in v2:
do not free mac_addrs and hash_mac_addrs here.

---
 lib/librte_ether/rte_ethdev.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
(quoted diff) +0 -0

b/lib/librte_ether/rte_ethdev.c index e13fde5..7ae101a 100644

lib/librte_ether/rte_ethdev.c +0 -0
@@ -369,8 +369,12 @@ rte_eth_dev_uninit(struct rte_pci_device

*pci_dev)

lib/librte_ether/rte_ethdev.c rte_eth_dev_uninit(struct rte_pci_device *pci_dev)

Quoted 9 lines
lib/librte_ether/rte_ethdev.c +4 -1
 	/* 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));

lib/librte_ether/rte_ethdev.c rte_eth_dev_uninit(struct rte_pci_device *pci_dev) · line 380

Quoted 4 lines
lib/librte_ether/rte_ethdev.c +1 -0
+	}
 
 	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.

Quoted 8 lines

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.

#4 lore raw
Quoted 48 lines · Bernard
Quoted 48 lines

-----Original Message-----
From: Qiu, Michael
Sent: Monday, June 29, 2015 9:55 AM
To: Iremonger, Bernard; [email protected]
Cc: Zhang, Helin; Ananyev, Konstantin; [email protected]; Stephen Hemminger
Subject: Re: [PATCH v2] librte_ether: release memory in uninit function.

lib/librte_ether/rte_ethdev.c rte_eth_dev_uninit(struct rte_pci_device

Quoted 13 lines · Bernard

Changes in v2:
do not free mac_addrs and hash_mac_addrs here.

---
 lib/librte_ether/rte_ethdev.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
(quoted diff) +0 -0

b/lib/librte_ether/rte_ethdev.c index e13fde5..7ae101a 100644

lib/librte_ether/rte_ethdev.c +0 -0
@@ -369,8 +369,12 @@ rte_eth_dev_uninit(struct rte_pci_device

*pci_dev)

lib/librte_ether/rte_ethdev.c rte_eth_dev_uninit(struct rte_pci_device *pci_dev)

Quoted 9 lines
lib/librte_ether/rte_ethdev.c +4 -1
 	/* 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));

lib/librte_ether/rte_ethdev.c rte_eth_dev_uninit(struct rte_pci_device *pci_dev) · line 380

Quoted 4 lines
lib/librte_ether/rte_ethdev.c +1 -0
+	}
 
 	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.

Quoted 5 lines
Quoted 2 lines

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().

It really make sense to free memory in rte_ether level, but when close a port with out detached? just as stop --> close() --> quit(), the memory will not be released :)

Thanks,
Michael

Quoted 9 lines

Regards,

Bernard.

#5 lore raw
Quoted 72 lines

-----Original Message-----
From: Qiu, Michael
Sent: Monday, June 29, 2015 4:22 PM
To: Iremonger, Bernard; [email protected]
Cc: Zhang, Helin; Ananyev, Konstantin; [email protected]; Stephen Hemminger
Subject: Re: [PATCH v2] librte_ether: release memory in uninit function.

Quoted 49 lines · Bernard
Quoted 49 lines

-----Original Message-----
From: Qiu, Michael
Sent: Monday, June 29, 2015 9:55 AM
To: Iremonger, Bernard; [email protected]
Cc: Zhang, Helin; Ananyev, Konstantin; [email protected]; Stephen Hemminger
Subject: Re: [PATCH v2] librte_ether: release memory in uninit function.

lib/librte_ether/rte_ethdev.c rte_eth_dev_uninit(struct rte_pci_device

Quoted 13 lines · Bernard

Changes in v2:
do not free mac_addrs and hash_mac_addrs here.

---
 lib/librte_ether/rte_ethdev.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
(quoted diff) +0 -0

b/lib/librte_ether/rte_ethdev.c index e13fde5..7ae101a 100644

lib/librte_ether/rte_ethdev.c +0 -0
@@ -369,8 +369,12 @@ rte_eth_dev_uninit(struct rte_pci_device

*pci_dev)

lib/librte_ether/rte_ethdev.c rte_eth_dev_uninit(struct rte_pci_device *pci_dev)

Quoted 9 lines
lib/librte_ether/rte_ethdev.c +4 -1
 	/* 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));

lib/librte_ether/rte_ethdev.c rte_eth_dev_uninit(struct rte_pci_device *pci_dev) · line 380

Quoted 4 lines
lib/librte_ether/rte_ethdev.c +1 -0
+	}
 
 	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 dev->data->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.

Quoted 5 lines
Quoted 2 lines

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().

Quoted 4 lines

It really make sense to free memory in rte_ether level, but when close a port with out detached? just as stop --> close() --> quit(), the memory will not be released :)

In the above scenario lots of memory will not be released.

This is why the detach() and the underlying dev_uninit() functions were introduced.
The dev_uninit() functions currently call dev_close() which in turn calls dev_stop() which calls dev_clear_queues().
The dev_clear_queues() function does not release the queue_memory or the queue array memory. The queue memory is now released in the dev_uninit() and the queue array memory is released in the rte_eth_dev_uninit() function.

If the queue array memory is released in rte_eth_dev_close() then the release of the queue_memory will have to be moved to the dev_close() functions from the dev_uninit() functions. This will impact all the existing PMD hotplug patches. It will also change the existing dev_close() functionality.

My preference is to leave the existing dev_close() functions unchanged as far as possible and to do what needs to be done in the dev_uninit() functions.

We probably need the view of the maintainers as to whether this should be done in the close() or uninit() functions.

Regards,

Bernard.

#6 lore raw
Quoted 69 lines · Bernard
Quoted 69 lines

-----Original Message-----
From: Qiu, Michael
Sent: Monday, June 29, 2015 4:22 PM
To: Iremonger, Bernard; [email protected]
Cc: Zhang, Helin; Ananyev, Konstantin; [email protected]; Stephen Hemminger
Subject: Re: [PATCH v2] librte_ether: release memory in uninit function.

Quoted 47 lines · Bernard
Quoted 47 lines

-----Original Message-----
From: Qiu, Michael
Sent: Monday, June 29, 2015 9:55 AM
To: Iremonger, Bernard; [email protected]
Cc: Zhang, Helin; Ananyev, Konstantin; [email protected]; Stephen Hemminger
Subject: Re: [PATCH v2] librte_ether: release memory in uninit function.

lib/librte_ether/rte_ethdev.c rte_eth_dev_uninit(struct rte_pci_device

Quoted 13 lines · Bernard

Changes in v2:
do not free mac_addrs and hash_mac_addrs here.

---
 lib/librte_ether/rte_ethdev.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
(quoted diff) +0 -0

b/lib/librte_ether/rte_ethdev.c index e13fde5..7ae101a 100644

lib/librte_ether/rte_ethdev.c +0 -0
@@ -369,8 +369,12 @@ rte_eth_dev_uninit(struct rte_pci_device

*pci_dev)

lib/librte_ether/rte_ethdev.c rte_eth_dev_uninit(struct rte_pci_device *pci_dev)

Quoted 9 lines
lib/librte_ether/rte_ethdev.c +4 -1
 	/* 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));

lib/librte_ether/rte_ethdev.c rte_eth_dev_uninit(struct rte_pci_device *pci_dev) · line 380

Quoted 4 lines
lib/librte_ether/rte_ethdev.c +1 -0
+	}
 
 	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 dev->data->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.

Quoted 5 lines
Quoted 2 lines

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().

Quoted 7 lines
Quoted 4 lines

It really make sense to free memory in rte_ether level, but when close a port with out detached? just as stop --> close() --> quit(), the memory will not be released :)

In the above scenario lots of memory will not be released.

This is why the detach() and the underlying dev_uninit() functions were introduced.

First detach is only for hotplug, for *users do not use hotplug*, that scenario is the right action. So "lots of memory will not be released" is issue need be fixed, actually, in fm10k driver, lots of memory has been released.

Quoted 1 line

The dev_uninit() functions currently call dev_close() which in turn calls dev_stop() which calls dev_clear_queues().

Users do hotplug then must call stop() --> close() --> dev_uninit(), it works fine. But do you think it make sense to release memory when close() it?

Quoted 1 line

The dev_clear_queues() function does not release the queue_memory or the queue array memory. The queue memory is now released in the dev_uninit() and the queue array memory is released in the rte_eth_dev_uninit() function.

That's your implementation, make sure not all users will detach a device, but the right action must include close(), do you agree?

Quoted 2 lines

If the queue array memory is released in rte_eth_dev_close() then the release of the queue_memory will have to be moved to the dev_close() functions from the dev_uninit() functions. This will impact all the existing PMD hotplug patches. It will also change the existing dev_close() functionality.

Why impact?? Actually it works fine with fm10k driver. What I concern is *when user do not use hotplug*, it will lead lots of memory not released, that unacceptable, to move release action to
rte_eth_dev_close() is just a suggestion by me, I think *the solution
should cover both scenario*, am I right?

Quoted 14 lines

My preference is to leave the existing dev_close() functions unchanged as far as possible and to do what needs to be done in the dev_uninit() functions.

We probably need the view of the maintainers as to whether this should be done in the close() or uninit() functions.

Regards,

Bernard.

#7 lore raw

Hi, all

As we has gap on the memory release action to be done in which step, I appreciate all your comments on this patch.

Currently, the correct quit sequence for testpmd is stop() ---> port_stop() --> port_close() --> quit(). This will lead lots of memory not released by default, like queues.

We have 3 potential proposals(normal case means without hotplug):

1. Those memory release in close() other left in uninit() This will work fine for both hotplug case and normal case.

2. leave close() just as the same before, all be done in uninit() This will works fine for hotplug, for normal case maybe has
issue(memory not released?).

3. Combine close() and uninit(), only one will be left. This will work fine for both hotplug case and normal case. But it
may change a lot, such as logic.

4. other.

For more details, you could go though this thread.

Thanks,
Michael

Quoted 112 lines · Michael
Quoted 68 lines · Bernard
Quoted 68 lines

-----Original Message-----
From: Qiu, Michael
Sent: Monday, June 29, 2015 4:22 PM
To: Iremonger, Bernard; [email protected]
Cc: Zhang, Helin; Ananyev, Konstantin; [email protected]; Stephen Hemminger
Subject: Re: [PATCH v2] librte_ether: release memory in uninit function.

Quoted 47 lines · Bernard
Quoted 47 lines

-----Original Message-----
From: Qiu, Michael
Sent: Monday, June 29, 2015 9:55 AM
To: Iremonger, Bernard; [email protected]
Cc: Zhang, Helin; Ananyev, Konstantin; [email protected]; Stephen Hemminger
Subject: Re: [PATCH v2] librte_ether: release memory in uninit function.

lib/librte_ether/rte_ethdev.c rte_eth_dev_uninit(struct rte_pci_device

Quoted 13 lines · Bernard

Changes in v2:
do not free mac_addrs and hash_mac_addrs here.

---
 lib/librte_ether/rte_ethdev.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
(quoted diff) +0 -0

b/lib/librte_ether/rte_ethdev.c index e13fde5..7ae101a 100644

lib/librte_ether/rte_ethdev.c +0 -0
@@ -369,8 +369,12 @@ rte_eth_dev_uninit(struct rte_pci_device

*pci_dev)

lib/librte_ether/rte_ethdev.c rte_eth_dev_uninit(struct rte_pci_device *pci_dev)

Quoted 9 lines
lib/librte_ether/rte_ethdev.c +4 -1
 	/* 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));

lib/librte_ether/rte_ethdev.c rte_eth_dev_uninit(struct rte_pci_device *pci_dev) · line 380

Quoted 4 lines
lib/librte_ether/rte_ethdev.c +1 -0
+	}
 
 	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 dev->data->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.

Quoted 5 lines
Quoted 2 lines

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().

Quoted 7 lines
Quoted 4 lines

It really make sense to free memory in rte_ether level, but when close a port with out detached? just as stop --> close() --> quit(), the memory will not be released :)

In the above scenario lots of memory will not be released.

This is why the detach() and the underlying dev_uninit() functions were introduced.

First detach is only for hotplug, for *users do not use hotplug*, that scenario is the right action. So "lots of memory will not be released" is issue need be fixed, actually, in fm10k driver, lots of memory has been released.

Quoted 1 line

The dev_uninit() functions currently call dev_close() which in turn calls dev_stop() which calls dev_clear_queues().

Users do hotplug then must call stop() --> close() --> dev_uninit(), it works fine. But do you think it make sense to release memory when close() it?

Quoted 1 line

The dev_clear_queues() function does not release the queue_memory or the queue array memory. The queue memory is now released in the dev_uninit() and the queue array memory is released in the rte_eth_dev_uninit() function.

That's your implementation, make sure not all users will detach a device, but the right action must include close(), do you agree?

Quoted 1 line

If the queue array memory is released in rte_eth_dev_close() then the release of the queue_memory will have to be moved to the dev_close() functions from the dev_uninit() functions. This will impact all the existing PMD hotplug patches. It will also change the existing dev_close() functionality.

Why impact?? Actually it works fine with fm10k driver. What I concern is *when user do not use hotplug*, it will lead lots of memory not released, that unacceptable, to move release action to
rte_eth_dev_close() is just a suggestion by me, I think *the solution
should cover both scenario*, am I right?

Quoted 13 lines

My preference is to leave the existing dev_close() functions unchanged as far as possible and to do what needs to be done in the dev_uninit() functions.

We probably need the view of the maintainers as to whether this should be done in the close() or uninit() functions.

Regards,

Bernard.

#8 lore raw
Quoted 5 lines · Michael

Hi, all

As we has gap on the memory release action to be done in which step, I appreciate all your comments on this patch.

Quoted 8 lines

Currently, the correct quit sequence for testpmd is stop() ---> port_stop() --> port_close() --> quit(). This will lead lots of memory not released by default, like queues.

We have 3 potential proposals(normal case means without hotplug):

1. Those memory release in close() other left in uninit() This will work fine for both hotplug case and normal case.

+1

I assume that once close() is called, we cannot start the port again without hotplugging.
This is my premise.

It might be good that we move finalization code to close() as much as possible, because of followings.
1. Anyway, once close() is called, we cannot start the port again. So it should be ok to free resources in close().
2. Non-hotplugging applications can release resources if we implement finalization code to close().

Also I guess Stephen's suggestion is important to keep code clean. It may be good that 'dev->data->rx/tx_queues[queue_id]' are freed in rx/tx_queue_release() of each PMD, and rx/tx_queue_release() will be called by rte_eth_dev_close(). Also 'dev->data->rx/tx_queues[]' should be freed in ethdev.c.

Quoted 3 lines

3. Combine close() and uninit(), only one will be left. This will work fine for both hotplug case and normal case. But it
may change a lot, such as logic.

I guess this will be second option. But I agree we need to change a lot. Also after enabling hotplug by default, when someone only wants to close the port, it will be impossible.

Regards,
Tetsuya

#9 lore raw
Quoted 10 lines

-----Original Message-----
From: Tetsuya Mukawa [mailto:[email protected]]
Sent: Tuesday, July 7, 2015 4:38 AM
To: [email protected]
Cc: Qiu, Michael; Iremonger, Bernard; [email protected]; Ananyev, Konstantin; Stephen Hemminger; Zhang, Helin; Chen, Jing D; Neil Horman
Subject: Re: [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit function.

Quoted 9 lines
Quoted 8 lines · Michael

Hi, all

As we has gap on the memory release action to be done in which step, I appreciate all your comments on this patch.

Currently, the correct quit sequence for testpmd is stop() ---> port_stop() --> port_close() --> quit(). This will lead lots of memory not released by default, like queues.

There is also the scenario (outside of testpmd) where an application can call rte_eth_dev_close() or rte_eth_dev_detach() which calls rte_eth_dev_uninit() directly from an application. In these cases the memory allocated in the EAL layer should be released in both rte_eth_dev_close() and rte_eth_dev_detach().
This patch is intended to address the rte_eth_dev_detach() case only (hotplug case).
Perhaps there should be a separate patch to address the rte_eth_dev_close() case.

Regards,

Bernard.

Quoted 35 lines
Quoted 5 lines

We have 3 potential proposals(normal case means without hotplug):

1. Those memory release in close() other left in uninit() This will work fine for both hotplug case and normal case.

+1

I assume that once close() is called, we cannot start the port again without hotplugging.
This is my premise.

It might be good that we move finalization code to close() as much as possible, because of followings.
1. Anyway, once close() is called, we cannot start the port again. So it should be ok to free resources in close().
2. Non-hotplugging applications can release resources if we implement finalization code to close().

Also I guess Stephen's suggestion is important to keep code clean. It may be good that 'dev->data->rx/tx_queues[queue_id]' are freed in rx/tx_queue_release() of each PMD, and rx/tx_queue_release() will be called by rte_eth_dev_close(). Also 'dev->data->rx/tx_queues[]' should be freed in ethdev.c.

Quoted 3 lines

3. Combine close() and uninit(), only one will be left. This will work fine for both hotplug case and normal case. But it
may change a lot, such as logic.

I guess this will be second option. But I agree we need to change a lot. Also after enabling hotplug by default, when someone only wants to close the port, it will be impossible.

Regards,
Tetsuya

#10 lore raw
Quoted 13 lines · Bernard
Quoted 13 lines

-----Original Message-----
From: Tetsuya Mukawa [mailto:[email protected]]
Sent: Tuesday, July 7, 2015 4:38 AM
To: [email protected]
Cc: Qiu, Michael; Iremonger, Bernard; [email protected]; Ananyev, Konstantin; Stephen Hemminger; Zhang, Helin; Chen, Jing D; Neil Horman
Subject: Re: [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit function.

Quoted 2 lines · Michael

Hi, all

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

As we has gap on the memory release action to be done in which step, I appreciate all your comments on this patch.

Currently, the correct quit sequence for testpmd is stop() ---> port_stop() --> port_close() --> quit(). This will lead lots of memory not released by default, like queues.

There is also the scenario (outside of testpmd) where an application can call rte_eth_dev_close() or rte_eth_dev_detach() which calls rte_eth_dev_uninit() directly from an application. In these cases the memory allocated in the EAL layer should be released in both rte_eth_dev_close() and rte_eth_dev_detach().

Hi Bernard,

All DPDK applications that uses hotpluggingmust call rte_eth_dev_stop() and rte_eth_dev_close()APIs before detaching ports.
(This is described in DPDK documentation)
Could we ignore applications that only calls rte_eth_dev_detach()?

Quoted 2 lines

This patch is intended to address the rte_eth_dev_detach() case only (hotplug case). Perhaps there should be a separate patch to address the rte_eth_dev_close() case.

We all needs to have consensus about how to implement finalization code in close() and uninit().
Probably one of options will be implementing finalization code in close() as much as possible.

Tetsuya,

Quoted 36 lines

Regards,

Bernard.

Quoted 32 lines
Quoted 4 lines

We have 3 potential proposals(normal case means without hotplug):

1. Those memory release in close() other left in uninit() This will work fine for both hotplug case and normal case.

+1

I assume that once close() is called, we cannot start the port again without hotplugging.
This is my premise.

It might be good that we move finalization code to close() as much as possible, because of followings.
1. Anyway, once close() is called, we cannot start the port again. So it should be ok to free resources in close().
2. Non-hotplugging applications can release resources if we implement finalization code to close().

Also I guess Stephen's suggestion is important to keep code clean. It may be good that 'dev->data->rx/tx_queues[queue_id]' are freed in rx/tx_queue_release() of each PMD, and rx/tx_queue_release() will be called by rte_eth_dev_close(). Also 'dev->data->rx/tx_queues[]' should be freed in ethdev.c.

Quoted 3 lines

3. Combine close() and uninit(), only one will be left. This will work fine for both hotplug case and normal case. But it
may change a lot, such as logic.

I guess this will be second option. But I agree we need to change a lot. Also after enabling hotplug by default, when someone only wants to close the port, it will be impossible.

Regards,
Tetsuya

#11 lore raw
Quoted 47 lines

-----Original Message-----
From: Tetsuya Mukawa [mailto:[email protected]]
Sent: Wednesday, July 8, 2015 4:48 AM
To: Iremonger, Bernard; [email protected]
Cc: Qiu, Michael; [email protected]; Ananyev, Konstantin; Stephen Hemminger; Zhang, Helin; Chen, Jing D; Neil Horman
Subject: Re: [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit function.

Quoted 13 lines · Bernard
Quoted 13 lines

-----Original Message-----
From: Tetsuya Mukawa [mailto:[email protected]]
Sent: Tuesday, July 7, 2015 4:38 AM
To: [email protected]
Cc: Qiu, Michael; Iremonger, Bernard; [email protected]; Ananyev, Konstantin; Stephen Hemminger; Zhang, Helin; Chen, Jing D; Neil Horman
Subject: Re: [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit function.

Quoted 2 lines · Michael

Hi, all

Quoted 7 lines
Quoted 6 lines
Quoted 6 lines

As we has gap on the memory release action to be done in which step, I appreciate all your comments on this patch.

Currently, the correct quit sequence for testpmd is stop() ---> port_stop() --> port_close() --> quit(). This will lead lots of memory not released by default, like queues.

There is also the scenario (outside of testpmd) where an application can call

rte_eth_dev_close() or rte_eth_dev_detach() which calls rte_eth_dev_uninit() directly from an application.

Quoted 1 line

In these cases the memory allocated in the EAL layer should be released in

both rte_eth_dev_close() and rte_eth_dev_detach().

Hi Bernard,

All DPDK applications that uses hotpluggingmust call rte_eth_dev_stop() and rte_eth_dev_close()APIs before detaching ports.
(This is described in DPDK documentation) Could we ignore applications that only calls rte_eth_dev_detach()?

Quoted 1 line

This patch is intended to address the rte_eth_dev_detach() case only

(hotplug case).

Quoted 1 line

Perhaps there should be a separate patch to address the

Quoted 8 lines

rte_eth_dev_close() case.

We all needs to have consensus about how to implement finalization code in close() and uninit().
Probably one of options will be implementing finalization code in close() as much as possible.

Tetsuya,

Hi Tetsuya,
Testpmd enforces the dev_stop(), dev_close() and dev_detach() sequence. There is no reason why an application cannot call dev_detach() directly.

During internal review of PMD dev_uninit() functions it was decided to ensure that this sequence was adhered to by calling dev_close() which calls dev_stop() from the dev_uninit() function. In the PMD hotplug patches the following calling sequence is implemented:
dev_uninit() calls dev_close() calls dev_stop().
At present most of the finalization code is implemented in dev_close() and dev_stop().
The dev_uninit() functions implement what is left of the finalization code.

Regards,

Bernard.

Quoted 37 lines
Quoted 37 lines

Regards,

Bernard.

Quoted 32 lines
Quoted 4 lines

We have 3 potential proposals(normal case means without hotplug):

1. Those memory release in close() other left in uninit() This will work fine for both hotplug case and normal case.

+1

I assume that once close() is called, we cannot start the port again without hotplugging.
This is my premise.

It might be good that we move finalization code to close() as much as possible, because of followings.
1. Anyway, once close() is called, we cannot start the port again. So it should be ok to free resources in close().
2. Non-hotplugging applications can release resources if we implement finalization code to close().

Also I guess Stephen's suggestion is important to keep code clean. It may be good that 'dev->data->rx/tx_queues[queue_id]' are freed in rx/tx_queue_release() of each PMD, and rx/tx_queue_release() will be called by rte_eth_dev_close(). Also 'dev->data->rx/tx_queues[]' should be freed in ethdev.c.

Quoted 3 lines

3. Combine close() and uninit(), only one will be left. This will work fine for both hotplug case and normal case. But
it may change a lot, such as logic.

I guess this will be second option. But I agree we need to change a lot. Also after enabling hotplug by default, when someone only wants to close the port, it will be impossible.

Regards,
Tetsuya

#12 lore raw

2015-07-08 09:49, Iremonger, Bernard:

Quoted 41 lines

From: Tetsuya Mukawa [mailto:[email protected]]

Quoted 27 lines · Bernard
Quoted 11 lines

From: Tetsuya Mukawa [mailto:[email protected]]

Quoted 9 lines · Michael
Quoted 8 lines

Hi, all

As we has gap on the memory release action to be done in which step, I appreciate all your comments on this patch.

Currently, the correct quit sequence for testpmd is stop() ---> port_stop() --> port_close() --> quit(). This will lead lots of memory not released by default, like queues.

There is also the scenario (outside of testpmd) where an application can call

rte_eth_dev_close() or rte_eth_dev_detach() which calls rte_eth_dev_uninit() directly from an application.

Quoted 1 line

In these cases the memory allocated in the EAL layer should be released in

both rte_eth_dev_close() and rte_eth_dev_detach().

Hi Bernard,

All DPDK applications that uses hotpluggingmust call rte_eth_dev_stop() and rte_eth_dev_close()APIs before detaching ports.
(This is described in DPDK documentation) Could we ignore applications that only calls rte_eth_dev_detach()?

Quoted 1 line

This patch is intended to address the rte_eth_dev_detach() case only

(hotplug case).

Quoted 1 line

Perhaps there should be a separate patch to address the

Quoted 8 lines

rte_eth_dev_close() case.

We all needs to have consensus about how to implement finalization code in close() and uninit().
Probably one of options will be implementing finalization code in close() as much as possible.

Tetsuya,

Hi Tetsuya,
Testpmd enforces the dev_stop(), dev_close() and dev_detach() sequence. There is no reason why an application cannot call dev_detach() directly.

Quoted 5 lines

During internal review of PMD dev_uninit() functions it was decided to ensure that this sequence was adhered to by calling dev_close() which calls dev_stop() from the dev_uninit() function. In the PMD hotplug patches the following calling sequence is implemented:
dev_uninit() calls dev_close() calls dev_stop().
At present most of the finalization code is implemented in dev_close() and dev_stop().
The dev_uninit() functions implement what is left of the finalization code.

It appears that the API is not defined.
None of these assumptions is written in rte_ethdev.h.
Please continue the discussion by submitting a patch fixing the doxygen comments of these functions.
How an application developper is supposed to use these functions without having a clear explanation of their roles in doxygen?

#13 lore raw
Quoted 46 lines · Thomas Monjalon

2015-07-08 09:49, Iremonger, Bernard:

Quoted 40 lines

From: Tetsuya Mukawa [mailto:[email protected]]

Quoted 27 lines · Bernard
Quoted 11 lines

From: Tetsuya Mukawa [mailto:[email protected]]

Quoted 9 lines · Michael
Quoted 8 lines

Hi, all

As we has gap on the memory release action to be done in which step, I appreciate all your comments on this patch.

Currently, the correct quit sequence for testpmd is stop() ---> port_stop() --> port_close() --> quit(). This will lead lots of memory not released by default, like queues.

There is also the scenario (outside of testpmd) where an application can call

rte_eth_dev_close() or rte_eth_dev_detach() which calls rte_eth_dev_uninit() directly from an application.

Quoted 1 line

In these cases the memory allocated in the EAL layer should be released in

both rte_eth_dev_close() and rte_eth_dev_detach().

Hi Bernard,

All DPDK applications that uses hotpluggingmust call rte_eth_dev_stop() and rte_eth_dev_close()APIs before detaching ports.
(This is described in DPDK documentation) Could we ignore applications that only calls rte_eth_dev_detach()?

Quoted 1 line

This patch is intended to address the rte_eth_dev_detach() case only

(hotplug case).

Quoted 1 line

Perhaps there should be a separate patch to address the

Quoted 8 lines

rte_eth_dev_close() case.

We all needs to have consensus about how to implement finalization code in close() and uninit().
Probably one of options will be implementing finalization code in close() as much as possible.

Tetsuya,

Hi Tetsuya,
Testpmd enforces the dev_stop(), dev_close() and dev_detach() sequence. There is no reason why an application cannot call dev_detach() directly.

Quoted 5 lines

During internal review of PMD dev_uninit() functions it was decided to ensure that this sequence was adhered to by calling dev_close() which calls dev_stop() from the dev_uninit() function. In the PMD hotplug patches the following calling sequence is implemented:
dev_uninit() calls dev_close() calls dev_stop().
At present most of the finalization code is implemented in dev_close() and dev_stop().
The dev_uninit() functions implement what is left of the finalization code.

Quoted 6 lines

It appears that the API is not defined.
None of these assumptions is written in rte_ethdev.h.
Please continue the discussion by submitting a patch fixing the doxygen comments of these functions.
How an application developper is supposed to use these functions without having a clear explanation of their roles in doxygen?

Yes, this assumption is only written in DPDK user's guide. So we should add description to doxygen. I will take care of it.

Anyway, I will add description to doxygen like user's guide.
(A) stop() and close() must be called before detach().
(B) close() releases all most all resources.
Probably Bernard and Michael patches are fit for above restrictions.

It may be good to add below in DPDK-2.2, though supporting below feature will be more user friendly.
(C) Even if stop() and close() are not called, detach() will take care
of it.

Probably, it's not so much time left before releasing DPDK-2.1. So how about keeping current restriction written in user's guide, then add a new feature in DPDK-2.2.

Regards,
Tetsuya

#14 lore raw
Quoted 6 lines · Tetsuya Mukawa
Quoted 5 lines · Thomas Monjalon

2015-07-08 09:49, Iremonger, Bernard:

Quoted 4 lines

From: Tetsuya Mukawa [mailto:[email protected]]

Quoted 3 lines · Bernard
Quoted 2 lines

From: Tetsuya Mukawa [mailto:[email protected]]

Quoted 1 line · Michael
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Hi, all

As we has gap on the memory release action to be done in which step, I appreciate all your comments on this patch.

Currently, the correct quit sequence for testpmd is stop() ---> port_stop() --> port_close() --> quit(). This will lead lots of memory not released by default, like queues.

[.../...]

Quoted 14 lines
Quoted 6 lines

It appears that the API is not defined.
None of these assumptions is written in rte_ethdev.h.
Please continue the discussion by submitting a patch fixing the doxygen comments of these functions.
How an application developper is supposed to use these functions without having a clear explanation of their roles in doxygen?

Yes, this assumption is only written in DPDK user's guide. So we should add description to doxygen. I will take care of it.

Anyway, I will add description to doxygen like user's guide.
(A) stop() and close() must be called before detach().
(B) close() releases all most all resources.
Probably Bernard and Michael patches are fit for above restrictions.

Quoted 8 lines

It may be good to add below in DPDK-2.2, though supporting below feature will be more user friendly.
(C) Even if stop() and close() are not called, detach() will take care
of it.

Probably, it's not so much time left before releasing DPDK-2.1. So how about keeping current restriction written in user's guide, then add a new feature in DPDK-2.2.

Yes, agree.

Thanks,
Michael

Quoted 3 lines

Regards,
Tetsuya

#15 lore raw

PATCH 1/1 doc: Fix doxygen comments of rte_eth_dev_close() and rte_eth_dev_detach()

In reply to Iremonger, Bernard

The patch fixes doxygen comments of below functions.
- rte_eth_dev_close()
Add description about what kind of resources will be freed.
- rte_eth_dev_detach()
Add description about when the function can be called.

---
 lib/librte_ether/rte_ethdev.h | 4 ++++
 1 file changed, 4 insertions(+)
lib/librte_ether/rte_ethdev.h +4 -0
index 438d59a..3148416 100644
@@ -1633,6 +1633,8 @@ int rte_eth_dev_attach(const char *devargs, uint8_t *port_id);
 
 /**
  * Detach a Ethernet device specified by port identifier.
+ * This function must be called when the device is in the
+ * closed state.
  *
  * @param port_id
  *   The port identifier of the device to detach.
@@ -1987,6 +1989,8 @@ extern int rte_eth_dev_set_link_down(uint8_t port_id);
 
 /**
  * Close an Ethernet device. The device cannot be restarted!
+ * The function frees all resources except for needed by the
+ * closed state. To free these resources, call rte_eth_dev_detach().
  *
  * @param port_id
  *   The port identifier of the Ethernet device.
Signature · 1 line
2.1.4
#16 lore raw

Re: [PATCH] doc: Fix doxygen comments of rte_eth_dev_close() and rte_eth_dev_detach()

2015-07-09 14:46, Tetsuya Mukawa:

Quoted 6 lines

The patch fixes doxygen comments of below functions.
- rte_eth_dev_close()
Add description about what kind of resources will be freed.
- rte_eth_dev_detach()
Add description about when the function can be called.

Quoted 6 lines

/**
* Close an Ethernet device. The device cannot be restarted!
+ * The function frees all resources except for needed by the
+ * closed state. To free these resources, call rte_eth_dev_detach().

Maybe we should tell that stop must be called before close:
"Close a stopped Ethernet device."

#17 lore raw

Re: [PATCH] doc: Fix doxygen comments of rte_eth_dev_close() and rte_eth_dev_detach()

Quoted 7 lines · Thomas Monjalon

2015-07-09 14:46, Tetsuya Mukawa:

Quoted 6 lines

The patch fixes doxygen comments of below functions.
- rte_eth_dev_close()
Add description about what kind of resources will be freed.
- rte_eth_dev_detach()
Add description about when the function can be called.

Quoted 7 lines
Quoted 5 lines

/**
* Close an Ethernet device. The device cannot be restarted!
+ * The function frees all resources except for needed by the
+ * closed state. To free these resources, call rte_eth_dev_detach().

Maybe we should tell that stop must be called before close:
"Close a stopped Ethernet device."

Sure, I will add it and submit again soon.

Tetsuya

#18 lore raw

PATCH v2 1/1 doc: Fix doxygen comments of rte_eth_dev_close() and rte_eth_dev_detach()

In reply to Iremonger, Bernard

The patch fixes doxygen comments of below functions.
- rte_eth_dev_close()
Add description about when the function can be called and also about what kind of resources will be freed.
- rte_eth_dev_detach()
Add description about when the function can be called.

---
 lib/librte_ether/rte_ethdev.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
lib/librte_ether/rte_ethdev.h +5 -1
index 438d59a..f4e3d42 100644
@@ -1633,6 +1633,8 @@ int rte_eth_dev_attach(const char *devargs, uint8_t *port_id);
 
 /**
  * Detach a Ethernet device specified by port identifier.
+ * This function must be called when the device is in the
+ * closed state.
  *
  * @param port_id
  *   The port identifier of the device to detach.
@@ -1986,7 +1988,9 @@ extern int rte_eth_dev_set_link_up(uint8_t port_id);
 extern int rte_eth_dev_set_link_down(uint8_t port_id);
 
 /**
- * Close an Ethernet device. The device cannot be restarted!
+ * Close a stopped Ethernet device. The device cannot be restarted!
+ * The function frees all resources except for needed by the
+ * closed state. To free these resources, call rte_eth_dev_detach().
  *
  * @param port_id
  *   The port identifier of the Ethernet device.
Signature · 1 line
2.1.4
#19 lore raw

Re: [PATCH v2] doc: Fix doxygen comments of rte_eth_dev_close() and rte_eth_dev_detach()

2015-07-09 17:19, Tetsuya Mukawa:

Quoted 8 lines

The patch fixes doxygen comments of below functions.
- rte_eth_dev_close()
Add description about when the function can be called and also about what kind of resources will be freed.
- rte_eth_dev_detach()
Add description about when the function can be called.

Applied, thanks