DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] net/virtio: unregister virtio user memery event to fix memory leak problem
@ 2021-12-20 12:41 Harold Huang
  2021-12-20 12:49 ` [PATCH v2] net/virtio: unregister virtio user memory " Harold Huang
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Harold Huang @ 2021-12-20 12:41 UTC (permalink / raw)
  To: dev; +Cc: maxime.coquelin, chenbo.xia

When eth_virtio_dev_init is failed, the registered virtio user memery is
not released and creating a new virtio user dev could be failed becase the
new dev could use the same address pointer and the register virtio user
memory to the same address is not allowed.

Signed-off-by: Harold Huang <baymaxhuang@gmail.com>
---
 drivers/net/virtio/virtio_user_ethdev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index 0271098f0d..16eca2f940 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -666,6 +666,7 @@ virtio_user_pmd_probe(struct rte_vdev_device *vdev)
 	/* previously called by pci probing for physical dev */
 	if (eth_virtio_dev_init(eth_dev) < 0) {
 		PMD_INIT_LOG(ERR, "eth_virtio_dev_init fails");
+		virtio_user_dev_uninit(dev);
 		virtio_user_eth_dev_free(eth_dev);
 		goto end;
 	}
-- 
2.27.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] net/virtio: unregister virtio user memory event to fix memory leak problem
  2021-12-20 12:41 [PATCH] net/virtio: unregister virtio user memery event to fix memory leak problem Harold Huang
@ 2021-12-20 12:49 ` Harold Huang
  2021-12-20 14:08   ` Fwd: " Harold Huang
  2021-12-22  8:33 ` [PATCH v3] net/virtio: fix unregister virtio user memory event cb problem Harold Huang
  2021-12-23  4:42 ` [PATCH] net/virtio: fix unreleased resource when creating virtio user dev is failed Harold Huang
  2 siblings, 1 reply; 7+ messages in thread
From: Harold Huang @ 2021-12-20 12:49 UTC (permalink / raw)
  To: dev

When eth_virtio_dev_init is failed, the registered virtio user memory is
not released and creating a new virtio user dev could be failed because the
new dev could use the same address pointer and the register virtio user
memory to the same address is not allowed.

Signed-off-by: Harold Huang <baymaxhuang@gmail.com>
---
 drivers/net/virtio/virtio_user_ethdev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index 0271098f0d..16eca2f940 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -666,6 +666,7 @@ virtio_user_pmd_probe(struct rte_vdev_device *vdev)
 	/* previously called by pci probing for physical dev */
 	if (eth_virtio_dev_init(eth_dev) < 0) {
 		PMD_INIT_LOG(ERR, "eth_virtio_dev_init fails");
+		virtio_user_dev_uninit(dev);
 		virtio_user_eth_dev_free(eth_dev);
 		goto end;
 	}
-- 
2.27.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Fwd: [PATCH v2] net/virtio: unregister virtio user memory event to fix memory leak problem
  2021-12-20 12:49 ` [PATCH v2] net/virtio: unregister virtio user memory " Harold Huang
@ 2021-12-20 14:08   ` Harold Huang
  0 siblings, 0 replies; 7+ messages in thread
From: Harold Huang @ 2021-12-20 14:08 UTC (permalink / raw)
  To: dev; +Cc: maxime.coquelin, chenbo.xia

The problem which this patch wants to solve can be reproduced via ovs 2.16:

1. add a port with an invalid speed parameter:
ovs-vsctl add-port ovs-br0 virtiouser0 -- set Interface virtiouser0
type=dpdk options:dpdk-devargs=virtio_user0,path=/dev/vhost-net,queue_size=1024,queues=1,speed=1000

2. delete the failed virtiouser0 port:
ovs-vsctl del-port virtiouser0

3. add a new port with valid parameters:
ovs-vsctl add-port ovs-br0 virtiouser0 -- set Interface virtiouser0
type=dpdk options:dpdk-devargs=virtio_user0,path=/dev/vhost-net,queue_size=1024,queues=1

The newly added port is always failed because of an existing memory event error.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v3] net/virtio: fix unregister virtio user memory event cb problem
  2021-12-20 12:41 [PATCH] net/virtio: unregister virtio user memery event to fix memory leak problem Harold Huang
  2021-12-20 12:49 ` [PATCH v2] net/virtio: unregister virtio user memory " Harold Huang
@ 2021-12-22  8:33 ` Harold Huang
  2021-12-23  4:42 ` [PATCH] net/virtio: fix unreleased resource when creating virtio user dev is failed Harold Huang
  2 siblings, 0 replies; 7+ messages in thread
From: Harold Huang @ 2021-12-22  8:33 UTC (permalink / raw)
  To: dev; +Cc: Maxime Coquelin, Chenbo Xia

When eth_virtio_dev_init is failed, the registered virtio user memory
event cb is not released and creating a new vdev could be failed
because the new virtio_user_dev could use the same address pointer and
register memory event cb to the same address is not allowed.

Signed-off-by: Harold Huang <baymaxhuang@gmail.com>
---
Compared PATCH v2, commit message is changed. The problem this patch want
to solve can be reproduced by ovs 2.16.90 and the latest dpdk.
 drivers/net/virtio/virtio_user_ethdev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index 0271098f0d..16eca2f940 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -666,6 +666,7 @@ virtio_user_pmd_probe(struct rte_vdev_device *vdev)
 	/* previously called by pci probing for physical dev */
 	if (eth_virtio_dev_init(eth_dev) < 0) {
 		PMD_INIT_LOG(ERR, "eth_virtio_dev_init fails");
+		virtio_user_dev_uninit(dev);
 		virtio_user_eth_dev_free(eth_dev);
 		goto end;
 	}
-- 
2.27.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] net/virtio: fix unreleased resource when creating virtio user dev is failed
  2021-12-20 12:41 [PATCH] net/virtio: unregister virtio user memery event to fix memory leak problem Harold Huang
  2021-12-20 12:49 ` [PATCH v2] net/virtio: unregister virtio user memory " Harold Huang
  2021-12-22  8:33 ` [PATCH v3] net/virtio: fix unregister virtio user memory event cb problem Harold Huang
@ 2021-12-23  4:42 ` Harold Huang
  2022-01-14  7:48   ` Xia, Chenbo
  2022-01-27  5:23   ` Xia, Chenbo
  2 siblings, 2 replies; 7+ messages in thread
From: Harold Huang @ 2021-12-23  4:42 UTC (permalink / raw)
  To: dev; +Cc: Maxime Coquelin, Chenbo Xia

When eth_virtio_dev_init is failed, the registered virtio user memory event
cb is not released and the backend created tap device is not destroyed.
It would cause some residual tap device existed in the host and creating
a new vdev could be failed because the new virtio_user_dev could use the
same address pointer and register memory event cb to the same address is
not allowed.

Signed-off-by: Harold Huang <baymaxhuang@gmail.com>
---
Compared to patch v3, commit log is changed because this bug could
cause residual tap device in the host.
 drivers/net/virtio/virtio_user_ethdev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index 0271098f0d..16eca2f940 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -666,6 +666,7 @@ virtio_user_pmd_probe(struct rte_vdev_device *vdev)
 	/* previously called by pci probing for physical dev */
 	if (eth_virtio_dev_init(eth_dev) < 0) {
 		PMD_INIT_LOG(ERR, "eth_virtio_dev_init fails");
+		virtio_user_dev_uninit(dev);
 		virtio_user_eth_dev_free(eth_dev);
 		goto end;
 	}
-- 
2.27.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH] net/virtio: fix unreleased resource when creating virtio user dev is failed
  2021-12-23  4:42 ` [PATCH] net/virtio: fix unreleased resource when creating virtio user dev is failed Harold Huang
@ 2022-01-14  7:48   ` Xia, Chenbo
  2022-01-27  5:23   ` Xia, Chenbo
  1 sibling, 0 replies; 7+ messages in thread
From: Xia, Chenbo @ 2022-01-14  7:48 UTC (permalink / raw)
  To: Harold Huang, dev; +Cc: Maxime Coquelin

> -----Original Message-----
> From: Harold Huang <baymaxhuang@gmail.com>
> Sent: Thursday, December 23, 2021 12:43 PM
> To: dev@dpdk.org
> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>; Xia, Chenbo
> <chenbo.xia@intel.com>
> Subject: [PATCH] net/virtio: fix unreleased resource when creating virtio user
> dev is failed
> 
> When eth_virtio_dev_init is failed, the registered virtio user memory event
> cb is not released and the backend created tap device is not destroyed.
> It would cause some residual tap device existed in the host and creating
> a new vdev could be failed because the new virtio_user_dev could use the
> same address pointer and register memory event cb to the same address is
> not allowed.
> 
> Signed-off-by: Harold Huang <baymaxhuang@gmail.com>
> ---
> Compared to patch v3, commit log is changed because this bug could
> cause residual tap device in the host.
>  drivers/net/virtio/virtio_user_ethdev.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/virtio/virtio_user_ethdev.c
> b/drivers/net/virtio/virtio_user_ethdev.c
> index 0271098f0d..16eca2f940 100644
> --- a/drivers/net/virtio/virtio_user_ethdev.c
> +++ b/drivers/net/virtio/virtio_user_ethdev.c
> @@ -666,6 +666,7 @@ virtio_user_pmd_probe(struct rte_vdev_device *vdev)
>  	/* previously called by pci probing for physical dev */
>  	if (eth_virtio_dev_init(eth_dev) < 0) {
>  		PMD_INIT_LOG(ERR, "eth_virtio_dev_init fails");
> +		virtio_user_dev_uninit(dev);
>  		virtio_user_eth_dev_free(eth_dev);
>  		goto end;
>  	}
> --
> 2.27.0

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH] net/virtio: fix unreleased resource when creating virtio user dev is failed
  2021-12-23  4:42 ` [PATCH] net/virtio: fix unreleased resource when creating virtio user dev is failed Harold Huang
  2022-01-14  7:48   ` Xia, Chenbo
@ 2022-01-27  5:23   ` Xia, Chenbo
  1 sibling, 0 replies; 7+ messages in thread
From: Xia, Chenbo @ 2022-01-27  5:23 UTC (permalink / raw)
  To: Harold Huang, dev; +Cc: Maxime Coquelin

> -----Original Message-----
> From: Harold Huang <baymaxhuang@gmail.com>
> Sent: Thursday, December 23, 2021 12:43 PM
> To: dev@dpdk.org
> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>; Xia, Chenbo
> <chenbo.xia@intel.com>
> Subject: [PATCH] net/virtio: fix unreleased resource when creating virtio user
> dev is failed
> 
> When eth_virtio_dev_init is failed, the registered virtio user memory event
> cb is not released and the backend created tap device is not destroyed.
> It would cause some residual tap device existed in the host and creating
> a new vdev could be failed because the new virtio_user_dev could use the
> same address pointer and register memory event cb to the same address is
> not allowed.
> 
> Signed-off-by: Harold Huang <baymaxhuang@gmail.com>
> ---
> Compared to patch v3, commit log is changed because this bug could
> cause residual tap device in the host.
>  drivers/net/virtio/virtio_user_ethdev.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/virtio/virtio_user_ethdev.c
> b/drivers/net/virtio/virtio_user_ethdev.c
> index 0271098f0d..16eca2f940 100644
> --- a/drivers/net/virtio/virtio_user_ethdev.c
> +++ b/drivers/net/virtio/virtio_user_ethdev.c
> @@ -666,6 +666,7 @@ virtio_user_pmd_probe(struct rte_vdev_device *vdev)
>  	/* previously called by pci probing for physical dev */
>  	if (eth_virtio_dev_init(eth_dev) < 0) {
>  		PMD_INIT_LOG(ERR, "eth_virtio_dev_init fails");
> +		virtio_user_dev_uninit(dev);
>  		virtio_user_eth_dev_free(eth_dev);
>  		goto end;
>  	}
> --
> 2.27.0

Applied to next-virtio/main with headline shortened and fix tag added.

Thanks!

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-01-27  5:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-20 12:41 [PATCH] net/virtio: unregister virtio user memery event to fix memory leak problem Harold Huang
2021-12-20 12:49 ` [PATCH v2] net/virtio: unregister virtio user memory " Harold Huang
2021-12-20 14:08   ` Fwd: " Harold Huang
2021-12-22  8:33 ` [PATCH v3] net/virtio: fix unregister virtio user memory event cb problem Harold Huang
2021-12-23  4:42 ` [PATCH] net/virtio: fix unreleased resource when creating virtio user dev is failed Harold Huang
2022-01-14  7:48   ` Xia, Chenbo
2022-01-27  5:23   ` Xia, Chenbo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).