ethdev: fix dev close in secondary process
PATCH 1/1 ethdev: fix dev close in secondary process
From: Min Hu <[email protected]>
Shared memory like port private resources should only be reserved by primary process. Secondary process should not start dev, and the state of 'dev_started' is only meaningful to primary process. While secondary process need to close dev to release process private resources.
This patch limited the scope of 'dev_started'.
--- lib/ethdev/rte_ethdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/ethdev/rte_ethdev.c +2 -1
@@ -1574,7 +1574,8 @@ rte_eth_dev_close(uint16_t port_id)RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); dev = &rte_eth_devices[port_id]; -if (dev->data->dev_started) { +if (rte_eal_process_type () ==RTE_PROC_PRIMARY && + dev->data->dev_started) {RTE_ETHDEV_LOG (ERR ,"Cannot close started device (port %u)\n" , port_id);return -EINVAL ;
Signature · 1 line
2.33.0
Quoted 9 lines · Min Hu (Connor)
From: Min Hu <[email protected]>
Shared memory like port private resources should only be reserved by primary process. Secondary process should not start dev, and the state of '
dev_started' is only meaningful to primary process. While secondary process need to close dev to release process private resources.This patch limited the scope of '
dev_started'.
I agree with the patch since secondary process should not be obliged to wait for device stop before closing ethdev. In any case closing ethdev in secondary process should do nothing harmful to the primary process.
However, the patch description pretends to limit dev_started scope for secondary processes in general. It is wrong since secondary processes need the information and that's why it is stored in shared memory.
Quoted 23 lines
Fixes febc855b358e ("ethdev: forbid closing started device")Signed-off-by Min Hu <[email protected]>--- lib/ethdev/rte_ethdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)lib/ethdev/rte_ethdev.c +2
-1@@ -1574,7 +1574,8 @@ rte_eth_dev_close(uint16_t port_id)RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); dev = &rte_eth_devices[port_id]; -if (dev->data->dev_started) { +if (rte_eal_process_type () ==RTE_PROC_PRIMARY && + dev->data->dev_started) {RTE_ETHDEV_LOG (ERR ,"Cannot close started device (port %u)\n" , port_id);return -EINVAL ;
Quoted 16 lines · On Tue, 31 May 2022 20:08:55 +0300 Andrew Rybchenko…
Quoted 9 lines · Min Hu (Connor)
From: Min Hu <[email protected]>
Shared memory like port private resources should only be reserved by primary process. Secondary process should not start dev, and the state of '
dev_started' is only meaningful to primary process. While secondary process need to close dev to release process private resources.This patch limited the scope of '
dev_started'.I agree with the patch since secondary process should not be obliged to wait for device stop before closing ethdev. In any case closing ethdev in secondary process should do nothing harmful to the primary process.
Quoted 11 lines
However, the patch description pretends to limit
dev_startedscope for secondary processes in general. It is wrong since secondary processes need the information and that's why it is stored in shared memory.Quoted 6 lines
Fixes febc855b358e ("ethdev: forbid closing started device")Signed-off-by Min Hu <[email protected]>---
Also secondary processes are used differently by different application models.
Some applications only use secondary process for information. But some have a primary process that only inits DPDK and do everything in a secondary process.
Hi,Andrew, Stephen ,
I fixed the comment, thanks for your comment.
Quoted 38 lines · Stephen Hemminger
Quoted 16 lines · On Tue, 31 May 2022 20:08:55 +0300 Andrew Rybchenko…
Quoted 9 lines · Min Hu (Connor)
From: Min Hu <[email protected]>
Shared memory like port private resources should only be reserved by primary process. Secondary process should not start dev, and the state of '
dev_started' is only meaningful to primary process. While secondary process need to close dev to release process private resources.This patch limited the scope of '
dev_started'.I agree with the patch since secondary process should not be obliged to wait for device stop before closing ethdev. In any case closing ethdev in secondary process should do nothing harmful to the primary process.
Quoted 11 lines
However, the patch description pretends to limit
dev_startedscope for secondary processes in general. It is wrong since secondary processes need the information and that's why it is stored in shared memory.Quoted 6 lines
Fixes febc855b358e ("ethdev: forbid closing started device")Signed-off-by Min Hu <[email protected]>---
Also secondary processes are used differently by different application models.
Some applications only use secondary process for information. But some have a primary process that only inits DPDK and do everything in a secondary process.
.
PATCH v2 1/1 ethdev: fix dev close in secondary process
In reply to Min Hu (Connor)From: Min Hu <[email protected]>
Secondary process need to close dev to release process private resources. But secondary process should not be obliged to wait for device stop before closing ethdev.
This patch fixed it.
---
v2:
* fixed comment.
--- lib/ethdev/rte_ethdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/ethdev/rte_ethdev.c +2 -1
@@ -1574,7 +1574,8 @@ rte_eth_dev_close(uint16_t port_id)RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); dev = &rte_eth_devices[port_id]; -if (dev->data->dev_started) { +if (rte_eal_process_type () ==RTE_PROC_PRIMARY && + dev->data->dev_started) {RTE_ETHDEV_LOG (ERR ,"Cannot close started device (port %u)\n" , port_id);return -EINVAL ;
Signature · 1 line
2.33.0
Quoted 25 lines · Min Hu (Connor)
From: Min Hu <[email protected]>
Secondary process need to close dev to release process private resources. But secondary process should not be obliged to wait for device stop before closing ethdev.
This patch fixed it.
Fixes febc855b358e ("ethdev: forbid closing started device")Signed-off-by Min Hu <[email protected]>---
v2:
* fixed comment.--- lib/ethdev/rte_ethdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)lib/ethdev/rte_ethdev.c +0
-0
lib/ethdev/rte_ethdev.c rte_eth_dev_close(uint16_t port_id) · line 1577
Quoted 4 lines
lib/ethdev/rte_ethdev.c +0
-1@@ -1574,7 +1574,8 @@ rte_eth_dev_close(uint16_t port_id)RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); dev = &rte_eth_devices[port_id]; -if (dev->data->dev_started) {
It will be good to add the comment as a part of the code as well. That way someone in future won't have to look at the commit log to understand the behavior.
Quoted 8 lines
lib/ethdev/rte_ethdev.c +2
-1+if (rte_eal_process_type () ==RTE_PROC_PRIMARY && + dev->data->dev_started) {RTE_ETHDEV_LOG (ERR ,"Cannot close started device (port %u)\n" , port_id);return -EINVAL ; --2.33.0
Hi, Ajit
v3 has been sent, thanks
Quoted 42 lines · Ajit Khaparde
Quoted 25 lines · Min Hu (Connor)
From: Min Hu <[email protected]>
Secondary process need to close dev to release process private resources. But secondary process should not be obliged to wait for device stop before closing ethdev.
This patch fixed it.
Fixes febc855b358e ("ethdev: forbid closing started device")Signed-off-by Min Hu <[email protected]>---
v2:
* fixed comment.--- lib/ethdev/rte_ethdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)lib/ethdev/rte_ethdev.c +0
-0lib/ethdev/rte_ethdev.c rte_eth_dev_close(uint16_t port_id) · line 1577
Quoted 4 lines
lib/ethdev/rte_ethdev.c +0
-1@@ -1574,7 +1574,8 @@ rte_eth_dev_close(uint16_t port_id)RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); dev = &rte_eth_devices[port_id]; -if (dev->data->dev_started) {It will be good to add the comment as a part of the code as well. That way someone in future won't have to look at the commit log to understand the behavior.
Quoted 8 lines
lib/ethdev/rte_ethdev.c +2
-1+if (rte_eal_process_type () ==RTE_PROC_PRIMARY && + dev->data->dev_started) {RTE_ETHDEV_LOG (ERR ,"Cannot close started device (port %u)\n" , port_id);return -EINVAL ; --2.33.0
Quoted 3 lines · Min Hu (Connor)
Hi, Ajit
v3 has been sent, thanks
Thanks
PATCH v3 1/1 ethdev: fix dev close in secondary process
In reply to Min Hu (Connor)From: Min Hu <[email protected]>
Secondary process need to close dev to release process private resources. But secondary process should not be obliged to wait for device stop before closing ethdev.
This patch fixed it.
---
v3:
* add comment in the code.
v2:
* fixed comment.
--- lib/ethdev/rte_ethdev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
lib/ethdev/rte_ethdev.c +7 -1
@@ -1574,7 +1574,13 @@ rte_eth_dev_close(uint16_t port_id)RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); dev = &rte_eth_devices[port_id]; -if (dev->data->dev_started) { +/* +* Secondary process need to close dev to release process private +* resources. But secondary process should not be obliged to wait +* for device stop before closing ethdev. +*/ +if (rte_eal_process_type () ==RTE_PROC_PRIMARY && + dev->data->dev_started) {RTE_ETHDEV_LOG (ERR ,"Cannot close started device (port %u)\n" , port_id);return -EINVAL ;
Signature · 1 line
2.33.0
Andrew Rybchenko
AppliedQuoted 6 lines · Min Hu (Connor)
From: Min Hu <[email protected]>
Secondary process need to close dev to release process private resources. But secondary process should not be obliged to wait for device stop before closing ethdev.
Quoted 6 lines
This patch fixed it.
Fixes febc855b358e ("ethdev: forbid closing started device")Signed-off-by Min Hu <[email protected]>
Applied to dpdk-next-net/main, thanks.