mirror of
https://github.com/torvalds/linux.git
synced 2024-11-21 19:41:42 +00:00
96a9fe64bf
Supposing first scenario with a virtio_blk driver.
CPU0 CPU1
blk_mq_try_issue_directly()
__blk_mq_issue_directly()
q->mq_ops->queue_rq()
virtio_queue_rq()
blk_mq_stop_hw_queue()
virtblk_done()
blk_mq_request_bypass_insert() 1) store
blk_mq_start_stopped_hw_queue()
clear_bit(BLK_MQ_S_STOPPED) 3) store
blk_mq_run_hw_queue()
if (!blk_mq_hctx_has_pending()) 4) load
return
blk_mq_sched_dispatch_requests()
blk_mq_run_hw_queue()
if (!blk_mq_hctx_has_pending())
return
blk_mq_sched_dispatch_requests()
if (blk_mq_hctx_stopped()) 2) load
return
__blk_mq_sched_dispatch_requests()
Supposing another scenario.
CPU0 CPU1
blk_mq_requeue_work()
blk_mq_insert_request() 1) store
virtblk_done()
blk_mq_start_stopped_hw_queue()
blk_mq_run_hw_queues() clear_bit(BLK_MQ_S_STOPPED) 3) store
blk_mq_run_hw_queue()
if (!blk_mq_hctx_has_pending()) 4) load
return
blk_mq_sched_dispatch_requests()
if (blk_mq_hctx_stopped()) 2) load
continue
blk_mq_run_hw_queue()
Both scenarios are similar, the full memory barrier should be inserted
between 1) and 2), as well as between 3) and 4) to make sure that either
CPU0 sees BLK_MQ_S_STOPPED is cleared or CPU1 sees dispatch list.
Otherwise, either CPU will not rerun the hardware queue causing
starvation of the request.
The easy way to fix it is to add the essential full memory barrier into
helper of blk_mq_hctx_stopped(). In order to not affect the fast path
(hardware queue is not stopped most of the time), we only insert the
barrier into the slow path. Actually, only slow path needs to care about
missing of dispatching the request to the low-level device driver.
Fixes:
|
||
---|---|---|
.. | ||
partitions | ||
badblocks.c | ||
bdev.c | ||
bfq-cgroup.c | ||
bfq-iosched.c | ||
bfq-iosched.h | ||
bfq-wf2q.c | ||
bio-integrity.c | ||
bio.c | ||
blk-cgroup-fc-appid.c | ||
blk-cgroup-rwstat.c | ||
blk-cgroup-rwstat.h | ||
blk-cgroup.c | ||
blk-cgroup.h | ||
blk-core.c | ||
blk-crypto-fallback.c | ||
blk-crypto-internal.h | ||
blk-crypto-profile.c | ||
blk-crypto-sysfs.c | ||
blk-crypto.c | ||
blk-flush.c | ||
blk-ia-ranges.c | ||
blk-integrity.c | ||
blk-ioc.c | ||
blk-iocost.c | ||
blk-iolatency.c | ||
blk-ioprio.c | ||
blk-ioprio.h | ||
blk-lib.c | ||
blk-map.c | ||
blk-merge.c | ||
blk-mq-cpumap.c | ||
blk-mq-debugfs.c | ||
blk-mq-debugfs.h | ||
blk-mq-pci.c | ||
blk-mq-sched.c | ||
blk-mq-sched.h | ||
blk-mq-sysfs.c | ||
blk-mq-tag.c | ||
blk-mq-virtio.c | ||
blk-mq.c | ||
blk-mq.h | ||
blk-pm.c | ||
blk-pm.h | ||
blk-rq-qos.c | ||
blk-rq-qos.h | ||
blk-settings.c | ||
blk-stat.c | ||
blk-stat.h | ||
blk-sysfs.c | ||
blk-throttle.c | ||
blk-throttle.h | ||
blk-timeout.c | ||
blk-wbt.c | ||
blk-wbt.h | ||
blk-zoned.c | ||
blk.h | ||
bounce.c | ||
bsg-lib.c | ||
bsg.c | ||
disk-events.c | ||
early-lookup.c | ||
elevator.c | ||
elevator.h | ||
fops.c | ||
genhd.c | ||
holder.c | ||
ioctl.c | ||
ioprio.c | ||
Kconfig | ||
Kconfig.iosched | ||
kyber-iosched.c | ||
Makefile | ||
mq-deadline.c | ||
opal_proto.h | ||
sed-opal.c | ||
t10-pi.c |