From: Ming Lei <ming.lei@redhat.com>
To: Sagi Grimberg <sagi@grimberg.me>
Cc: Jens Axboe <axboe@kernel.dk>,
Bart Van Assche <bvanassche@acm.org>,
Johannes Thumshirn <Johannes.Thumshirn@wdc.com>,
linux-nvme@lists.infradead.org, linux-block@vger.kernel.org,
Hannes Reinecke <hare@suse.de>, Chao Leng <lengchao@huawei.com>,
Keith Busch <kbusch@kernel.org>, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH V4 2/4] blk-mq: implement queue quiesce via percpu_ref for BLK_MQ_F_BLOCKING
Date: Thu, 10 Sep 2020 16:03:37 +0800 [thread overview]
Message-ID: <20200910080337.GC31286@T590> (raw)
In-Reply-To: <dae73b2c-c191-c8a6-4287-838ab4962467@grimberg.me>
On Wed, Sep 09, 2020 at 01:53:30PM -0700, Sagi Grimberg wrote:
>
> > > void blk_mq_quiesce_queue(struct request_queue *q)
> > > {
> > > - struct blk_mq_hw_ctx *hctx;
> > > - unsigned int i;
> > > - bool rcu = false;
> > > + bool blocking = !!(q->tag_set->flags & BLK_MQ_F_BLOCKING);
> > > + bool was_quiesced =__blk_mq_quiesce_queue_nowait(q);
> > > - __blk_mq_quiesce_queue_nowait(q);
> > > + if (!was_quiesced && blocking)
> > > + percpu_ref_kill(&q->dispatch_counter);
> > > - queue_for_each_hw_ctx(q, hctx, i) {
> > > - if (hctx->flags & BLK_MQ_F_BLOCKING)
> > > - synchronize_srcu(hctx->srcu);
> > > - else
> > > - rcu = true;
> > > - }
> > > - if (rcu)
> > > + if (blocking)
> > > + wait_event(q->mq_quiesce_wq,
> > > + percpu_ref_is_zero(&q->dispatch_counter));
> > > + else
> > > synchronize_rcu();
> > > }
> >
> > In the previous version, you had ensured no thread can unquiesce a queue
> > while another is waiting for quiescence. Now that the locking is gone,
> > a thread could unquiesce the queue before percpu_ref reaches zero, so
> > the wait_event() may never complete on the resurrected percpu_ref.
>
> Yea, where did that go?
The mutex is removed because:
1) As Bart mentioned, blk_mq_quiesce_queue() may be called in context
which doesn't allow sleep.
2) Both percpu_ref_kill() and percpu_ref_resurrect() have been protected by
one global spinlock, so both two can be run concurrently.
3) warning may be triggered when percpu_ref_kill() is run on one DEAD
percpu-refcount, or when percpu_ref_resurrect() is run on one live
percpu-refcount. We can avoid the warning with test_and_{clear|test}_bit
exactly by running the actual quiesce/unquiesce action only once.
Thanks,
Ming
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
next prev parent reply other threads:[~2020-09-10 8:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-09 10:41 [PATCH V4 0/4] blk-mq: implement queue quiesce via percpu_ref for BLK_MQ_F_BLOCKING Ming Lei
2020-09-09 10:41 ` [PATCH V4 1/4] block: use test_and_{clear|test}_bit to set/clear QUEUE_FLAG_QUIESCED Ming Lei
2020-09-09 10:41 ` [PATCH V4 2/4] blk-mq: implement queue quiesce via percpu_ref for BLK_MQ_F_BLOCKING Ming Lei
2020-09-09 16:04 ` Keith Busch
2020-09-09 20:53 ` Sagi Grimberg
2020-09-10 8:03 ` Ming Lei [this message]
2020-09-10 1:53 ` Ming Lei
2020-09-10 14:55 ` Keith Busch
2020-09-09 10:41 ` [PATCH V4 3/4] blk-mq: add tagset quiesce interface Ming Lei
2020-09-09 10:41 ` [PATCH V4 4/4] nvme: use blk_mq_[un]quiesce_tagset 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=20200910080337.GC31286@T590 \
--to=ming.lei@redhat.com \
--cc=Johannes.Thumshirn@wdc.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=lengchao@huawei.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/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;
as well as URLs for NNTP newsgroup(s).