patches for DPDK stable branches
 help / color / Atom feed
From: Raslan Darawsheh <rasland@nvidia.com>
To: Dekel Peled <dekelp@nvidia.com>, Matan Azrad <matan@nvidia.com>,
	"Shahaf Shuler" <shahafs@nvidia.com>,
	Slava Ovsiienko <viacheslavo@nvidia.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>, "stable@dpdk.org" <stable@dpdk.org>
Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH] net/mlx5: fix use of atomic cmpset for age state
Date: Mon, 19 Oct 2020 10:48:43 +0000
Message-ID: <DM6PR12MB274823D31A3C3F9B76802357CF1E0@DM6PR12MB2748.namprd12.prod.outlook.com> (raw)
In-Reply-To: <80931ca7b31b48beebb22d0d093e07a3d6539336.1602762247.git.dekelp@nvidia.com>

Hi,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Dekel Peled
> Sent: Thursday, October 15, 2020 2:44 PM
> To: Matan Azrad <matan@nvidia.com>; Shahaf Shuler
> <shahafs@nvidia.com>; Slava Ovsiienko <viacheslavo@nvidia.com>
> Cc: dev@dpdk.org; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] net/mlx5: fix use of atomic cmpset for age state
> 
> According to documentation [1], function rte_atomic16_cmpset()
> return value is non-zero on success; 0 on failure.
> In existing code this function is called, and the return value
> is compared to AGE_CANDIDATE, which is defined as 1.
> Such comparison is incorrect and can lead to unwanted behavior.
> 
> This patch updates the calls to rte_atomic16_cmpset(), to check
> that the return value is 0 or non-zero.
> 
> [1]
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoc.
> dpdk.org%2Fapi%2Frte__atomic_8h.html&amp;data=04%7C01%7Crasland%
> 40nvidia.com%7Cc92848ff1c4a42b83bfb08d870ffe9d0%7C43083d15727340c1b
> 7db39efd9ccc17a%7C0%7C0%7C637383591730997946%7CUnknown%7CTWFp
> bGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVC
> I6Mn0%3D%7C1000&amp;sdata=l%2Bq5%2F8MO4Qrh8MrJzEGrrQCTzE%2FH
> 5Iw03qqXj5LG2PY%3D&amp;reserved=0
> 
> Fixes: fa2d01c87d2b ("net/mlx5: support flow aging")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Dekel Peled <dekelp@nvidia.com>
> Acked-by: Matan Azrad <matan@nvidia.com>
> ---
>  drivers/net/mlx5/mlx5_flow.c    | 8 ++------
>  drivers/net/mlx5/mlx5_flow_dv.c | 9 ++++-----
>  2 files changed, 6 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
> index 3d38e11..2729629 100644
> --- a/drivers/net/mlx5/mlx5_flow.c
> +++ b/drivers/net/mlx5/mlx5_flow.c
> @@ -6747,12 +6747,8 @@ struct mlx5_meter_domains_infos *
>  		priv = rte_eth_devices[age_param->port_id].data-
> >dev_private;
>  		age_info = GET_PORT_AGE_INFO(priv);
>  		rte_spinlock_lock(&age_info->aged_sl);
> -		/* If the cpmset fails, release happens. */
> -		if (rte_atomic16_cmpset((volatile uint16_t *)
> -					&age_param->state,
> -					AGE_CANDIDATE,
> -					AGE_TMOUT) ==
> -					AGE_CANDIDATE) {
> +		if (rte_atomic16_cmpset((volatile uint16_t *)&age_param-
> >state,
> +					AGE_CANDIDATE, AGE_TMOUT)) {
>  			TAILQ_INSERT_TAIL(&age_info->aged_counters, cnt,
> next);
>  			MLX5_AGE_SET(age_info, MLX5_AGE_EVENT_NEW);
>  		}
> diff --git a/drivers/net/mlx5/mlx5_flow_dv.c
> b/drivers/net/mlx5/mlx5_flow_dv.c
> index 361c32d..174189a 100644
> --- a/drivers/net/mlx5/mlx5_flow_dv.c
> +++ b/drivers/net/mlx5/mlx5_flow_dv.c
> @@ -5103,10 +5103,8 @@ struct field_modify_info modify_tcp[] = {
> 
>  	age_info = GET_PORT_AGE_INFO(priv);
>  	age_param = flow_dv_counter_idx_get_age(dev, counter);
> -	if (rte_atomic16_cmpset((volatile uint16_t *)
> -			&age_param->state,
> -			AGE_CANDIDATE, AGE_FREE)
> -			!= AGE_CANDIDATE) {
> +	if (!rte_atomic16_cmpset((volatile uint16_t *)&age_param->state,
> +				 AGE_CANDIDATE, AGE_FREE)) {
>  		/**
>  		 * We need the lock even it is age timeout,
>  		 * since counter may still in process.
> @@ -5114,9 +5112,10 @@ struct field_modify_info modify_tcp[] = {
>  		rte_spinlock_lock(&age_info->aged_sl);
>  		TAILQ_REMOVE(&age_info->aged_counters, cnt, next);
>  		rte_spinlock_unlock(&age_info->aged_sl);
> +		rte_atomic16_set(&age_param->state, AGE_FREE);
>  	}
> -	rte_atomic16_set(&age_param->state, AGE_FREE);
>  }
> +
>  /**
>   * Release a flow counter.
>   *
> --
> 1.8.3.1

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

      reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-15 11:44 [dpdk-stable] " Dekel Peled
2020-10-19 10:48 ` Raslan Darawsheh [this message]

Reply instructions:

You may reply publically 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=DM6PR12MB274823D31A3C3F9B76802357CF1E0@DM6PR12MB2748.namprd12.prod.outlook.com \
    --to=rasland@nvidia.com \
    --cc=dekelp@nvidia.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

patches for DPDK stable branches

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ http://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/ public-inbox