Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2440187ybv; Fri, 21 Feb 2020 15:58:05 -0800 (PST) X-Google-Smtp-Source: APXvYqzixqXODvDITqdozdpS1VklF7bRsH9taekNdxTTncDzGtmlWUpW7GtTyoyWhswnQL4PhWZu X-Received: by 2002:a05:6830:1d59:: with SMTP id p25mr31209477oth.308.1582329485798; Fri, 21 Feb 2020 15:58:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582329485; cv=none; d=google.com; s=arc-20160816; b=tJ3V5fCzcJbzFCprhouhwnMxJcE0bZ+MfhNx9ZgcMSqi98r/6oZmeN71Hd85xjooMa QYWs2qYXxKa/kH8dvdcVBd/NNf/foKdtpGT7YZY6gcedpieA0Tu3ywF2SIB1+oSZJpu2 B5q7sPxbgMMGDc2p6Jo0Fzc5dGvDmuPkI+e2tKd45N3x7VQwtHsB3eTWb5ZYOB7p+SMb YXFtNSSgdChTjOB/gfAV9ki2uxgok+7NTBoyP+uTdRtZgxF/64gp1eSU2CEKLIodIO4A YHkjWI3QpuXSKfXQJA2ujksJzz/wouc2F9rrS4LWJac4nEg3Kg5MUTDxCD6Eo0rEP7Os Gidg== 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; bh=BAn9r0dyXNqEajiUKkhhIZJ15iGkDwS6O3yo74a0yZs=; b=Kvgi1OVgOb0vYs8i3oXiIj2Rx0TLV6WIBnUFvmEJrARKbZtrE3893hGUfeURkXpAhY 6cjSjKx7lr+2eJwRrSX+q/OgmHfWheOhnd89RtQuS3zEFdlXsUZ3oYUN1yd4z03+Cu0y 4/J2yjnOUvk9Xt4abqsKMKOEn7O3pzKDcvO13om+U9qjqjRctAgREfLb51PykRxl09k6 /gNxY8PQtc3RP3Iwsn7utR0gD0C6cxJ4Qr0mET4HBU2IOytgjSTNZlwJX+eIl4zKkFNS crHtkxsqqXcld+8HBU0N96F5cRKM9xYCJMzpoau67d2Kar60jMHfZCMkNBpurELhg0t3 fkBw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 a14si2552349otk.2.2020.02.21.15.57.54; Fri, 21 Feb 2020 15:58:05 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729757AbgBUX4b (ORCPT + 99 others); Fri, 21 Feb 2020 18:56:31 -0500 Received: from mail-qv1-f65.google.com ([209.85.219.65]:46179 "EHLO mail-qv1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726802AbgBUX4b (ORCPT ); Fri, 21 Feb 2020 18:56:31 -0500 Received: by mail-qv1-f65.google.com with SMTP id y2so1735469qvu.13 for ; Fri, 21 Feb 2020 15:56:30 -0800 (PST) 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=BAn9r0dyXNqEajiUKkhhIZJ15iGkDwS6O3yo74a0yZs=; b=SHQ2ERJ6RmCOgsUTQn82gnSvL0VCirvt9BO8bbvliENCqe05IJiYaPUOqSSpObW/V6 dETFLhGbEFLb+ImeTn7k9uhxuAh4bofyNvHgfUmtYO5BNYtbvKG/hTcjx2rTB8sOtpx1 Pppxh82WMM5/xF2a7hloRK+5R72D1Vo9eMVhLUQBXVBHKh77X2rQMHQykJbXSEPmk8Rp DWnhHwLjWnmZ7sHGIW9SJ5uaOIabE4DNw6ALAPklEz51z2NWEQjdORQe3aRyXpuXsjfB Jjx1AXsBhtR7t1Le0WtCk2XmpZwFRFWmb8oC03oK3YdwYfK53GJIsYeIL4eNiU4c9fTR Uqpw== X-Gm-Message-State: APjAAAWOw2bF3nqrV+aPvYsLf4bSCJdfK3tDy8fxaUl/cou3W7H04P7y /BrsxJpXXziZ+xaALBUKU5c= X-Received: by 2002:a05:6214:1634:: with SMTP id e20mr32658741qvw.205.1582329389941; Fri, 21 Feb 2020 15:56:29 -0800 (PST) Received: from dennisz-mbp.dhcp.thefacebook.com ([2620:10d:c091:500::dcfd]) by smtp.gmail.com with ESMTPSA id g11sm2346901qtc.48.2020.02.21.15.56.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Feb 2020 15:56:29 -0800 (PST) Date: Fri, 21 Feb 2020 18:56:27 -0500 From: Dennis Zhou To: ira.weiny@intel.com Cc: linux-kernel@vger.kernel.org, Petr Mladek , Tejun Heo , Dennis Zhou , Thomas Gleixner , Greg Kroah-Hartman , Roman Gushchin , Sakari Ailus Subject: Re: [RESEND PATCH] percpu_ref: Fix comment regarding percpu_ref_init flags Message-ID: <20200221235627.GA59628@dennisz-mbp.dhcp.thefacebook.com> References: <20200221231607.12782-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200221231607.12782-1-ira.weiny@intel.com> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ira, On Fri, Feb 21, 2020 at 03:16:07PM -0800, ira.weiny@intel.com wrote: > From: Ira Weiny > > The comment for percpu_ref_init() implies that using > PERCPU_REF_ALLOW_REINIT will cause the refcount to start at 0. But > this is not true. PERCPU_REF_ALLOW_REINIT starts the count at 1 as > if the flags were zero. Add this fact to the kernel doc comment. > > Signed-off-by: Ira Weiny > --- > RESEND: > Add more people on the CC list to see if I'm wrong here. > https://lore.kernel.org/lkml/20200206042810.GA29917@iweiny-DESK2.sc.intel.com/ > --- > > lib/percpu-refcount.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c > index 4f6c6ebbbbde..48d7fcff70b6 100644 > --- a/lib/percpu-refcount.c > +++ b/lib/percpu-refcount.c > @@ -50,9 +50,9 @@ static unsigned long __percpu *percpu_count_ptr(struct percpu_ref *ref) > * @flags: PERCPU_REF_INIT_* flags > * @gfp: allocation mask to use > * > - * Initializes @ref. If @flags is zero, @ref starts in percpu mode with a > - * refcount of 1; analagous to atomic_long_set(ref, 1). See the > - * definitions of PERCPU_REF_INIT_* flags for flag behaviors. > + * Initializes @ref. If @flags is zero or PERCPU_REF_ALLOW_REINIT, @ref starts > + * in percpu mode with a refcount of 1; analagous to atomic_long_set(ref, 1). > + * See the definitions of PERCPU_REF_INIT_* flags for flag behaviors. Yeah. Prior we had both PERCPU_REF_INIT_ATOMIC and PERCPU_REF_INIT_DEAD with the latter implying the former. So 0 meant percpu and the others meant atomic. With PERCPU_REF_ALLOW_REINIT, it's probably easier to understand by saying if neither PERCPU_REF_INIT_ATOMIC or PERCPU_REF_INIT_DEAD is set, it starts out in percpu mode which is mentioned in the comments where the flags are defined. It's not great having implied flags, but it's worked so far. Also, it's not quite analagous to atomic_long_set(ref, 1) as there is a bias to prevent prematurely hitting 0. I can take this and massage the wording a bit. > * > * Note that @release must not sleep - it may potentially be called from RCU > * callback context by percpu_ref_kill(). > -- > 2.21.0 > Thanks, Dennis