All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Ming Lei <ming.lei@redhat.com>
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: Wed, 12 Sep 2018 08:53:21 -0700	[thread overview]
Message-ID: <20180912155321.GE2966370@devbig004.ftw2.facebook.com> (raw)
In-Reply-To: <20180912015247.GA12475@ming.t460p>

Hello,

On Wed, Sep 12, 2018 at 09:52:48AM +0800, Ming Lei wrote:
> > If you killed and waited until kill finished, you should be able to
> > re-init.  Is it that you want to kill but abort killing in some cases?
> 
> Yes, it can be re-init, just with the warning of WARN_ON_ONCE(!percpu_ref_is_zero(ref)).

We can add another interface but it can't be re _init_.

> > How do you then handle the race against release?  Can you please
> 
> The .release is only called at atomic mode, and once we switch to
> percpu mode, .release can't be called at all. Or I may not follow you,
> could you explain a bit the race with release?

Yeah but what guards ->release() starting to run and then the ref
being switched to percpu mode?  Or maybe that doesn't matter?

> > describe the exact usage you have on mind?
> 
> Let me explain the use case:
> 
> 1) nvme timeout comes
> 
> 2) all pending requests are canceled, but won't be completed because
> they have to be retried after the controller is recovered
> 
> 3) meantime, the queue has to be frozen for avoiding new request, so
> the refcount is killed via percpu_ref_kill().
> 
> 4) after the queue is recovered(or the controller is reset successfully), it
> isn't necessary to wait until the refcount drops zero, since it is fine to
> reinit it by clearing DEAD and switching back to percpu mode from atomic mode.
> And waiting for the refcount dropping to zero in the reset handler may trigger
> IO hang if IO timeout happens again during reset.

Does the recovery need the in-flight commands actually drained or does
it just need to block new issues for a while.  If latter, why is
percpu_ref even being used?

> So what I am trying to propose is the following usage:
> 
> 1) percpu_ref_kill() on .q_usage_counter before recovering the controller for
> preventing new requests from entering queue

The way you're describing it, the above part is no different from
having a global bool which gates new issues.

> 2) controller is recovered
> 
> 3) percpu_ref_reinit() on .q_usage_counter, and do not wait for
> .q_usage_counter dropping to zero, then we needn't to wait in NVMe reset
> handler which can be thought as single thread, and avoid IO hang when
> new timeout is triggered during the waiting.

This sounds possibly confused to me.  Can you please explain how the
recovery may hang if you wait for the ref to drain?

Thanks.

-- 
tejun

  reply	other threads:[~2018-09-12 20:58 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-09 12:58 [PATCH] percpu-refcount: relax limit on percpu_ref_reinit() 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  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
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 [this message]
2018-09-12 22:11                       ` Ming Lei
2018-09-12 22:11                         ` Ming Lei
2018-09-18 12:49                         ` Tejun Heo
2018-09-18 12:49                           ` Tejun Heo
2018-09-19  2:51                           ` Ming Lei
2018-09-19  2:51                             ` Ming Lei
2018-09-19 20:36                             ` Tejun Heo
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=20180912155321.GE2966370@devbig004.ftw2.facebook.com \
    --to=tj@kernel.org \
    --cc=jianchao.w.wang@oracle.com \
    --cc=kent.overstreet@gmail.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.