From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.4 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14023C31E40 for ; Tue, 6 Aug 2019 18:36:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D8BE42086D for ; Tue, 6 Aug 2019 18:36:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="NaCiCQSH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733179AbfHFSgH (ORCPT ); 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-Google-Smtp-Source: APXvYqwy1L8dEpY8EmVTZsHO6MDZHBCEi1r8Z1tUlIX+of3znd+xvWIZm+zyAOK4Tvk+C14HehfEhA== 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