Skip to content

Commit 1e3c389

Browse files
jankaragregkh
authored andcommitted
bfq: Do not let waker requests skip proper accounting
[ Upstream commit c65e6fd ] Commit 7cc4ffc ("block, bfq: put reqs of waker and woken in dispatch list") added a condition to bfq_insert_request() which added waker's requests directly to dispatch list. The rationale was that completing waker's IO is needed to get more IO for the current queue. Although this rationale is valid, there is a hole in it. The waker does not necessarily serve the IO only for the current queue and maybe it's current IO is not needed for current queue to make progress. Furthermore injecting IO like this completely bypasses any service accounting within bfq and thus we do not properly track how much service is waker's queue getting or that the waker is actually doing any IO. Depending on the conditions this can result in the waker getting too much or too few service. Consider for example the following job file: [global] directory=/mnt/repro/ rw=write size=8g time_based runtime=30 ramp_time=10 blocksize=1m direct=0 ioengine=sync [slowwriter] numjobs=1 prioclass=2 prio=7 fsync=200 [fastwriter] numjobs=1 prioclass=2 prio=0 fsync=200 Despite processes have very different IO priorities, they get the same about of service. The reason is that bfq identifies these processes as having waker-wakee relationship and once that happens, IO from fastwriter gets injected during slowwriter's time slice. As a result bfq is not aware that fastwriter has any IO to do and constantly schedules only slowwriter's queue. Thus fastwriter is forced to compete with slowwriter's IO all the time instead of getting its share of time based on IO priority. Drop the special injection condition from bfq_insert_request(). As a result, requests will be tracked and queued in a normal way and on next dispatch bfq_select_queue() can decide whether the waker's inserted requests should be injected during the current queue's timeslice or not. Fixes: 7cc4ffc ("block, bfq: put reqs of waker and woken in dispatch list") Acked-by: Paolo Valente <paolo.valente@linaro.org> Signed-off-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/r/20211125133645.27483-8-jack@suse.cz Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 0907bda commit 1e3c389

1 file changed

Lines changed: 1 addition & 43 deletions

File tree

‎block/bfq-iosched.c‎

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5991,48 +5991,7 @@ static void bfq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
59915991

59925992
spin_lock_irq(&bfqd->lock);
59935993
bfqq = bfq_init_rq(rq);
5994-
5995-
/*
5996-
* Reqs with at_head or passthrough flags set are to be put
5997-
* directly into dispatch list. Additional case for putting rq
5998-
* directly into the dispatch queue: the only active
5999-
* bfq_queues are bfqq and either its waker bfq_queue or one
6000-
* of its woken bfq_queues. The rationale behind this
6001-
* additional condition is as follows:
6002-
* - consider a bfq_queue, say Q1, detected as a waker of
6003-
* another bfq_queue, say Q2
6004-
* - by definition of a waker, Q1 blocks the I/O of Q2, i.e.,
6005-
* some I/O of Q1 needs to be completed for new I/O of Q2
6006-
* to arrive. A notable example of waker is journald
6007-
* - so, Q1 and Q2 are in any respect the queues of two
6008-
* cooperating processes (or of two cooperating sets of
6009-
* processes): the goal of Q1's I/O is doing what needs to
6010-
* be done so that new Q2's I/O can finally be
6011-
* issued. Therefore, if the service of Q1's I/O is delayed,
6012-
* then Q2's I/O is delayed too. Conversely, if Q2's I/O is
6013-
* delayed, the goal of Q1's I/O is hindered.
6014-
* - as a consequence, if some I/O of Q1/Q2 arrives while
6015-
* Q2/Q1 is the only queue in service, there is absolutely
6016-
* no point in delaying the service of such an I/O. The
6017-
* only possible result is a throughput loss
6018-
* - so, when the above condition holds, the best option is to
6019-
* have the new I/O dispatched as soon as possible
6020-
* - the most effective and efficient way to attain the above
6021-
* goal is to put the new I/O directly in the dispatch
6022-
* list
6023-
* - as an additional restriction, Q1 and Q2 must be the only
6024-
* busy queues for this commit to put the I/O of Q2/Q1 in
6025-
* the dispatch list. This is necessary, because, if also
6026-
* other queues are waiting for service, then putting new
6027-
* I/O directly in the dispatch list may evidently cause a
6028-
* violation of service guarantees for the other queues
6029-
*/
6030-
if (!bfqq ||
6031-
(bfqq != bfqd->in_service_queue &&
6032-
bfqd->in_service_queue != NULL &&
6033-
bfq_tot_busy_queues(bfqd) == 1 + bfq_bfqq_busy(bfqq) &&
6034-
(bfqq->waker_bfqq == bfqd->in_service_queue ||
6035-
bfqd->in_service_queue->waker_bfqq == bfqq)) || at_head) {
5994+
if (!bfqq || at_head) {
60365995
if (at_head)
60375996
list_add(&rq->queuelist, &bfqd->dispatch);
60385997
else
@@ -6059,7 +6018,6 @@ static void bfq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
60596018
* merge).
60606019
*/
60616020
cmd_flags = rq->cmd_flags;
6062-
60636021
spin_unlock_irq(&bfqd->lock);
60646022

60656023
bfq_update_insert_stats(q, bfqq, idle_timer_disabled,

0 commit comments

Comments
 (0)