Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp659644ybh; Sat, 3 Aug 2019 07:10:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqyuE2+iv5j2MA7tCzrdFgfctV/yhW2Ucb+P8wY5dlAy8VcKLWRch5/dNlrnqUdUUEnESjMR X-Received: by 2002:a63:8ac3:: with SMTP id y186mr128428933pgd.13.1564841442095; Sat, 03 Aug 2019 07:10:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564841442; cv=none; d=google.com; s=arc-20160816; b=KarDeRMxnwJ8H5c1jNoT5lGkIAvD5CTuMIyPyCyZwrDxnSWV8N1SBjpq3Vh1GQi2Mb gwK55LvYQahENX/DHTQJdurPaWyb8OkZ6cEdyKSeyE8o7tvUmxWGhE5C1f0b7UOQTtTS FdyZH4y8eoIQww0HLrOnkLqU4oKxXDWXaY+1sg7YgYwCCmf2atf6BToKXy+0XqpDh/zc FxnMi6yH9QEOPAn8zaSeMh8PxPG7p/Jnym9+NRc+Dr5i75g3WVM4MmuAfny62ath74jd /6WILCIDU2qiwxAcjpub3U6HoG0f9eqxrPHhvPY005s44qDb4vWw0cDhvbnxo9cw9hEN ilJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=C9LPjwmpCbhIG9fa404OYjDh216Z1i9HjOGON92MWYk=; b=M6MLTjSnT7kbgs0VfO/XWmgqV8bS6I00ARt+2juDSzbT6Te0kVol8WmWt4g+59n0Os u6Ko/Yy3uFrp0R2MRMDLBlQiN9/sYytug6YcnKQYOtQI6smRX4hLbv03UOHjJeV2FDHq gRa9HexKpeWLyeHjkPLTRoibFyh6DPTR3b6WfCM9iNPEU61fiOA423tYl8QFRkfKNZzK rEKAOXejBYmc/DLfTRV1OGlHDkfcjt7GNvvEyysjW+0ta6cMDBecAT69M2Q+cqX0ku4D oCZKwQ8ARbUv72A4V635CStZO9Njdb3X/MSOx/7irNrdFSQMlCx7H/1GAWlqBQpxm5D1 wl7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Iqz2OamA; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 14si40861647pgy.255.2019.08.03.07.10.26; Sat, 03 Aug 2019 07:10:42 -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=@gmail.com header.s=20161025 header.b=Iqz2OamA; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394936AbfHBO1z (ORCPT + 99 others); Fri, 2 Aug 2019 10:27:55 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:40506 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730999AbfHBO1y (ORCPT ); Fri, 2 Aug 2019 10:27:54 -0400 Received: by mail-ed1-f67.google.com with SMTP id k8so72525233eds.7; Fri, 02 Aug 2019 07:27:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=C9LPjwmpCbhIG9fa404OYjDh216Z1i9HjOGON92MWYk=; b=Iqz2OamAaYolMP2nQ42QOA+OqHFEvmp+/aHWq5wTA0vcNcHZzeEc0ykVqbJfNgQYbQ wHFuVsEDpuuPoeNMnJJcaAaYj2y43eyKCNk3NkxakxTXkwzNzp1hKPTDZX1JjICdNQPd GS9QwXTdV92L8zl/BcOHze2ejPClmNiknhHIqDYNQZGQzKF+e5TxQoWvQNirqTIZW+wH P20M2Tvxuc5JCJ+H5KsXYIhJZ7icjDGLzc16jOeYzOu3RWJBAWqY506d5i3gxsGh3GfZ /zUowVXzWV4SiT894PKjJovd8YteDxA9COu/P10KC7n4J2efS94S27kvA82fhxX0tGYU /CRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=C9LPjwmpCbhIG9fa404OYjDh216Z1i9HjOGON92MWYk=; b=Yshgt4rROfcAH8OvwuCqR3mqY0/FEJDhUnnY0JHd4Jlhjh5LEDavqeAkf+Mj2+tj0I UMFjN5tD58BpvcKqIw1SH7rUpTldH+ugAnpjaOILj6YMRyPDmd3k2/LeOc96lWqQ1PGe k07VAg3fHILZKIUcF8GVEtc1gPlJcF/Zs52Nu0wDI/XZiDR2rOZqFnGWn+RQl1wQmqQA v69XeyKGZhn5OY5bjNhLzMnUNXdiF3wFj3vW2P6q9FgMD8gD2+ZvKzza+Ig2zfNpdJAy Mcuty2vdZ3S63Vfrxlob51roQY1kuX3tN9y8O1A6U064XbfOE2ySuHl5/MVpwXavgUTN sCVw== X-Gm-Message-State: APjAAAXLc0toG00WnYFi/Rc8OAqxuE2SB5AvEpLYTdQnmBd7pSC+0sNz DOl4fzQbnKNvOXribGBC3hEnqH1tOYo6wAvudgE= X-Received: by 2002:a05:6402:896:: with SMTP id e22mr115658449edy.202.1564756073161; Fri, 02 Aug 2019 07:27:53 -0700 (PDT) MIME-Version: 1.0 References: <20190802083541.12602-1-hslester96@gmail.com> In-Reply-To: From: Chuhong Yuan Date: Fri, 2 Aug 2019 22:27:42 +0800 Message-ID: Subject: Re: [PATCH v2 1/2] cxgb4: sched: Use refcount_t for refcount To: Willem de Bruijn Cc: Vishal Kulkarni , "David S . Miller" , Network Development , linux-kernel Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Willem de Bruijn =E4=BA=8E2019=E5=B9=B48= =E6=9C=882=E6=97=A5=E5=91=A8=E4=BA=94 =E4=B8=8B=E5=8D=889:40=E5=86=99=E9=81= =93=EF=BC=9A > > On Fri, Aug 2, 2019 at 4:36 AM 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. > > > > Signed-off-by: Chuhong Yuan > > --- > > Changes in v2: > > - Convert refcount from 0-base to 1-base. > > This changes the initial value from 0 to 1, but does not change the > release condition. So this introduces an accounting bug? I have noticed this problem and have checked other files which use refcount= _t. I find although the refcounts are 1-based, they still use refcount_dec_and_test() to check whether the resource should be released. One example is drivers/char/mspec.c. Therefore I think this is okay and do not change the release condition.