diff mbox series

net/mlx5: remove redundant "set used"

Message ID 20211111084751.26721-1-viacheslavo@nvidia.com (mailing list archive)
State Rejected, archived
Delegated to: Raslan Darawsheh
Headers show
Series net/mlx5: remove redundant "set used" | expand

Checks

Context Check Description
ci/iol-testing warning apply patch failure
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Slava Ovsiienko Nov. 11, 2021, 8:47 a.m. UTC
The patch just refines the code and replaces the pairs
of MLX5_ASSERT() and RTE_SET_USED() with equivalent claim_zero().

Cc: stable@dpdk.org

Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 drivers/net/mlx5/mlx5_txpp.c | 30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)

Comments

Slava Ovsiienko Nov. 11, 2021, 8:59 a.m. UTC | #1
Hi, Ferruh

I've also inspected the mlx5 PMD code for RTE_SET_USED() for the similar
issues related to the MLX5_ASSERT().

The patch http://patches.dpdk.org/project/dpdk/patch/20211111084751.26721-1-viacheslavo@nvidia.com/
should refine the few found ones. 

I do not mind about squashing with "net/mlx5: fix mutex unlock in txpp cleanup"
After getting this code in Upstream will care about the version for LTS.

With best regards,
Slava

> -----Original Message-----
> From: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
> Sent: Thursday, November 11, 2021 10:48
> To: dev@dpdk.org
> Cc: ferruh.yigit@intel.com; Raslan Darawsheh <rasland@nvidia.com>; Matan
> Azrad <matan@nvidia.com>; stable@dpdk.org
> Subject: [PATCH] net/mlx5: remove redundant "set used"
> 
> The patch just refines the code and replaces the pairs of MLX5_ASSERT() and
> RTE_SET_USED() with equivalent claim_zero().
> 
> Cc: stable@dpdk.org
> 
> Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
> ---
>  drivers/net/mlx5/mlx5_txpp.c | 30 ++++++++++--------------------
>  1 file changed, 10 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c
> index 73626f0e8f..af77e91e4c 100644
> --- a/drivers/net/mlx5/mlx5_txpp.c
> +++ b/drivers/net/mlx5/mlx5_txpp.c
> @@ -890,7 +890,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. */ @@ -
> 903,14 +902,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;
> @@ -924,9 +923,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;
>  }
> 
> @@ -944,28 +941,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) {
> -		ret = pthread_mutex_unlock(&sh->txpp.mutex);
> -		MLX5_ASSERT(!ret);
> -		RTE_SET_USED(ret);
> +		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.18.1
Ferruh Yigit Nov. 11, 2021, 12:08 p.m. UTC | #2
On 11/11/2021 8:59 AM, Slava Ovsiienko wrote:
> Hi, Ferruh
> 
> I've also inspected the mlx5 PMD code for RTE_SET_USED() for the similar
> issues related to the MLX5_ASSERT().
> 
> The patch http://patches.dpdk.org/project/dpdk/patch/20211111084751.26721-1-viacheslavo@nvidia.com/
> should refine the few found ones.
> 
> I do not mind about squashing with "net/mlx5: fix mutex unlock in txpp cleanup"
> After getting this code in Upstream will care about the version for LTS.
> 

It will cause additional complexity for the LTS, since a small part of the below fix
will be originated from Chengfeng's change. To help LTS, what do you think

- First get your fix on top of current task
- Have a new version from Chengfeng on top of latest head, with 'claim_zero' usage?

So only your update need to be merged to LTS releases.



> With best regards,
> Slava
> 
>> -----Original Message-----
>> From: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
>> Sent: Thursday, November 11, 2021 10:48
>> To: dev@dpdk.org
>> Cc: ferruh.yigit@intel.com; Raslan Darawsheh <rasland@nvidia.com>; Matan
>> Azrad <matan@nvidia.com>; stable@dpdk.org
>> Subject: [PATCH] net/mlx5: remove redundant "set used"
>>
>> The patch just refines the code and replaces the pairs of MLX5_ASSERT() and
>> RTE_SET_USED() with equivalent claim_zero().
>>
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
>> ---
>>   drivers/net/mlx5/mlx5_txpp.c | 30 ++++++++++--------------------
>>   1 file changed, 10 insertions(+), 20 deletions(-)
>>
>> diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c
>> index 73626f0e8f..af77e91e4c 100644
>> --- a/drivers/net/mlx5/mlx5_txpp.c
>> +++ b/drivers/net/mlx5/mlx5_txpp.c
>> @@ -890,7 +890,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. */ @@ -
>> 903,14 +902,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;
>> @@ -924,9 +923,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;
>>   }
>>
>> @@ -944,28 +941,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) {
>> -		ret = pthread_mutex_unlock(&sh->txpp.mutex);
>> -		MLX5_ASSERT(!ret);
>> -		RTE_SET_USED(ret);
>> +		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.18.1
>
Slava Ovsiienko Nov. 11, 2021, 12:27 p.m. UTC | #3
Hi, Ferruh

> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@intel.com>
> Sent: Thursday, November 11, 2021 14:08
> To: Slava Ovsiienko <viacheslavo@nvidia.com>; dev@dpdk.org
> Cc: Raslan Darawsheh <rasland@nvidia.com>; Matan Azrad
> <matan@nvidia.com>; stable@dpdk.org; Chengfeng Ye
> <cyeaa@connect.ust.hk>
> Subject: Re: [PATCH] net/mlx5: remove redundant "set used"
> 
> On 11/11/2021 8:59 AM, Slava Ovsiienko wrote:
> > Hi, Ferruh
> >
> > I've also inspected the mlx5 PMD code for RTE_SET_USED() for the
> > similar issues related to the MLX5_ASSERT().
> >
> > The patch
> > http://patches.dpdk.org/project/dpdk/patch/20211111084751.26721-1-
> viac
> > heslavo@nvidia.com/
> > should refine the few found ones.
> >
> > I do not mind about squashing with "net/mlx5: fix mutex unlock in txpp
> cleanup"
> > After getting this code in Upstream will care about the version for LTS.
> >
> 
> It will cause additional complexity for the LTS, since a small part of the below
> fix will be originated from Chengfeng's change. To help LTS, what do you think
> - First get your fix on top of current task
> - Have a new version from Chengfeng on top of latest head, with 'claim_zero'
> usage?
Would be nice, I have no any objections.
Chengfeng, could you please, squash (or write by yourself) my proposed updates
and send the next version of your patch with "claim_zero()"?

> So only your update need to be merged to LTS releases.
Yes, agree, it is even better than my proposal.

With best regards,
Slava

> >
> >> -----Original Message-----
> >> From: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
> >> Sent: Thursday, November 11, 2021 10:48
> >> To: dev@dpdk.org
> >> Cc: ferruh.yigit@intel.com; Raslan Darawsheh <rasland@nvidia.com>;
> >> Matan Azrad <matan@nvidia.com>; stable@dpdk.org
> >> Subject: [PATCH] net/mlx5: remove redundant "set used"
> >>
> >> The patch just refines the code and replaces the pairs of
> >> MLX5_ASSERT() and
> >> RTE_SET_USED() with equivalent claim_zero().
> >>
> >> Cc: stable@dpdk.org
> >>
> >> Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
> >> ---
> >>   drivers/net/mlx5/mlx5_txpp.c | 30 ++++++++++--------------------
> >>   1 file changed, 10 insertions(+), 20 deletions(-)
> >>
> >> diff --git a/drivers/net/mlx5/mlx5_txpp.c
> >> b/drivers/net/mlx5/mlx5_txpp.c index 73626f0e8f..af77e91e4c 100644
> >> --- a/drivers/net/mlx5/mlx5_txpp.c
> >> +++ b/drivers/net/mlx5/mlx5_txpp.c
> >> @@ -890,7 +890,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. */ @@ -
> >> 903,14 +902,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;
> >> @@ -924,9 +923,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;
> >>   }
> >>
> >> @@ -944,28 +941,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) {
> >> -		ret = pthread_mutex_unlock(&sh->txpp.mutex);
> >> -		MLX5_ASSERT(!ret);
> >> -		RTE_SET_USED(ret);
> >> +		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.18.1
> >
YE Chengfeng Nov. 11, 2021, 4:07 p.m. UTC | #4
No problem, I will send the new patch.

But what about the commit message and title, should I use the previous one?

net/mlx5: fix mutex unlock in txpp cleanup


获取 Outlook for iOS<https://aka.ms/o0ukef>
Slava Ovsiienko Nov. 11, 2021, 4:47 p.m. UTC | #5
From: YE Chengfeng <cyeaa@connect.ust.hk>
Sent: Thursday, November 11, 2021 18:08
To: Slava Ovsiienko <viacheslavo@nvidia.com>; Ferruh Yigit <ferruh.yigit@intel.com>; dev@dpdk.org
Cc: Raslan Darawsheh <rasland@nvidia.com>; Matan Azrad <matan@nvidia.com>; stable@dpdk.org
Subject: Re: [PATCH] net/mlx5: remove redundant "set used"

No problem, I will send the new patch.
[SO] Thank you.

But what about the commit message and title, should I use the previous one?

net/mlx5: fix mutex unlock in txpp cleanup

[SO] Please,  send as the next version (v6?) of your patch. Just squash my proposals
and keep your title (“net/mlx5: fix mutex unlock in txpp cleanup”) and commit message.



With best regards,
Slava





获取 Outlook for iOS<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Faka.ms%2Fo0ukef&data=04%7C01%7Cviacheslavo%40nvidia.com%7Ce021aa65a82246fea44808d9a52d64bb%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637722436716123715%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=gLoebXXI%2BFE8l6sE0pmNxjvPNVk34vBxWTeVlTOmJJ0%3D&reserved=0>
YE Chengfeng Nov. 11, 2021, 6:31 p.m. UTC | #6
Got it.

获取 Outlook for iOS<https://aka.ms/o0ukef>
YE Chengfeng Nov. 16, 2021, 2:52 p.m. UTC | #7
Hi,

I send the v6 patch.

Best regards,
Chengfeng
diff mbox series

Patch

diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c
index 73626f0e8f..af77e91e4c 100644
--- a/drivers/net/mlx5/mlx5_txpp.c
+++ b/drivers/net/mlx5/mlx5_txpp.c
@@ -890,7 +890,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. */
@@ -903,14 +902,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;
@@ -924,9 +923,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;
 }
 
@@ -944,28 +941,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) {
-		ret = pthread_mutex_unlock(&sh->txpp.mutex);
-		MLX5_ASSERT(!ret);
-		RTE_SET_USED(ret);
+		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));
 }
 
 /*