* [PATCH] blk-mq: auto-start hw queue in requeue
@ 2014-09-19 14:22 Ming Lei
2014-09-19 17:48 ` Christoph Hellwig
0 siblings, 1 reply; 5+ messages in thread
From: Ming Lei @ 2014-09-19 14:22 UTC (permalink / raw)
To: linux-kernel, Christoph Hellwig; +Cc: Jens Axboe, Ming Lei
Requests often need to be retried because of timeout, hardware
busy or sort of reasons via blk_mq_requeue_request(), but at
that time dispatch queue may have been stopped.
This patch starts the dispatch queue automatically in requeue's
work handler, and fixes scsi-mq's timeout issue, which can be
triggered if there are two or more requests timedout.
Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
block/blk-mq.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 80ade9f..edd0ece 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -33,6 +33,8 @@ static DEFINE_MUTEX(all_q_mutex);
static LIST_HEAD(all_q_list);
static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx);
+static void __blk_mq_run_queues(struct request_queue *q, bool async,
+ bool restart);
/*
* Check if any of the ctx's have pending work in this hardware queue
@@ -473,7 +475,7 @@ static void blk_mq_requeue_work(struct work_struct *work)
blk_mq_insert_request(rq, false, false, false);
}
- blk_mq_run_queues(q, false);
+ __blk_mq_run_queues(q, false, true);
}
void blk_mq_add_to_requeue_list(struct request *rq, bool at_head)
@@ -806,15 +808,21 @@ void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async)
}
}
-void blk_mq_run_queues(struct request_queue *q, bool async)
+static void __blk_mq_run_queues(struct request_queue *q, bool async,
+ bool restart)
{
struct blk_mq_hw_ctx *hctx;
int i;
queue_for_each_hw_ctx(q, hctx, i) {
+ bool stopped = test_bit(BLK_MQ_S_STOPPED, &hctx->state);
+
+ if (restart && stopped)
+ clear_bit(BLK_MQ_S_STOPPED, &hctx->state);
+
if ((!blk_mq_hctx_has_pending(hctx) &&
list_empty_careful(&hctx->dispatch)) ||
- test_bit(BLK_MQ_S_STOPPED, &hctx->state))
+ (stopped && !restart))
continue;
preempt_disable();
@@ -822,6 +830,11 @@ void blk_mq_run_queues(struct request_queue *q, bool async)
preempt_enable();
}
}
+
+void blk_mq_run_queues(struct request_queue *q, bool async)
+{
+ __blk_mq_run_queues(q, async, false);
+}
EXPORT_SYMBOL(blk_mq_run_queues);
void blk_mq_stop_hw_queue(struct blk_mq_hw_ctx *hctx)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] blk-mq: auto-start hw queue in requeue
2014-09-19 14:22 [PATCH] blk-mq: auto-start hw queue in requeue Ming Lei
@ 2014-09-19 17:48 ` Christoph Hellwig
2014-09-19 17:52 ` Jens Axboe
0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2014-09-19 17:48 UTC (permalink / raw)
To: Ming Lei; +Cc: linux-kernel, Christoph Hellwig, Jens Axboe
On Fri, Sep 19, 2014 at 10:22:50PM +0800, Ming Lei wrote:
> Requests often need to be retried because of timeout, hardware
> busy or sort of reasons via blk_mq_requeue_request(), but at
> that time dispatch queue may have been stopped.
>
> This patch starts the dispatch queue automatically in requeue's
> work handler, and fixes scsi-mq's timeout issue, which can be
> triggered if there are two or more requests timedout.
Sounds like blk_mq_requeue_work should simply call void
blk_mq_start_hw_queues where it calls blk_mq_run_queues currently.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] blk-mq: auto-start hw queue in requeue
2014-09-19 17:48 ` Christoph Hellwig
@ 2014-09-19 17:52 ` Jens Axboe
2014-09-19 17:54 ` Christoph Hellwig
0 siblings, 1 reply; 5+ messages in thread
From: Jens Axboe @ 2014-09-19 17:52 UTC (permalink / raw)
To: Christoph Hellwig, Ming Lei; +Cc: linux-kernel
On 09/19/2014 11:48 AM, Christoph Hellwig wrote:
> On Fri, Sep 19, 2014 at 10:22:50PM +0800, Ming Lei wrote:
>> Requests often need to be retried because of timeout, hardware
>> busy or sort of reasons via blk_mq_requeue_request(), but at
>> that time dispatch queue may have been stopped.
>>
>> This patch starts the dispatch queue automatically in requeue's
>> work handler, and fixes scsi-mq's timeout issue, which can be
>> triggered if there are two or more requests timedout.
>
> Sounds like blk_mq_requeue_work should simply call void
> blk_mq_start_hw_queues where it calls blk_mq_run_queues currently.
I agree. I think Ming wanted to avoid an unnecessary bitflip if
possible, but the fix is more convoluted than I would like.
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] blk-mq: auto-start hw queue in requeue
2014-09-19 17:52 ` Jens Axboe
@ 2014-09-19 17:54 ` Christoph Hellwig
2014-09-19 18:03 ` Jens Axboe
0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2014-09-19 17:54 UTC (permalink / raw)
To: Jens Axboe; +Cc: Ming Lei, linux-kernel
On Fri, Sep 19, 2014 at 11:52:59AM -0600, Jens Axboe wrote:
> I agree. I think Ming wanted to avoid an unnecessary bitflip if
> possible, but the fix is more convoluted than I would like.
If the requeue from irq context ever ends up in the fast path we
have much worse problems..
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] blk-mq: auto-start hw queue in requeue
2014-09-19 17:54 ` Christoph Hellwig
@ 2014-09-19 18:03 ` Jens Axboe
0 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2014-09-19 18:03 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Ming Lei, linux-kernel
On 09/19/2014 11:54 AM, Christoph Hellwig wrote:
> On Fri, Sep 19, 2014 at 11:52:59AM -0600, Jens Axboe wrote:
>> I agree. I think Ming wanted to avoid an unnecessary bitflip if
>> possible, but the fix is more convoluted than I would like.
>
> If the requeue from irq context ever ends up in the fast path we
> have much worse problems..
Oh yes certainly, my point was purely that I think this is why Mings fix
ended up being more involved than it need be.
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-09-19 18:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-19 14:22 [PATCH] blk-mq: auto-start hw queue in requeue Ming Lei
2014-09-19 17:48 ` Christoph Hellwig
2014-09-19 17:52 ` Jens Axboe
2014-09-19 17:54 ` Christoph Hellwig
2014-09-19 18:03 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox