Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp3712149ybh; Tue, 6 Aug 2019 00:01:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzsrsjHMK03bMXdexMvgX4hsqx3QFJAon3Cl9kHtCo+A15P7K/1GWv1mq+rppgNPOOZT3Co X-Received: by 2002:a63:c013:: with SMTP id h19mr1726888pgg.108.1565074900220; Tue, 06 Aug 2019 00:01:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565074900; cv=none; d=google.com; s=arc-20160816; b=XTFI7mJfH3tk9n7gkKztDyGeTj8iOmr6tABdqpu75+8W1unZ5SfCMDac5iPz75Uf/T 0+bYJV0QmwLZIlMDDrRjoQHRlkgPpD9oS1yofOXfc80kaTFgeAlQEkOhd0C7qZ9Z3UI3 MvYZIu3xK0enXeEyxridNqljtmz7/a3IC5DmbO33dZUfLrj1oDtlJD3B6dkoiF9pmD3g TQWZXlGnb7ydg0AokBWs4jfrY/6KhKJwlu7tnwijwlYgFm0SEWrZsGOp2HtRDj4Eb9Qa 64Jv4fXSHFydg56kG5A54pV05qTPWgT8NT6zR9jObte47Qt0nw2ZFTZaM1a54L6pjhhT 9b/Q== 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=NHXSXNOhcukgOBIw2+t1RdqqbL8a+wF17UGBnsCwGWw=; b=AJU6pIgkZnCLZ/VQNdBC2z4XKFWLAw4eAesEkagz3ntGCAji8kRcnHMUiePEu34l0Y +m/pRlWrK6cKoAdihgRwdYGp0BWI7ZtCobsTUAK7SxvOLOB34NPd+dW1I+iIsSf9iZNf CHTcuE6cvRd7QuVnSgs+ybijZ4z48/7Sl7wZzbdCNn6JrsKhsagikgsL8KTSt3S0g1w9 belW13YY1n/jCtf/XqlT0W7i8FHyHe9WNrstl8ZKAbYuZATWmxsZArmE6wrGK35kVgQN PeYSviSgYF0SAdYkXrY8Y2PANdQoobg3kYoMxI3Y08TK4kQZIYztnTTSkBpxAwQzPlZV ws5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="uEDO/vfE"; 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 a14si45752691pfo.37.2019.08.06.00.01.24; Tue, 06 Aug 2019 00:01:40 -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="uEDO/vfE"; 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 S1731994AbfHFHAD (ORCPT + 99 others); Tue, 6 Aug 2019 03:00:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:33218 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731735AbfHFHAD (ORCPT ); Tue, 6 Aug 2019 03:00:03 -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 5CA4D20B1F; Tue, 6 Aug 2019 07:00:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565074802; bh=NHXSXNOhcukgOBIw2+t1RdqqbL8a+wF17UGBnsCwGWw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uEDO/vfE69v6yPrGRGjKu0hop5bMB1qrJSxijrDd6TYv552kGPvGsYu2myE/4d05Y 99L1C/Htis4Bvv+AtLMz/0+vSJflB3nyYp5hLzutbBA8jP9x1n6U2UfBSOWKvbWd+O TdTpUO//vyfvLUrRDF1gL44fMSAi6dsKQpNZ+KeQ= Date: Tue, 6 Aug 2019 09:59:58 +0300 From: Leon Romanovsky To: Saeed Mahameed Cc: "hslester96@gmail.com" , "davem@davemloft.net" , "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: <20190806065958.GQ4832@mtr-leonro.mtl.com> References: <20190802164828.20243-1-hslester96@gmail.com> <20190804125858.GJ4832@mtr-leonro.mtl.com> <20190805061320.GN4832@mtr-leonro.mtl.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Mon, Aug 05, 2019 at 08:06:36PM +0000, Saeed Mahameed wrote: > On Mon, 2019-08-05 at 14:55 +0800, Chuhong Yuan wrote: > > On Mon, Aug 5, 2019 at 2:13 PM Leon Romanovsky > > wrote: > > > On Sun, Aug 04, 2019 at 10:44:47PM +0800, Chuhong Yuan wrote: > > > > On Sun, Aug 4, 2019 at 8:59 PM Leon Romanovsky > > > > wrote: > > > > > 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 > > > > > > > > I have to say that these patches are not done automatically... > > > > Only the detection of problems is done by a script. > > > > All conversions are done manually. > > > > > > Even worse, you need to audit usage of atomic_t and replace there > > > it can overflow. > > > > > > > I am not sure whether the flow can cause an overflow. > > > > > > It can't. > > > > > > > But I think it is hard to ensure that a data path is impossible > > > > to have problems in any cases including being attacked. > > > > > > It is not data path, and I doubt that such conversion will be > > > allowed > > > in data paths without proving that no performance regression is > > > introduced. > > > > So I think it is better to do this minor revision to prevent > > > > potential risk, just like we have done in mlx5/core/cq.c. > > > > > > mlx5/core/cq.c is a different beast, refcount there means actual > > > users > > > of CQ which are limited in SW, so in theory, they have potential > > > to be overflown. > > > > > > It is not the case here, there your are adding new port. > > > There is nothing wrong with atomic_t. > > > > > > > Thanks for your explanation! > > I will pay attention to this point in similar cases. > > But it seems that the semantic of refcount is not always as clear as > > here... > > > > Semantically speaking, there is nothing wrong with moving to refcount_t > in the case of vxlan ports.. it also seems more accurate and will > provide the type protection, even if it is not necessary. Please let me > know what is the verdict here, i can apply this patch to net-next-mlx5. There is no verdict here, it is up to you., if you like code churn, go for it. Thanks > > Thanks, > Saeed.