Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp1619172ybh; Sun, 4 Aug 2019 05:59:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxr7uuHkfLaIo8B4EUx4AtBJjTIHt6wx7ZewG7VB4ZjJA+bupbjD6qAZ2fQ8KxYUQNk6C7T X-Received: by 2002:a63:5754:: with SMTP id h20mr90662786pgm.195.1564923592413; Sun, 04 Aug 2019 05:59:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564923592; cv=none; d=google.com; s=arc-20160816; b=fGYXPrGhPI+zffnvJrn1eIimE/ICfhitPwrAam6QePRogW8/fmRxcuUW4TNZv6uvZA 2bwet0/mQKkCrCNa8DE3vr24ejuKm6uQt5/+7XlbqXGmOQ0QX0Zl5+9oYZaavE4+tiN4 OEY2epptCk4N8pHdGXAUZ/+OJ3321W0ChEJMjQ5Agmnblo20KIMlQlYW1yndfhp8Yd0r xnF6BahzkcAwQmZJRRuoH3ZRoGGaCVy9AJ+1AAmVfbUjjTfUy5wrWJJrLzy0Ic1DJi3+ L6MWRIuUqqZKfctqK/lMhvWpC3NcvyRX08XOmwnX8iU9rukqgzayEa+ce1tTSnhzieYy zFFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=VyA8Vib0ptKsqgsXNtlJ8NybxoRCwvNTSMiKK3zxzVE=; b=J/b+w1QnUau5Cx+MASH7kKD71pfjSdn2oF8Gjc6oBND1jo8otOAQVo7sw1eCVnn/ok nBFEYJhMJ9HJ295cWX1QFJ2dyh/vsTbMYJyRek3OEsd62tucIrMLbY31VyX9tY9R+z5Y 7zI8Vkh8KJj1HnkjIYdXtPTzxz11qn4zHbZVsG5E+ouRu2AcsuIPd/Gdk+5lnuHOK/1J HAEghr3dTxknF2o0Go5/W17MU3V3Cz/foZClt4D6pWfbu5F1BlSm6xViouO9xXfLjd73 iSFhLOWU35oAqkmlVpr0YdLNGmbsJi1daz4bnuP6tpjGsvAogkg3poHzGR3T6vlk1Y7U KYow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oMobUdKW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y4si42094465pfq.222.2019.08.04.05.59.36; Sun, 04 Aug 2019 05:59:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oMobUdKW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726237AbfHDM7D (ORCPT + 99 others); Sun, 4 Aug 2019 08:59:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:43460 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726034AbfHDM7C (ORCPT ); Sun, 4 Aug 2019 08:59:02 -0400 Received: from localhost (unknown [193.47.165.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4B804206C1; Sun, 4 Aug 2019 12:59:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564923541; bh=vfQ5c7E4RyLpa5ot8AofSGWxzc5hrr2Zrq97933cUnM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oMobUdKWKkBQRn6k1Pno/ICxDpI2iFgTC8KZbp6kT9OEWf15ISumu57tVoMsJWSfK 7mj/cosRzrTOR/w/W3DToV2GPJ8lk8cn1YrT3u8eZLy8WiLDOD+AcrYIv9KmOM8TB3 NT1dbdPIOXif12FRyxS3Oc3x+sR8iKEOuoixnRWk= Date: Sun, 4 Aug 2019 15:58:58 +0300 From: Leon Romanovsky To: Chuhong Yuan Cc: Saeed Mahameed , "David S . Miller" , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] net/mlx5e: Use refcount_t for refcount Message-ID: <20190804125858.GJ4832@mtr-leonro.mtl.com> References: <20190802164828.20243-1-hslester96@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190802164828.20243-1-hslester96@gmail.com> User-Agent: Mutt/1.12.0 (2019-05-25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Aug 03, 2019 at 12:48:28AM +0800, Chuhong Yuan wrote: > refcount_t is better for reference counters since its > implementation can prevent overflows. > So convert atomic_t ref counters to refcount_t. I'm not thrilled to see those automatic conversion patches, especially for flows which can't overflow. There is nothing wrong in using atomic_t type of variable, do you have in mind flow which will cause to overflow? Thanks > > Signed-off-by: Chuhong Yuan > --- > Changes in v2: > - Add #include. > > drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c > index b9d4f4e19ff9..148b55c3db7a 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c > @@ -32,6 +32,7 @@ > > #include > #include > +#include > #include > #include > #include "mlx5_core.h" > @@ -48,7 +49,7 @@ struct mlx5_vxlan { > > struct mlx5_vxlan_port { > struct hlist_node hlist; > - atomic_t refcount; > + refcount_t refcount; > u16 udp_port; > }; > > @@ -113,7 +114,7 @@ int mlx5_vxlan_add_port(struct mlx5_vxlan *vxlan, u16 port) > > vxlanp = mlx5_vxlan_lookup_port(vxlan, port); > if (vxlanp) { > - atomic_inc(&vxlanp->refcount); > + refcount_inc(&vxlanp->refcount); > return 0; > } > > @@ -137,7 +138,7 @@ int mlx5_vxlan_add_port(struct mlx5_vxlan *vxlan, u16 port) > } > > vxlanp->udp_port = port; > - atomic_set(&vxlanp->refcount, 1); > + refcount_set(&vxlanp->refcount, 1); > > spin_lock_bh(&vxlan->lock); > hash_add(vxlan->htable, &vxlanp->hlist, port); > @@ -170,7 +171,7 @@ int mlx5_vxlan_del_port(struct mlx5_vxlan *vxlan, u16 port) > goto out_unlock; > } > > - if (atomic_dec_and_test(&vxlanp->refcount)) { > + if (refcount_dec_and_test(&vxlanp->refcount)) { > hash_del(&vxlanp->hlist); > remove = true; > } > -- > 2.20.1 >