Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp4436187ybh; Tue, 6 Aug 2019 11:37:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqzvDtoTT3tLClZs6Kyh9qPj/GKp1RexljAd4j5CkIs4LWarCHXAyRszA844AJdCTcXXiaBq X-Received: by 2002:a63:fe17:: with SMTP id p23mr4232626pgh.103.1565116634094; Tue, 06 Aug 2019 11:37:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565116634; cv=none; d=google.com; s=arc-20160816; b=oSIquFEAMfHHN4bWjbcJZZEyblsGforzswMzBfzgr/E3fBCzNyA6WfUW9M2ZDnn0rU Rg8VQP8y1PhSfHPTPwgb9bxkUn8Gzq2VfG3Q5ocqZ7wEBiq7i9w2RdkKNZKdFkhA9jkm YAy42RASbXtwqMvZWT14OEgie+MXHpDL5R8NTh4a63smFDJ8msp6Gr7/OCKhq+5ltP4a d0KeftN4TC5AaiWh4I04RZbN6QZ4oKwa0i+Ye+/yxs9uMNvzKyBiVgu+w4Pq7pfANIw1 twZgoqR0tSFaO+tvi0ahV8VEcvbbkYszqOc5Ia7txBBrIgF46fgwQX5kp9Da5e0oCx9G /KtA== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=JtINiPTTaxXs89drKGXiMpthv7Xf3LRZukSbKo8R/Vs=; b=IDtrIOYSGGh6neOKN6dskPal83+gmMdmmlmchTpUMC/iZa8Po6fUh4HzX0h5ws2lD7 5VCQyk3mvrDV7dgfO18wMieogxJvX0s2ndRGrWe00DBBy6ODtdibnZfSawjWUjfvTSXB uKfxU1FWLOadFVxv4MmJWTp0Vopt63JGQEtOzyNeyG/buM7q5C8XDURHL7uxBg3sj1z8 N8wnjjC6YTv7mD1317Uah7txxqy0qumiB4iVIqpv5D3R5RISPSUEJ2jetSMwBsqFRnXC lhQ376yrAoGOUhHwNEZ+gksP+3b+JBE+7JJIPBXBo7CjYrY2QOgZ0/WMaD5D16kFMQES Nclg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=NaCiCQSH; 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.36.57; Tue, 06 Aug 2019 11:37:14 -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=NaCiCQSH; 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 S1732820AbfHFSgH (ORCPT + 99 others); Tue, 6 Aug 2019 14:36:07 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:38884 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728836AbfHFSgH (ORCPT ); Tue, 6 Aug 2019 14:36:07 -0400 Received: by mail-qt1-f196.google.com with SMTP id n11so85568683qtl.5 for ; Tue, 06 Aug 2019 11:36:06 -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:content-transfer-encoding:in-reply-to :user-agent; bh=JtINiPTTaxXs89drKGXiMpthv7Xf3LRZukSbKo8R/Vs=; b=NaCiCQSHxFDb4r8ia6jN1dSySpTaDWH0hxU7dWGojqAwyO4Vi0i4fKhIVVC/XM7aON 6edg9wk+4SBflCPw75uG5f125yoLwujQoBhnJmxT2OI9yk82hvv45lrTqZQlX+xtA3yo Z0OXDCLLJSs8VsujMGl3gDEitD8HjX9/u2jz6MMHzYEikkea+dz2lXYbp6+ze3esYNIw +IG+ApkkeIGIlMKYpubK2xac5Hkabx9KufnoB9IzsBVoQfe+5U0wD2pHc4DxzXOIXOtb oBaGBQAmz5SQHjuspem9LnAErsMZmJ0jgoMlCzdwW7ogd1zXVEibDtdiB1NCvS8a1Gzd ew6w== 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:content-transfer-encoding :in-reply-to:user-agent; bh=JtINiPTTaxXs89drKGXiMpthv7Xf3LRZukSbKo8R/Vs=; b=gCR7LIjq9QKUZ9RL5W51jvks5C2QuUW2VTp/6DoyH+Tnh4/JN17XgQe7lP2C2DTMbv uncvk68fW+EPgEs1YsZiXCFp1U7iDxnPKxeWu92bwkgf1T8u4qiwZrIVip8CB4T7gvgs rdfv3dq9ggHRUiBqjVbeUcZO9KTQeqK0yf5MW7aFAZ97NmWkwdRu+Q+SZdEevuvJUnY1 O0+Iuh3smpObUjtBGumthZN6FPXpf+xFW/8l28AkwB7G78M3dg0wcYXDFME8vwzCGP1s qZdBbfIvghuV0mf4FNLnzDeDbGW/jkCbDssDoN2ERlPQQ+EfLbw4kJQdpuLVnXpmtXMl CMdg== X-Gm-Message-State: APjAAAURSqrKGg3fBkwH0cOwPjb5CzwdNQKkfs58XdtJ5UboqoMSO0yq NdDorI2DsMvd2BRnsX3+ZvSSXg== X-Received: by 2002:a0c:ffc5:: with SMTP id h5mr4478918qvv.43.1565116566370; Tue, 06 Aug 2019 11:36:06 -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 r36sm48135303qte.71.2019.08.06.11.36.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Aug 2019 11:36:05 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1hv4JY-0004Lm-Pm; Tue, 06 Aug 2019 15:36:04 -0300 Date: Tue, 6 Aug 2019 15:36:04 -0300 From: Jason Gunthorpe To: Chuhong Yuan Cc: Saeed Mahameed , "linux-kernel@vger.kernel.org" , "davem@davemloft.net" , Tariq Toukan , "linux-rdma@vger.kernel.org" , "netdev@vger.kernel.org" Subject: Re: [PATCH] net/mlx4_core: Use refcount_t for refcount Message-ID: <20190806183604.GQ11627@ziepe.ca> References: <20190802121020.1181-1-hslester96@gmail.com> <47bb83d0111f1132bbf532c16be483c5efbe839f.camel@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 Sat, Aug 03, 2019 at 10:42:31AM +0800, Chuhong Yuan wrote: > Saeed Mahameed 于2019年8月3日周六 上午2:38写道: > > > > On Sat, 2019-08-03 at 00:10 +0800, Chuhong Yuan wrote: > > > Chuhong Yuan 于2019年8月2日周五 下午8:10写道: > > > > refcount_t is better for reference counters since its > > > > implementation can prevent overflows. > > > > So convert atomic_t ref counters to refcount_t. > > > > > > > > Also convert refcount from 0-based to 1-based. > > > > > > > > > > It seems that directly converting refcount from 0-based > > > to 1-based is infeasible. > > > I am sorry for this mistake. > > > > Just curious, why not keep it 0 based and use refcout_t ? > > > > refcount API should have the same semantics as atomic_t API .. no ? > > refcount API will warn when increase a 0 refcount. > It regards this as a use-after-free. If this causes failures then the code is not doing atomic as a refcount properly anyhow.. There are some cases where the atomic refcount is just a imprecise debugging aide. Jason