librte_ether: release memory in uninit function.
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
@@ -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
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 freemac_addrsandhash_mac_addrshere.Signed-off-by Bernard Iremonger <[email protected]>--- lib/librte_ether/rte_ethdev.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)lib/librte_ether/rte_ethdev.c +0
-1@@ -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
Quoted 16 lines · Bernard
Changes in v2:
do not freemac_addrsandhash_mac_addrshere.Signed-off-by Bernard Iremonger <[email protected]>--- lib/librte_ether/rte_ethdev.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)lib/librte_ether/rte_ethdev.c +0
-0@@ -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
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 freemac_addrsandhash_mac_addrshere.Signed-off-by Bernard Iremonger <[email protected]>--- lib/librte_ether/rte_ethdev.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)(quoted diff) +0
-0
b/lib/librte_ether/rte_ethdev.cindex e13fde5..7ae101a 100644lib/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_queuesyou should make sure dev->data->rx_queues[i] has been freed in PMDclose()function, So this two should be better done at the same time, ether inrte_eth_dev_close()or in PMDclose()function. For hotplug in fm10k, I put it in PMDclose()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.
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 freemac_addrsandhash_mac_addrshere.Signed-off-by Bernard Iremonger <[email protected]>--- lib/librte_ether/rte_ethdev.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)(quoted diff) +0
-0
b/lib/librte_ether/rte_ethdev.cindex e13fde5..7ae101a 100644lib/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_queuesyou should make sure dev->data->rx_queues[i] has been freed in PMDclose()function, So this two should be better done at the same time, ether inrte_eth_dev_close()or in PMDclose()function. For hotplug in fm10k, I put it in PMDclose()function.
Quoted 5 lines
Quoted 2 lines
Thanks,
MichaelHi Michael,
The consensus is that the
rx_queueandtx_queuememory should not be released in the PMD as it is not allocated by the PMD. The memory is allocated inrte_eth_dev_rx_queue_config()andrte_eth_dev_tx_queue_config(), which are both called fromrte_eth_dev_configure()which is called by the application (for exampletest_pmd). So it seems to make sense to free this memory inrte_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.
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 freemac_addrsandhash_mac_addrshere.Signed-off-by Bernard Iremonger <[email protected]>--- lib/librte_ether/rte_ethdev.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)(quoted diff) +0
-0
b/lib/librte_ether/rte_ethdev.cindex e13fde5..7ae101a 100644lib/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_queuesyou should make sure dev->data->rx_queues[i] has been freed in PMDclose()function, Sodev->data->this
two should be better done at the same time, ether inrte_eth_dev_close()or in PMDclose()function. For hotplug in fm10k, I put it in PMDclose()function.Quoted 5 lines
Quoted 2 lines
Thanks,
MichaelHi Michael,
The consensus is that the
rx_queueandtx_queuememory should not bereleased in the PMD as it is not allocated by the PMD. The memory is allocated in
rte_eth_dev_rx_queue_config()andrte_eth_dev_tx_queue_config(), which are both called fromrte_eth_dev_configure()which is called by the application (for exampletest_pmd). So it seems to make sense to free this memory inrte_eth_dev_uninit().
Quoted 4 lines
It really make sense to free memory in
rte_etherlevel, 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.
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 freemac_addrsandhash_mac_addrshere.Signed-off-by Bernard Iremonger <[email protected]>--- lib/librte_ether/rte_ethdev.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)(quoted diff) +0
-0
b/lib/librte_ether/rte_ethdev.cindex e13fde5..7ae101a 100644lib/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_queuesyou should make sure dev->data->rx_queues[i] has been freed in PMDclose()function, Sodev->data->this
two should be better done at the same time, ether inrte_eth_dev_close()or in PMDclose()function. For hotplug in fm10k, I put it in PMDclose()function.Quoted 5 lines
Quoted 2 lines
Thanks,
MichaelHi Michael,
The consensus is that the
rx_queueandtx_queuememory should not bereleased in the PMD as it is not allocated by the PMD. The memory is allocated in
rte_eth_dev_rx_queue_config()andrte_eth_dev_tx_queue_config(), which are both called fromrte_eth_dev_configure()which is called by the application (for exampletest_pmd). So it seems to make sense to free this memory inrte_eth_dev_uninit().
Quoted 7 lines
Quoted 4 lines
It really make sense to free memory in
rte_etherlevel, 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 underlyingdev_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 calldev_close()which in turn callsdev_stop()which callsdev_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 thequeue_memoryor the queue array memory. The queue memory is now released in thedev_uninit()and the queue array memory is released in therte_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 thequeue_memorywill have to be moved to thedev_close()functions from thedev_uninit()functions. This will impact all the existing PMD hotplug patches. It will also change the existingdev_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 torte_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 thedev_uninit()functions.We probably need the view of the maintainers as to whether this should be done in the
close()oruninit()functions.Regards,
Bernard.
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 freemac_addrsandhash_mac_addrshere.Signed-off-by Bernard Iremonger <[email protected]>--- lib/librte_ether/rte_ethdev.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)(quoted diff) +0
-0
b/lib/librte_ether/rte_ethdev.cindex e13fde5..7ae101a 100644lib/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_queuesyou should make sure dev->data->rx_queues[i] has been freed in PMDclose()function, Sodev->data->this
two should be better done at the same time, ether inrte_eth_dev_close()or in PMDclose()function. For hotplug in fm10k, I put it in PMDclose()function.Quoted 5 lines
Quoted 2 lines
Thanks,
MichaelHi Michael,
The consensus is that the
rx_queueandtx_queuememory should not bereleased in the PMD as it is not allocated by the PMD. The memory is allocated in
rte_eth_dev_rx_queue_config()andrte_eth_dev_tx_queue_config(), which are both called fromrte_eth_dev_configure()which is called by the application (for exampletest_pmd). So it seems to make sense to free this memory inrte_eth_dev_uninit().Quoted 7 lines
Quoted 4 lines
It really make sense to free memory in
rte_etherlevel, 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 underlyingdev_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 calldev_close()which in turn callsdev_stop()which callsdev_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 whenclose()it?Quoted 1 line
The
dev_clear_queues()function does not release thequeue_memoryor the queue array memory. The queue memory is now released in thedev_uninit()and the queue array memory is released in therte_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 thequeue_memorywill have to be moved to thedev_close()functions from thedev_uninit()functions. This will impact all the existing PMD hotplug patches. It will also change the existingdev_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 thedev_uninit()functions.We probably need the view of the maintainers as to whether this should be done in the
close()oruninit()functions.Regards,
Bernard.
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 inuninit()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()anduninit(), 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
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 inuninit()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, onceclose()is called, we cannot start the port again. So it should be ok to free resources inclose().
2. Non-hotplugging applications can release resources if we implement finalization code toclose().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 inethdev.c.Quoted 3 lines
3. Combine
close()anduninit(), 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
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()orrte_eth_dev_detach()which callsrte_eth_dev_uninit()directly from an application. In these cases the memory allocated in the EAL layer should be released in bothrte_eth_dev_close()andrte_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 therte_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 inuninit()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, onceclose()is called, we cannot start the port again. So it should be ok to free resources inclose().
2. Non-hotplugging applications can release resources if we implement finalization code toclose().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 inethdev.c.Quoted 3 lines
3. Combine
close()anduninit(), 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
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()orrte_eth_dev_detach()which callsrte_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()andrte_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 callsrte_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()anduninit().
Probably one of options will be implementing finalization code inclose()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 inuninit()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, onceclose()is called, we cannot start the port again. So it should be ok to free resources inclose().
2. Non-hotplugging applications can release resources if we implement finalization code toclose().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 inethdev.c.Quoted 3 lines
3. Combine
close()anduninit(), 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
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()orrte_eth_dev_detach()which callsrte_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()andrte_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 callsrte_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()anduninit().
Probably one of options will be implementing finalization code inclose()as much as possible.Tetsuya,
Hi Tetsuya,
Testpmd enforces thedev_stop(),dev_close()anddev_detach()sequence. There is no reason why an application cannot calldev_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 callingdev_close()which callsdev_stop()from thedev_uninit()function. In the PMD hotplug patches the following calling sequence is implemented:dev_uninit()callsdev_close()callsdev_stop().
At present most of the finalization code is implemented indev_close()anddev_stop().
Thedev_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?
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()orrte_eth_dev_detach()which callsrte_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()andrte_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 callsrte_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()anduninit().
Probably one of options will be implementing finalization code inclose()as much as possible.Tetsuya,
Hi Tetsuya,
Testpmd enforces thedev_stop(),dev_close()anddev_detach()sequence. There is no reason why an application cannot calldev_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 callingdev_close()which callsdev_stop()from thedev_uninit()function. In the PMD hotplug patches the following calling sequence is implemented:dev_uninit()callsdev_close()callsdev_stop().
At present most of the finalization code is implemented indev_close()anddev_stop().
Thedev_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 inrte_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
PATCH 1/1 doc: Fix doxygen comments of rte_eth_dev_close() and rte_eth_dev_detach()
In reply to Iremonger, BernardThe 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
@@ -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
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
Signed-off-by Tetsuya Mukawa <[email protected]>/**
* 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, callrte_eth_dev_detach().
Maybe we should tell that stop must be called before close:
"Close a stopped Ethernet device."
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
Signed-off-by Tetsuya Mukawa <[email protected]>/**
* 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, callrte_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
PATCH v2 1/1 doc: Fix doxygen comments of rte_eth_dev_close() and rte_eth_dev_detach()
In reply to Iremonger, BernardThe 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
@@ -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
Thomas Monjalon
AppliedRe: [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.Signed-off-by Tetsuya Mukawa <[email protected]>
Applied, thanks
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 inrte_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()andclose()must be called beforedetach().
(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 ifstop()andclose()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