mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Tejun Heo <tj@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Jianchao Wang <jianchao.w.wang@oracle.com>,
	Kent Overstreet <kent.overstreet@gmail.com>,
	linux-block@vger.kernel.org
Subject: Re: [PATCH] percpu-refcount: relax limit on percpu_ref_reinit()
Date: Tue, 11 Sep 2018 08:00:50 +0800	[thread overview]
Message-ID: <20180911000049.GB30977@ming.t460p> (raw)
In-Reply-To: <20180910164920.GE1100574@devbig004.ftw2.facebook.com>

Hi Tejun,

On Mon, Sep 10, 2018 at 09:49:20AM -0700, Tejun Heo wrote:
> Hello, Ming.
> 
> On Sun, Sep 09, 2018 at 08:58:24PM +0800, Ming Lei wrote:
> > @@ -196,15 +197,6 @@ static void __percpu_ref_switch_to_percpu(struct percpu_ref *ref)
> >  
> >  	atomic_long_add(PERCPU_COUNT_BIAS, &ref->count);
> >  
> > -	/*
> > -	 * Restore per-cpu operation.  smp_store_release() is paired
> > -	 * with READ_ONCE() in __ref_is_percpu() and guarantees that the
> > -	 * zeroing is visible to all percpu accesses which can see the
> > -	 * following __PERCPU_REF_ATOMIC clearing.
> > -	 */
> 
> So, while the location of percpu counter resetting moved, the pairing
> of store_release and READ_ONCE is still required to ensure that the
> clearing is visible before the switching to percpu mode becomes
> effective.  Can you please rephrase and keep the above comment?

OK, will do it in V2.

> 
> > -	for_each_possible_cpu(cpu)
> > -		*per_cpu_ptr(percpu_count, cpu) = 0;
> > -
> >  	smp_store_release(&ref->percpu_count_ptr,
> >  			  ref->percpu_count_ptr & ~__PERCPU_REF_ATOMIC);
> >  }
> ...
> > @@ -357,10 +349,11 @@ EXPORT_SYMBOL_GPL(percpu_ref_kill_and_confirm);
> >  void percpu_ref_reinit(struct percpu_ref *ref)
> >  {
> >  	unsigned long flags;
> > +	unsigned long __percpu *percpu_count;
> >  
> >  	spin_lock_irqsave(&percpu_ref_switch_lock, flags);
> >  
> > -	WARN_ON_ONCE(!percpu_ref_is_zero(ref));
> > +	WARN_ON_ONCE(__ref_is_percpu(ref, &percpu_count));
> 
> Can you elaborate this part?  This doesn't seem required for the
> described change.  Why is it part of the patch?

The motivation of this patch is to avoid the above warning and allow
the ref to switch back to percpu mode without dropping to zero.

That is why the check has to be changed to the above way.


Thanks,
Ming

  reply	other threads:[~2018-09-11  0:01 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-09 12:58 Ming Lei
2018-09-09 18:46 ` Bart Van Assche
2018-09-09 23:59   ` Ming Lei
2018-09-10  1:40 ` jianchao.wang
2018-09-10 16:11   ` Ming Lei
2018-09-11  1:48     ` jianchao.wang
2018-09-11  4:03       ` Ming Lei
2018-09-11  4:40         ` jianchao.wang
2018-09-11  8:20           ` Ming Lei
2018-09-11 14:22             ` jianchao.wang
2018-09-11 13:44           ` Tejun Heo
2018-09-11 14:13             ` jianchao.wang
2018-09-10  1:54 ` jianchao.wang
2018-09-10 16:49 ` Tejun Heo
2018-09-11  0:00   ` Ming Lei [this message]
2018-09-11 13:48     ` Tejun Heo
2018-09-11 15:45       ` Ming Lei
2018-09-11 15:49         ` Tejun Heo
2018-09-11 16:05           ` Ming Lei
2018-09-11 16:30             ` Tejun Heo
2018-09-11 16:34               ` Ming Lei
2018-09-11 16:38                 ` Tejun Heo
2018-09-12  1:52                   ` Ming Lei
2018-09-12 15:53                     ` Tejun Heo
2018-09-12 22:11                       ` Ming Lei
2018-09-18 12:49                         ` Tejun Heo
2018-09-19  2:51                           ` Ming Lei
2018-09-19 20:36                             ` Tejun Heo
2018-09-18  3:21 ` jianchao.wang
2018-09-18  7:34   ` Ming Lei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180911000049.GB30977@ming.t460p \
    --to=ming.lei@redhat.com \
    --cc=jianchao.w.wang@oracle.com \
    --cc=kent.overstreet@gmail.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®