From: Bart Van Assche <bvanassche@acm.org>
To: Ming Lei <ming.lei@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
Christoph Hellwig <hch@infradead.org>,
Hannes Reinecke <hare@suse.com>,
James Smart <james.smart@broadcom.com>,
Jianchao Wang <jianchao.w.wang@oracle.com>,
Dongli Zhang <dongli.zhang@oracle.com>,
stable@vger.kernel.org
Subject: Re: [PATCH 2/4] block: Fix a race between request queue freezing and running queues
Date: Tue, 02 Apr 2019 08:44:10 -0700 [thread overview]
Message-ID: <1554219850.118779.137.camel@acm.org> (raw)
In-Reply-To: <20190402005318.GC21944@ming.t460p>
On Tue, 2019-04-02 at 08:53 +0800, Ming Lei wrote:
> On Mon, Apr 01, 2019 at 02:20:12PM -0700, Bart Van Assche wrote:
> > diff --git a/block/blk-mq.c b/block/blk-mq.c
> > index 3ff3d7b49969..652d0c6d5945 100644
> > --- a/block/blk-mq.c
> > +++ b/block/blk-mq.c
> > @@ -1499,12 +1499,20 @@ void blk_mq_run_hw_queues(struct request_queue *q, bool async)
> > struct blk_mq_hw_ctx *hctx;
> > int i;
> >
> > + /*
> > + * Do not run any hardware queues if the queue is frozen or if a
> > + * concurrent blk_cleanup_queue() call is removing any data
> > + * structures used by this function.
> > + */
> > + if (!percpu_ref_tryget(&q->q_usage_counter))
> > + return;
> > queue_for_each_hw_ctx(q, hctx, i) {
> > if (blk_mq_hctx_stopped(hctx))
> > continue;
> >
> > blk_mq_run_hw_queue(hctx, async);
> > }
> > + percpu_ref_put(&q->q_usage_counter);
> > }
> > EXPORT_SYMBOL(blk_mq_run_hw_queues);
>
> I don't see it is necessary to add percpu_ref_tryget()/percpu_ref_put()
> in the fast path if we simply release all hctx resource in hctx's
> release handler by the following patch:
>
> https://lore.kernel.org/linux-block/20190401044247.29881-2-ming.lei@redhat.com/T/#u
>
> Even we can kill the percpu_ref_tryget_live()/percpu_ref_put() in
> scsi_end_request().
The above approach has the advantages of being easy to review and to maintain.
Patch "[PATCH V2 1/3] blk-mq: free hw queue's resource in hctx's release handler"
makes the block layer more complicated because it introduces a new state for
hardware queues: block driver cleanup has happened (set->ops->exit_hctx(...)) but
the hardware queues are still in use by the block layer core.
Let's see what other reviewers think.
Bart.
next prev parent reply other threads:[~2019-04-02 15:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-01 21:20 [PATCH 0/4] Fir a race between request queue cleanup and running queues Bart Van Assche
2019-04-01 21:20 ` [PATCH 1/4] block: Move the percpu_ref_exit(&q->q_usage_counter) call into __blk_release_queue() Bart Van Assche
2019-04-01 21:20 ` [PATCH 2/4] block: Fix a race between request queue freezing and running queues Bart Van Assche
2019-04-02 0:53 ` Ming Lei
2019-04-02 15:44 ` Bart Van Assche [this message]
2019-04-03 3:31 ` Ming Lei
2019-04-01 21:20 ` [PATCH 3/4] block: Fix a comment in blk_cleanup_queue() Bart Van Assche
2019-04-01 21:20 ` [PATCH 4/4] block: Make blk_cleanup_queue() faster Bart Van Assche
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=1554219850.118779.137.camel@acm.org \
--to=bvanassche@acm.org \
--cc=axboe@kernel.dk \
--cc=dongli.zhang@oracle.com \
--cc=hare@suse.com \
--cc=hch@infradead.org \
--cc=hch@lst.de \
--cc=james.smart@broadcom.com \
--cc=jianchao.w.wang@oracle.com \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=stable@vger.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;
as well as URLs for NNTP newsgroup(s).