Re: [PATCH] block: mq-deadline: Fix queue restart handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Oct 05, 2019 at 12:03:18PM +0900, Damien Le Moal wrote:
[ Upstream commit cb8acabbe33b110157955a7425ee876fb81e6bbc ]

Commit 7211aef86f79 ("block: mq-deadline: Fix write completion
handling") added a call to blk_mq_sched_mark_restart_hctx() in
dd_dispatch_request() to make sure that write request dispatching does
not stall when all target zones are locked. This fix left a subtle race
when a write completion happens during a dispatch execution on another
CPU:

CPU 0: Dispatch			CPU1: write completion

dd_dispatch_request()
   lock(&dd->lock);
   ...
   lock(&dd->zone_lock);	dd_finish_request()
   rq = find request		lock(&dd->zone_lock);
   unlock(&dd->zone_lock);
   				zone write unlock
				unlock(&dd->zone_lock);
				...
				__blk_mq_free_request
                                     check restart flag (not set)
				      -> queue not run
   ...
   if (!rq && have writes)
       blk_mq_sched_mark_restart_hctx()
   unlock(&dd->lock)

Since the dispatch context finishes after the write request completion
handling, marking the queue as needing a restart is not seen from
__blk_mq_free_request() and blk_mq_sched_restart() not executed leading
to the dispatch stall under 100% write workloads.

Fix this by moving the call to blk_mq_sched_mark_restart_hctx() from
dd_dispatch_request() into dd_finish_request() under the zone lock to
ensure full mutual exclusion between write request dispatch selection
and zone unlock on write request completion.

Fixes: 7211aef86f79 ("block: mq-deadline: Fix write completion handling")
Cc: stable@xxxxxxxxxxxxxxx
Reported-by: Hans Holmberg <Hans.Holmberg@xxxxxxx>
Reviewed-by: Hans Holmberg <hans.holmberg@xxxxxxx>
Reviewed-by: Christoph Hellwig <hch@xxxxxx>
Signed-off-by: Damien Le Moal <damien.lemoal@xxxxxxx>
Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>

I've queued it up for 4.19, thanks!

--
Thanks,
Sasha



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux