public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: tj@kernel.org (Tejun Heo)
Subject: [PATCH] percpu-refcount: relax limit on percpu_ref_reinit()
Date: Wed, 19 Sep 2018 13:36:41 -0700	[thread overview]
Message-ID: <20180919203641.GD902964@devbig004.ftw2.facebook.com> (raw)
In-Reply-To: <20180919025148.GB20560@ming.t460p>

Hello, Ming.

On Wed, Sep 19, 2018@10:51:49AM +0800, Ming Lei wrote:
> > That doesn't make sense to me.  How is synchronize_rcu() gonna change
> > anything there?
> 
> As you saw in the new post, synchronize_rcu() isn't used for avoiding
> the race. Instead, it is done by grabbing one extra ref on atomic part.

This is layering violation.  It just isn't a good idea to depend on
percpu_ref internal implementation details like this.

> > 1. Callers of percpu_ref must not depend on what internal
> >    synchronization construct percpu_ref uses.  Again, percpu_ref
> >    doesn't even use regular RCU.
> > 
> > 2. If there is already an outer RCU protection around ref operation,
> >    that RCU critical section can and should be used for
> >    synchronization, not percpu_ref.
> 
> I guess the above doesn't apply any more because there isn't new 
> synchronize_rcu() introduced in my new post.

It still does.  The problem is that what you're doing creates
dependencies on percpu_ref's implementation details - how it
guarantees the mode transition visibility using what sort of
synchronization construct.

> > Right?  There isn't much wheel to reinvent here and using percpu_ref
> > for the above is likely already incorrect due to the different RCU
> > type being used.
> 
> No RCU story any more, :-)
> 
> It might work, but still a reinvented wheel since perpcu-refcount does
> provide same function. Not mention the inter-action between the two
> mechanism may have to be considered.

Why would the two independent mechanisms interact with each other?
What's problematic is entangling two mechanisms in an implementation
dependent way.

> Also there is still cost introduced in WRITER side, and the
> synchronize_rcu() often takes a bit long, especially there might be lots
> of namespaces, each need to run one synchronize_rcu(). We have learned
> lessons in converting to blk-mq for scsi, in which synchronize_rcu()
> introduces long delay in booting.

You're already paying that latency.  It's not like percpu_ref can make
it happen magically without paying the same cost.  You also can easily
overlay the two grace periods as the percpu_ref part can be
asynchronous (if you still care about it).  But, from what I've read
till now, it doesn't even look like you'd need to do anything with
percpu_ref if you all you need to do is shutting down issue of new
commands.

Thanks.

-- 
tejun

      reply	other threads:[~2018-09-19 20:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20180911000049.GB30977@ming.t460p>
     [not found] ` <20180911134836.GG1100574@devbig004.ftw2.facebook.com>
     [not found]   ` <20180911154540.GA10082@ming.t460p>
     [not found]     ` <20180911154959.GI1100574@devbig004.ftw2.facebook.com>
     [not found]       ` <20180911160532.GB10082@ming.t460p>
     [not found]         ` <20180911163032.GA2966370@devbig004.ftw2.facebook.com>
     [not found]           ` <20180911163443.GD10082@ming.t460p>
     [not found]             ` <20180911163856.GB2966370@devbig004.ftw2.facebook.com>
     [not found]               ` <20180912015247.GA12475@ming.t460p>
     [not found]                 ` <20180912155321.GE2966370@devbig004.ftw2.facebook.com>
2018-09-12 22:11                   ` [PATCH] percpu-refcount: relax limit on percpu_ref_reinit() Ming Lei
2018-09-18 12:49                     ` Tejun Heo
2018-09-19  2:51                       ` Ming Lei
2018-09-19 20:36                         ` Tejun Heo [this message]

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=20180919203641.GD902964@devbig004.ftw2.facebook.com \
    --to=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