* [PATCH v6] net/mlx5: fix mutex unlock in txpp cleanup
@ 2021-11-16 14:49 Chengfeng Ye
2021-11-16 15:04 ` Slava Ovsiienko
0 siblings, 1 reply; 3+ messages in thread
From: Chengfeng Ye @ 2021-11-16 14:49 UTC (permalink / raw)
To: matan, viacheslavo, tzahio, ferruh.yigit, rasland
Cc: dev, Chengfeng Ye, stable
The lock sh->txpp.mutex was not correctly released on one path
of cleanup function return, potentially causing the deadlock.
Fixes: d133f4cdb7 ("net/mlx5: create clock queue for packet pacing")
Cc: stable@dpdk.org
Signed-off-by: Chengfeng Ye <cyeaa@connect.ust.hk>
---
drivers/net/mlx5/mlx5_txpp.c | 30 ++++++++++++------------------
1 file changed, 12 insertions(+), 18 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c
index 4f6da9f2d1..75c08c55e2 100644
--- a/drivers/net/mlx5/mlx5_txpp.c
+++ b/drivers/net/mlx5/mlx5_txpp.c
@@ -896,7 +896,6 @@ mlx5_txpp_start(struct rte_eth_dev *dev)
struct mlx5_priv *priv = dev->data->dev_private;
struct mlx5_dev_ctx_shared *sh = priv->sh;
int err = 0;
- int ret;
if (!priv->config.tx_pp) {
/* Packet pacing is not requested for the device. */
@@ -909,14 +908,14 @@ mlx5_txpp_start(struct rte_eth_dev *dev)
return 0;
}
if (priv->config.tx_pp > 0) {
- ret = rte_mbuf_dynflag_lookup
- (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME, NULL);
- if (ret < 0)
+ err = rte_mbuf_dynflag_lookup
+ (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME, NULL);
+ /* No flag registered means no service needed. */
+ if (err < 0)
return 0;
+ err = 0;
}
- ret = pthread_mutex_lock(&sh->txpp.mutex);
- MLX5_ASSERT(!ret);
- RTE_SET_USED(ret);
+ claim_zero(pthread_mutex_lock(&sh->txpp.mutex));
if (sh->txpp.refcnt) {
priv->txpp_en = 1;
++sh->txpp.refcnt;
@@ -930,9 +929,7 @@ mlx5_txpp_start(struct rte_eth_dev *dev)
rte_errno = -err;
}
}
- ret = pthread_mutex_unlock(&sh->txpp.mutex);
- MLX5_ASSERT(!ret);
- RTE_SET_USED(ret);
+ claim_zero(pthread_mutex_unlock(&sh->txpp.mutex));
return err;
}
@@ -950,24 +947,21 @@ mlx5_txpp_stop(struct rte_eth_dev *dev)
{
struct mlx5_priv *priv = dev->data->dev_private;
struct mlx5_dev_ctx_shared *sh = priv->sh;
- int ret;
if (!priv->txpp_en) {
/* Packet pacing is already disabled for the device. */
return;
}
priv->txpp_en = 0;
- ret = pthread_mutex_lock(&sh->txpp.mutex);
- MLX5_ASSERT(!ret);
- RTE_SET_USED(ret);
+ claim_zero(pthread_mutex_lock(&sh->txpp.mutex));
MLX5_ASSERT(sh->txpp.refcnt);
- if (!sh->txpp.refcnt || --sh->txpp.refcnt)
+ if (!sh->txpp.refcnt || --sh->txpp.refcnt) {
+ claim_zero(pthread_mutex_unlock(&sh->txpp.mutex));
return;
+ }
/* No references any more, do actual destroy. */
mlx5_txpp_destroy(sh);
- ret = pthread_mutex_unlock(&sh->txpp.mutex);
- MLX5_ASSERT(!ret);
- RTE_SET_USED(ret);
+ claim_zero(pthread_mutex_unlock(&sh->txpp.mutex));
}
/*
--
2.17.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH v6] net/mlx5: fix mutex unlock in txpp cleanup
2021-11-16 14:49 [PATCH v6] net/mlx5: fix mutex unlock in txpp cleanup Chengfeng Ye
@ 2021-11-16 15:04 ` Slava Ovsiienko
2021-11-16 17:01 ` Ferruh Yigit
0 siblings, 1 reply; 3+ messages in thread
From: Slava Ovsiienko @ 2021-11-16 15:04 UTC (permalink / raw)
To: Chengfeng Ye, Matan Azrad, Tzahi Oved, ferruh.yigit, Raslan Darawsheh
Cc: dev, stable
> -----Original Message-----
> From: Chengfeng Ye <cyeaa@connect.ust.hk>
> Sent: Tuesday, November 16, 2021 16:49
> To: Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Tzahi Oved <tzahio@nvidia.com>;
> ferruh.yigit@intel.com; Raslan Darawsheh <rasland@nvidia.com>
> Cc: dev@dpdk.org; Chengfeng Ye <cyeaa@connect.ust.hk>; stable@dpdk.org
> Subject: [PATCH v6] net/mlx5: fix mutex unlock in txpp cleanup
>
> The lock sh->txpp.mutex was not correctly released on one path of cleanup
> function return, potentially causing the deadlock.
>
> Fixes: d133f4cdb7 ("net/mlx5: create clock queue for packet pacing")
> Cc: stable@dpdk.org
>
> Signed-off-by: Chengfeng Ye <cyeaa@connect.ust.hk>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v6] net/mlx5: fix mutex unlock in txpp cleanup
2021-11-16 15:04 ` Slava Ovsiienko
@ 2021-11-16 17:01 ` Ferruh Yigit
0 siblings, 0 replies; 3+ messages in thread
From: Ferruh Yigit @ 2021-11-16 17:01 UTC (permalink / raw)
To: Slava Ovsiienko, Chengfeng Ye, Matan Azrad, Tzahi Oved, Raslan Darawsheh
Cc: dev, stable
On 11/16/2021 3:04 PM, Slava Ovsiienko wrote:
>> -----Original Message-----
>> From: Chengfeng Ye <cyeaa@connect.ust.hk>
>> Sent: Tuesday, November 16, 2021 16:49
>> To: Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
>> <viacheslavo@nvidia.com>; Tzahi Oved <tzahio@nvidia.com>;
>> ferruh.yigit@intel.com; Raslan Darawsheh <rasland@nvidia.com>
>> Cc: dev@dpdk.org; Chengfeng Ye <cyeaa@connect.ust.hk>; stable@dpdk.org
>> Subject: [PATCH v6] net/mlx5: fix mutex unlock in txpp cleanup
>>
>> The lock sh->txpp.mutex was not correctly released on one path of cleanup
>> function return, potentially causing the deadlock.
>>
>> Fixes: d133f4cdb7 ("net/mlx5: create clock queue for packet pacing")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Chengfeng Ye <cyeaa@connect.ust.hk>
> Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
>
Applied to dpdk-next-net/main, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-16 17:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16 14:49 [PATCH v6] net/mlx5: fix mutex unlock in txpp cleanup Chengfeng Ye
2021-11-16 15:04 ` Slava Ovsiienko
2021-11-16 17:01 ` Ferruh Yigit
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).