Skip to content

Commit 7cc4ffc

Browse files
Algodev-githubaxboe
authored andcommitted
block, bfq: put reqs of waker and woken in dispatch list
Consider a new I/O request that arrives for a bfq_queue bfqq. If, when this happens, the only active bfq_queues are bfqq and either its waker bfq_queue or one of its woken bfq_queues, then there is no point in queueing this new I/O request in bfqq for service. In fact, the in-service queue and bfqq agree on serving this new I/O request as soon as possible. So this commit puts this new I/O request directly into the dispatch list. Tested-by: Jan Kara <jack@suse.cz> Acked-by: Jan Kara <jack@suse.cz> Signed-off-by: Paolo Valente <paolo.valente@linaro.org> Tested-by: Oleksandr Natalenko <oleksandr@natalenko.name> Link: https://lore.kernel.org/r/20210304174627.161-3-paolo.valente@linaro.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 2ec5a5c commit 7cc4ffc

1 file changed

Lines changed: 43 additions & 1 deletion

File tree

‎block/bfq-iosched.c‎

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5649,7 +5649,49 @@ static void bfq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
56495649

56505650
spin_lock_irq(&bfqd->lock);
56515651
bfqq = bfq_init_rq(rq);
5652-
if (!bfqq || at_head || blk_rq_is_passthrough(rq)) {
5652+
5653+
/*
5654+
* Reqs with at_head or passthrough flags set are to be put
5655+
* directly into dispatch list. Additional case for putting rq
5656+
* directly into the dispatch queue: the only active
5657+
* bfq_queues are bfqq and either its waker bfq_queue or one
5658+
* of its woken bfq_queues. The rationale behind this
5659+
* additional condition is as follows:
5660+
* - consider a bfq_queue, say Q1, detected as a waker of
5661+
* another bfq_queue, say Q2
5662+
* - by definition of a waker, Q1 blocks the I/O of Q2, i.e.,
5663+
* some I/O of Q1 needs to be completed for new I/O of Q2
5664+
* to arrive. A notable example of waker is journald
5665+
* - so, Q1 and Q2 are in any respect the queues of two
5666+
* cooperating processes (or of two cooperating sets of
5667+
* processes): the goal of Q1's I/O is doing what needs to
5668+
* be done so that new Q2's I/O can finally be
5669+
* issued. Therefore, if the service of Q1's I/O is delayed,
5670+
* then Q2's I/O is delayed too. Conversely, if Q2's I/O is
5671+
* delayed, the goal of Q1's I/O is hindered.
5672+
* - as a consequence, if some I/O of Q1/Q2 arrives while
5673+
* Q2/Q1 is the only queue in service, there is absolutely
5674+
* no point in delaying the service of such an I/O. The
5675+
* only possible result is a throughput loss
5676+
* - so, when the above condition holds, the best option is to
5677+
* have the new I/O dispatched as soon as possible
5678+
* - the most effective and efficient way to attain the above
5679+
* goal is to put the new I/O directly in the dispatch
5680+
* list
5681+
* - as an additional restriction, Q1 and Q2 must be the only
5682+
* busy queues for this commit to put the I/O of Q2/Q1 in
5683+
* the dispatch list. This is necessary, because, if also
5684+
* other queues are waiting for service, then putting new
5685+
* I/O directly in the dispatch list may evidently cause a
5686+
* violation of service guarantees for the other queues
5687+
*/
5688+
if (!bfqq ||
5689+
(bfqq != bfqd->in_service_queue &&
5690+
bfqd->in_service_queue != NULL &&
5691+
bfq_tot_busy_queues(bfqd) == 1 + bfq_bfqq_busy(bfqq) &&
5692+
(bfqq->waker_bfqq == bfqd->in_service_queue ||
5693+
bfqd->in_service_queue->waker_bfqq == bfqq)) ||
5694+
at_head || blk_rq_is_passthrough(rq)) {
56535695
if (at_head)
56545696
list_add(&rq->queuelist, &bfqd->dispatch);
56555697
else

0 commit comments

Comments
 (0)