net/mlx5: fix atomic API update

Message ID 1604386064-342267-1-git-send-email-matan@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers
Series net/mlx5: fix atomic API update |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-testing success Testing PASS
ci/iol-intel-Functional fail Functional Testing issues
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Matan Azrad Nov. 3, 2020, 6:47 a.m. UTC
  The Txq refcnt 1 value means that there is not real reference to the
queue and only the control configuration are saved in the struct.

The patch below wrongly didn't consider it and caused a leak in the Txq
object resource.

Revert the specific update in the refcnt.

Fixes: a02d6dd9e61f ("net/mlx5: use C11 atomics for RxQ/TxQ refcounts")

Signed-off-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/mlx5_txq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Slava Ovsiienko Nov. 3, 2020, 6:55 a.m. UTC | #1
> -----Original Message-----
> From: Matan Azrad <matan@nvidia.com>
> Sent: Tuesday, November 3, 2020 8:48
> To: Slava Ovsiienko <viacheslavo@nvidia.com>
> Cc: dev@dpdk.org
> Subject: [PATCH] net/mlx5: fix atomic API update
> 
> The Txq refcnt 1 value means that there is not real reference to the queue and
> only the control configuration are saved in the struct.
> 
> The patch below wrongly didn't consider it and caused a leak in the Txq object
> resource.
> 
> Revert the specific update in the refcnt.
> 
> Fixes: a02d6dd9e61f ("net/mlx5: use C11 atomics for RxQ/TxQ refcounts")
> 
> Signed-off-by: Matan Azrad <matan@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
  
Raslan Darawsheh Nov. 5, 2020, 5:37 p.m. UTC | #2
Hi,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Matan Azrad
> Sent: Tuesday, November 3, 2020 8:48 AM
> To: Slava Ovsiienko <viacheslavo@nvidia.com>
> Cc: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH] net/mlx5: fix atomic API update
> 
> The Txq refcnt 1 value means that there is not real reference to the
> queue and only the control configuration are saved in the struct.
> 
> The patch below wrongly didn't consider it and caused a leak in the Txq
> object resource.
> 
> Revert the specific update in the refcnt.
> 
> Fixes: a02d6dd9e61f ("net/mlx5: use C11 atomics for RxQ/TxQ refcounts")
> 
> Signed-off-by: Matan Azrad <matan@nvidia.com>
> ---
>  drivers/net/mlx5/mlx5_txq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh
  

Patch

diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index 6390cd0..cdd1022 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -1234,7 +1234,7 @@  struct mlx5_txq_ctrl *
 	if (!(*priv->txqs)[idx])
 		return 0;
 	txq_ctrl = container_of((*priv->txqs)[idx], struct mlx5_txq_ctrl, txq);
-	if (__atomic_sub_fetch(&txq_ctrl->refcnt, 1, __ATOMIC_RELAXED) != 0)
+	if (__atomic_sub_fetch(&txq_ctrl->refcnt, 1, __ATOMIC_RELAXED) > 1)
 		return 1;
 	if (txq_ctrl->obj) {
 		priv->obj_ops.txq_obj_release(txq_ctrl->obj);