patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Chengfeng Ye <cyeaa@connect.ust.hk>, <david.marchand@redhat.com>,
	<viacheslavo@nvidia.com>, <shahafs@nvidia.com>,
	<matan@nvidia.com>
Cc: <dev@dpdk.org>, <stable@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v5] net/mlx5: fix mutex unlock in txpp cleanup
Date: Wed, 10 Nov 2021 16:57:27 +0000	[thread overview]
Message-ID: <9543c101-2328-8698-0ea7-a2e754d3146d@intel.com> (raw)
In-Reply-To: <20211012100204.5569-1-cyeaa@connect.ust.hk>

On 10/12/2021 11:02 AM, Chengfeng Ye wrote:
> 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 | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c
> index 4f6da9f2d1..0ece788a84 100644
> --- a/drivers/net/mlx5/mlx5_txpp.c
> +++ b/drivers/net/mlx5/mlx5_txpp.c
> @@ -961,8 +961,12 @@ mlx5_txpp_stop(struct rte_eth_dev *dev)
>   	MLX5_ASSERT(!ret);
>   	RTE_SET_USED(ret);
>   	MLX5_ASSERT(sh->txpp.refcnt);
> -	if (!sh->txpp.refcnt || --sh->txpp.refcnt)
> +	if (!sh->txpp.refcnt || --sh->txpp.refcnt) {
> +		ret = pthread_mutex_unlock(&sh->txpp.mutex);
> +		MLX5_ASSERT(!ret);
> +		RTE_SET_USED(ret);

Is this 'RTE_SET_USED()' need to be used multiple times for same variable?

This usage looks ugly, I can see why it is used but I wonder if this can
be solved differently, what about something like following:

  #ifdef RTE_LIBRTE_MLX5_DEBUG
   #define MLX5_ASSERT(exp) RTE_VERIFY(exp)
  #else
   #ifdef RTE_ENABLE_ASSERT
    #define MLX5_ASSERT(exp) RTE_ASSERT(exp)
   #else
    #define MLX5_ASSERT(exp) RTE_SET_USED(exp)
   #endif
  #endif

>   		return;
> +	}
>   	/* No references any more, do actual destroy. */
>   	mlx5_txpp_destroy(sh);
>   	ret = pthread_mutex_unlock(&sh->txpp.mutex);
> 


  parent reply	other threads:[~2021-11-10 16:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-12 10:02 [dpdk-stable] " Chengfeng Ye
2021-11-02  7:55 ` Slava Ovsiienko
2021-11-09 11:08 ` [dpdk-stable] [dpdk-dev] " Raslan Darawsheh
2021-11-10 16:57 ` Ferruh Yigit [this message]
2021-11-11  7:06   ` Slava Ovsiienko
2021-11-11  8:47     ` [PATCH] net/mlx5: remove redundant "set used" Viacheslav Ovsiienko
2021-11-11  8:59       ` Slava Ovsiienko
2021-11-11 12:08         ` Ferruh Yigit
2021-11-11 12:27           ` Slava Ovsiienko
2021-11-11 16:07             ` YE Chengfeng
2021-11-11 16:47               ` Slava Ovsiienko
2021-11-11 18:31                 ` YE Chengfeng
2021-11-16 14:52                   ` 回复: " YE Chengfeng
2021-11-11 11:25     ` [dpdk-dev] [PATCH v5] net/mlx5: fix mutex unlock in txpp cleanup Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9543c101-2328-8698-0ea7-a2e754d3146d@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=cyeaa@connect.ust.hk \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=matan@nvidia.com \
    --cc=shahafs@nvidia.com \
    --cc=stable@dpdk.org \
    --cc=viacheslavo@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).