]> git.baikalelectronics.ru Git - kernel.git/commit
block: Limit number of items taken from the I/O scheduler in one go
authorSalman Qazi <sqazi@google.com>
Fri, 24 Apr 2020 15:03:21 +0000 (08:03 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 11 Mar 2023 15:43:34 +0000 (16:43 +0100)
commitcc014c6f42263f621107846c6d504eda584a27ba
tree2a257d6d3742295270c4d0eee68ad9867c7d1b66
parent58b4ec509f1aa2d1f7f9c2faa5847a7327fbc1f0
block: Limit number of items taken from the I/O scheduler in one go

[ Upstream commit 22126542d63dba158dcb4c91d72b3677917f454c ]

Flushes bypass the I/O scheduler and get added to hctx->dispatch
in blk_mq_sched_bypass_insert.  This can happen while a kworker is running
hctx->run_work work item and is past the point in
blk_mq_sched_dispatch_requests where hctx->dispatch is checked.

The blk_mq_do_dispatch_sched call is not guaranteed to end in bounded time,
because the I/O scheduler can feed an arbitrary number of commands.

Since we have only one hctx->run_work, the commands waiting in
hctx->dispatch will wait an arbitrary length of time for run_work to be
rerun.

A similar phenomenon exists with dispatches from the software queue.

The solution is to poll hctx->dispatch in blk_mq_do_dispatch_sched and
blk_mq_do_dispatch_ctx and return from the run_work handler and let it
rerun.

Signed-off-by: Salman Qazi <sqazi@google.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Stable-dep-of: c31e76bcc379 ("blk-mq: remove stale comment for blk_mq_sched_mark_restart_hctx")
Signed-off-by: Sasha Levin <sashal@kernel.org>
block/blk-mq-sched.c