* [PATCH v2] blk-mq: run queue no matter whether the request is the last request
@ 2022-07-26 11:01 Yufen Yu
2022-07-27 2:06 ` Ming Lei
0 siblings, 1 reply; 2+ messages in thread
From: Yufen Yu @ 2022-07-26 11:01 UTC (permalink / raw)
To: axboe; +Cc: ming.lei, yukuai3, linux-block, Yufen Yu
We do test on a virtio scsi device (/dev/sda) and the default mq
scheduler is 'none'. We found a IO hung as following:
blk_finish_plug
blk_mq_plug_issue_direct
scsi_mq_get_budget
//get budget_token fail and sdev->restarts=1
scsi_end_request
scsi_run_queue_async
//sdev->restart=0 and run queue
blk_mq_request_bypass_insert
//add request to hctx->dispatch list
//continue to dispath plug list
blk_mq_dispatch_plug_list
blk_mq_try_issue_list_directly
//success issue all requests from plug list
After .get_budget fail, scsi_mq_get_budget will increase 'restarts'.
Normally, it will run hw queue when io complete and set 'restarts'
as 0. But if we run queue before adding request to the dispatch list
and blk_mq_dispatch_plug_list also success issue all requests, then
on one will run queue, and the request will be stall in the dispatch
list and cannot complete forever.
It is wrong to use last request of plug list to decide if run queue is
needed since all the remained requests in plug list may be from other
hctxs. To fix the bug, pass run_queue as true always to
blk_mq_request_bypass_insert().
Fix-suggested-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Yufen Yu <yuyufen@huawei.com>
---
block/blk-mq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 93d9d60980fb..1eb13d57a946 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2568,7 +2568,7 @@ static void blk_mq_plug_issue_direct(struct blk_plug *plug, bool from_schedule)
break;
case BLK_STS_RESOURCE:
case BLK_STS_DEV_RESOURCE:
- blk_mq_request_bypass_insert(rq, false, last);
+ blk_mq_request_bypass_insert(rq, false, true);
blk_mq_commit_rqs(hctx, &queued, from_schedule);
return;
default:
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] blk-mq: run queue no matter whether the request is the last request
2022-07-26 11:01 [PATCH v2] blk-mq: run queue no matter whether the request is the last request Yufen Yu
@ 2022-07-27 2:06 ` Ming Lei
0 siblings, 0 replies; 2+ messages in thread
From: Ming Lei @ 2022-07-27 2:06 UTC (permalink / raw)
To: Yufen Yu; +Cc: axboe, yukuai3, linux-block
On Tue, Jul 26, 2022 at 07:01:11PM +0800, Yufen Yu wrote:
> We do test on a virtio scsi device (/dev/sda) and the default mq
> scheduler is 'none'. We found a IO hung as following:
>
> blk_finish_plug
> blk_mq_plug_issue_direct
> scsi_mq_get_budget
> //get budget_token fail and sdev->restarts=1
>
> scsi_end_request
> scsi_run_queue_async
> //sdev->restart=0 and run queue
>
> blk_mq_request_bypass_insert
> //add request to hctx->dispatch list
>
> //continue to dispath plug list
> blk_mq_dispatch_plug_list
> blk_mq_try_issue_list_directly
> //success issue all requests from plug list
>
> After .get_budget fail, scsi_mq_get_budget will increase 'restarts'.
> Normally, it will run hw queue when io complete and set 'restarts'
> as 0. But if we run queue before adding request to the dispatch list
> and blk_mq_dispatch_plug_list also success issue all requests, then
> on one will run queue, and the request will be stall in the dispatch
> list and cannot complete forever.
The story isn't related with scsi actually.
>
> It is wrong to use last request of plug list to decide if run queue is
> needed since all the remained requests in plug list may be from other
> hctxs. To fix the bug, pass run_queue as true always to
> blk_mq_request_bypass_insert().
>
> Fix-suggested-by: Ming Lei <ming.lei@redhat.com>
> Signed-off-by: Yufen Yu <yuyufen@huawei.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Thanks,
Ming
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-07-27 2:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-26 11:01 [PATCH v2] blk-mq: run queue no matter whether the request is the last request Yufen Yu
2022-07-27 2:06 ` Ming Lei
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).