Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp4438646ybh; Tue, 6 Aug 2019 11:40:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxE01UaPCNpSBEGg0vq4EB1KFQWCFTPgCqdsYdH1CXdGwpgH3Uw3jx/e3mSfN2Sb6YeRnO9 X-Received: by 2002:a63:ed55:: with SMTP id m21mr4263293pgk.343.1565116811933; Tue, 06 Aug 2019 11:40:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565116811; cv=none; d=google.com; s=arc-20160816; b=e0mqMgqWiCsTblZ1aMFHK9/cIBtTNzvh9ohGXPbWFgGtBGFiY7gNxIukRzxLQhA5c7 jGeWUSX7rSRxlXAdrjHzNCcHAEyIiZbKDb/JozCF9ZtSbxZKfWBjGGSpVTHe50Ax3uwt n6ii1yfet51iscCZs8hDfZq96B5mGjiv1rNlW0ylq0Shf9xPYogVKKqx6SjUxRGdtSy5 BE8F4V+d/bRAHBmfjSpXokkbSjWJfuINtaHpUapCrDsxAQMA/tUx/3oHExxjX3qnKazd SH3wcMXI1RROlkvH+j9kfqOHP5fD2bbhJDtQijy5A0s6gTQLmb4epvufZBXutOUU2gHp y9TQ== 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=t0FZaLhTQo8X5m9sJH3jai3ugnitzUTUhXxicv7YDk8=; b=Mi6dpbv5yWQuJ7STZwiQ2HIwJlJRM57SYnQAN/CC2Nb8ktWUt4RD/5yJ1xYug+Z64B SR68rUhAXe3ZGI/xjIZKl+/iLqWE9muwpQS7J+BNEZ2pUnPKEXuNYcu9gIL5/rghoXsG PanYHcFkzypS/XEwlKYjoPE7YF+Fg3BctI8JlBoyOiuFQ4LIKS/t9P1jpJP7Yvp8nzr1 s9G80Q8/Ge7hVlvzSeu20Rq1xU7oK+0FhftoOrO+JDtLIT4pJGJxSBn8jfE+bEb3l5rZ sNsmwgO1pXTzp3QcWPBXoISkT1ZRakO63StLN6oHvadUUzD6TxpWh1Z+wiV7yPIvss7j T3Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=DzULNXQE; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j4si34500524pfa.141.2019.08.06.11.39.55; Tue, 06 Aug 2019 11:40:11 -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=@ziepe.ca header.s=google header.b=DzULNXQE; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731692AbfHFSiY (ORCPT + 99 others); Tue, 6 Aug 2019 14:38:24 -0400 Received: from mail-qk1-f194.google.com ([209.85.222.194]:40167 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728836AbfHFSiX (ORCPT ); Tue, 6 Aug 2019 14:38:23 -0400 Received: by mail-qk1-f194.google.com with SMTP id s145so63719572qke.7 for ; Tue, 06 Aug 2019 11:38:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=t0FZaLhTQo8X5m9sJH3jai3ugnitzUTUhXxicv7YDk8=; b=DzULNXQEJNZwg345/aqx14lziCowwmZZ111AycKfFi5XM1I301Ud8rtZZt1wgeF5Pl UU6wbBcMywCdYe2A00lP3rFFRmRHkverVEso5c/xpaLDR8J1XMlG7KG83Vs1L8jQdWhi o82MwcEtBdtL0DJveIufG1vt+LkvzW6Fe5LtJGtcF3gNTJmIummsJdbcVlAV3fyEpO46 6VVPQLT6TIe9NED3IcRJk8e+lTOltkPSvmuu6jEvNkJHdRpRrIsHpypmQJKpFVqidOGc 9UEGDh2qogUsM6aedOr0W515t9WTNWR1c68j4XvUSFM/riUM3zuVVTRliMQEO0XOPTUX EA3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=t0FZaLhTQo8X5m9sJH3jai3ugnitzUTUhXxicv7YDk8=; b=lwLXDMjU9qH2IO4rG6nILO5vHslz30Cd+u38UNt2qGO8i2FV9QUZyQj2QJuZxn3P/p VfoybtHNOCrgXbEH2lsu1B8K93iy3PDoNqeHrCXMA+DH0jN3FBvGa4OPQLjwFYMLEDyz atAODlhR/JlM2yLp/Av0+AEV6/DP6i+bSA3CSbLu5l4wWRpmJxV7vHHMZwyqfxO+RKhw hSnu6QHmcxzgSOKdYBxZCwxk8pjHEsfMpH/ugv8o/Iv0eI+IiC+h2EPdID0f8AkQG5lX WX0nPd3DmdteUrQVIEThbyIol8GKHhFesn90SaFExWshm//TI3JUMyCEUki5+H+Q5vtY qcmg== X-Gm-Message-State: APjAAAWTgXWtjWkohGcCYimjthqqT0BdAQmSPCACbW3n3Qzy7EbnKUBj cyY6hRi9OfY9tbrNCpCUyPQ5JQ== X-Received: by 2002:a05:620a:124f:: with SMTP id a15mr4630085qkl.173.1565116702615; Tue, 06 Aug 2019 11:38:22 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-55-100.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.55.100]) by smtp.gmail.com with ESMTPSA id d141sm37790010qke.3.2019.08.06.11.38.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Aug 2019 11:38:21 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1hv4Ll-0004NN-6J; Tue, 06 Aug 2019 15:38:21 -0300 Date: Tue, 6 Aug 2019 15:38:21 -0300 From: Jason Gunthorpe To: Leon Romanovsky Cc: Saeed Mahameed , "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: <20190806183821.GR11627@ziepe.ca> References: <20190802164828.20243-1-hslester96@gmail.com> <20190804125858.GJ4832@mtr-leonro.mtl.com> <20190805061320.GN4832@mtr-leonro.mtl.com> <20190806065958.GQ4832@mtr-leonro.mtl.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190806065958.GQ4832@mtr-leonro.mtl.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 06, 2019 at 09:59:58AM +0300, Leon Romanovsky wrote: > 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. IMHO CONFIG_REFCOUNT_FULL is a valuable enough reason to not open code with an atomic even if overflow is not possible. Races resulting in incrs on 0 refcounts is a common enough mistake. Jason