From: bart.vanassche@sandisk.com (Bart Van Assche)
Subject: [PATCH v2 4/7] blk-mq: Introduce blk_quiesce_queue() and blk_resume_queue()
Date: Fri, 30 Sep 2016 08:55:59 -0700 [thread overview]
Message-ID: <9fb67745-954c-a70f-a89a-d184c99ae9aa@sandisk.com> (raw)
In-Reply-To: <CACVXFVOO4P3RsnWci8XHdFoYBhNPq0KqjWJddsie-92+31bpEg@mail.gmail.com>
On 09/29/16 14:51, Ming Lei wrote:
> On Thu, Sep 29, 2016 at 7:59 AM, Bart Van Assche
> <bart.vanassche@sandisk.com> wrote:
>> blk_quiesce_queue() prevents that new queue_rq() invocations
>
> blk_mq_quiesce_queue()
Thanks, I will update the patch title and patch description.
>> +void blk_mq_quiesce_queue(struct request_queue *q)
>> +{
>> + struct blk_mq_hw_ctx *hctx;
>> + unsigned int i;
>> + bool res, rcu = false;
>> +
>> + spin_lock_irq(q->queue_lock);
>> + WARN_ON_ONCE(blk_queue_quiescing(q));
>> + queue_flag_set(QUEUE_FLAG_QUIESCING, q);
>> + spin_unlock_irq(q->queue_lock);
>> +
>> + res = __blk_mq_freeze_queue_start(q, false);
>
> Looks the implementation is a bit tricky and complicated, if the percpu
> usage counter isn't killed, it isn't necessary to touch .mq_freeze_depth
> since you use QUEUE_FLAG_QUIESCING to set/get this status of
> the queue.
>
> Then using synchronize_rcu() and rcu_read_lock()/rcu_read_unlock()
> with the flag of QUIESCING may be enough to wait for completing
> of ongoing invocations of .queue_rq() and avoid to run new .queue_rq,
> right?
That's an interesting thought. Can you have a look at the attached patch
in which blk_mq_quiesce_queue() no longer manipulates the
mq_freeze_depth counter?
>> + WARN_ON_ONCE(!res);
>> + queue_for_each_hw_ctx(q, hctx, i) {
>> + if (hctx->flags & BLK_MQ_F_BLOCKING) {
>> + mutex_lock(&hctx->queue_rq_mutex);
>> + mutex_unlock(&hctx->queue_rq_mutex);
>
> Could you explain a bit why all BLOCKING is treated so special? And
> that flag just means the hw queue always need to schedule asynchronously,
> and of course even though the flag isn't set, it still may be run
> asynchronously too. So looks it should be enough to just use RCU.
The mutex manipulations introduce atomic stores in the hot path. Hence
the use of synchronize_rcu() and rcu_read_lock()/rcu_read_unlock() when
possible. Since BLK_MQ_F_BLOCKING indicates that .queue_rq() may sleep
and since sleeping is not allowed while holding the RCU read lock,
queue_rq_mutex has been introduced for the BLK_MQ_F_BLOCKING case.
Bart.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-blk-mq-Introduce-blk_mq_quiesce_queue.patch
Type: text/x-patch
Size: 6466 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-nvme/attachments/20160930/0dd0b79e/attachment-0001.bin>
next prev parent reply other threads:[~2016-09-30 15:55 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-28 23:57 [PATCH v2 0/7] Introduce blk_quiesce_queue() and blk_resume_queue() Bart Van Assche
2016-09-28 23:57 ` [PATCH v2 1/7] blk-mq: Introduce blk_mq_queue_stopped() Bart Van Assche
2016-10-05 17:50 ` Sagi Grimberg
2016-10-11 16:40 ` Christoph Hellwig
2016-09-28 23:59 ` [PATCH v2 4/7] blk-mq: Introduce blk_quiesce_queue() and blk_resume_queue() Bart Van Assche
2016-09-29 5:52 ` Hannes Reinecke
2016-09-29 21:51 ` Ming Lei
2016-09-30 15:55 ` Bart Van Assche [this message]
2016-10-01 22:56 ` Ming Lei
2016-10-05 4:16 ` Bart Van Assche
2016-10-05 4:32 ` Ming Lei
2016-10-05 14:46 ` Bart Van Assche
2016-10-05 16:11 ` Ming Lei
2016-10-05 18:14 ` Sagi Grimberg
2016-10-05 19:05 ` Bart Van Assche
2016-10-05 19:10 ` Sagi Grimberg
2016-10-05 21:08 ` Bart Van Assche
2016-10-05 22:49 ` Ming Lei
2016-10-05 23:00 ` Bart Van Assche
2016-09-29 0:00 ` [PATCH v2 5/7] dm: Fix a race condition related to stopping and starting queues Bart Van Assche
2016-09-29 0:01 ` [PATCH v2 6/7] SRP transport: Port srp_wait_for_queuecommand() to scsi-mq Bart Van Assche
2016-09-29 5:54 ` Hannes Reinecke
2016-10-05 17:38 ` Sagi Grimberg
2016-10-05 21:51 ` Bart Van Assche
2016-10-11 16:44 ` Christoph Hellwig
2016-09-29 0:01 ` [PATCH v2 7/7] [RFC] nvme: Fix a race condition Bart Van Assche
2016-10-05 17:40 ` Sagi Grimberg
2016-10-11 16:46 ` Christoph Hellwig
2016-10-12 0:41 ` Bart Van Assche
2016-09-29 0:02 ` [PATCH v2 2/7] dm: Use BLK_MQ_S_STOPPED instead of QUEUE_FLAG_STOPPED in blk-mq code Bart Van Assche
2016-09-29 0:02 ` [PATCH v2 3/7] [RFC] nvme: " Bart Van Assche
2016-10-05 17:43 ` Sagi Grimberg
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=9fb67745-954c-a70f-a89a-d184c99ae9aa@sandisk.com \
--to=bart.vanassche@sandisk.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox