Hi, Ming!
在 2022/07/19 17:26, Ming Lei 写道:
On Mon, Jul 18, 2022 at 08:35:28PM +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
Here the issue shouldn't be related with scsi's get budget or
scsi_run_queue_async.
If blk-mq adds request into ->dispatch_list, it is blk-mq core's
responsibility to re-run queue for moving on. Can you investigate a
bit more why blk-mq doesn't run queue after adding request to
hctx dispatch list?
I think Yufen is probably thinking about the following Concurrent
scenario:
blk_mq_flush_plug_list
# assume there are three rq
blk_mq_plug_issue_direct
blk_mq_request_issue_directly
# dispatch rq1, succeed
blk_mq_request_issue_directly
# dispatch rq2
__blk_mq_try_issue_directly
blk_mq_get_dispatch_budget
scsi_mq_get_budget
atomic_inc(&sdev->restarts);
# rq2 failed to get budget
# restarts is 1 now
scsi_end_request
# rq1 is completed
┊scsi_run_queue_async
┊
atomic_cmpxchg(&sdev->restarts, old, 0) == old
┊ # set restarts to 0
┊ blk_mq_run_hw_queues
┊ # hctx->dispatch list is empty
blk_mq_request_bypass_insert
# insert rq2 to hctx->dispatch list
blk_mq_dispatch_plug_list
# continue to dispatch rq3
blk_mq_sched_insert_requests
blk_mq_try_issue_list_directly
# blk_mq_run_hw_queue() won't be called
# because dispatching is succeed
scsi_end_request
┊# rq3 is complete
┊ scsi_run_queue_async
┊ # restarts is 0, won't run queue
The root cause is that the failed dispatching is not the last rq,
and last rq is dispatched sucessfully.
Thanks,
Kuai
Thanks,
Ming
.