block, bfq: fix weight-raising resume with !low_latency
authorPaolo Valente <paolo.valente@linaro.org>
Thu, 4 Mar 2021 17:46:25 +0000 (18:46 +0100)
committerJens Axboe <axboe@kernel.dk>
Thu, 25 Mar 2021 16:50:07 +0000 (10:50 -0600)
When the io_latency heuristic is off, bfq_queues must not start to be
weight-raised. Unfortunately, by mistake, this may happen when the
state of a previously weight-raised bfq_queue is resumed after a queue
split. This commit fixes this error.

Tested-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-5-paolo.valente@linaro.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bfq-iosched.c

index b00dcc46bac77fef9f830a59ff5e2978a02e6d0a..2a84294b0525b2183526f2c2d9a80b010a4e5981 100644 (file)
@@ -1012,7 +1012,7 @@ static void
 bfq_bfqq_resume_state(struct bfq_queue *bfqq, struct bfq_data *bfqd,
                      struct bfq_io_cq *bic, bool bfq_already_existing)
 {
-       unsigned int old_wr_coeff = bfqq->wr_coeff;
+       unsigned int old_wr_coeff = 1;
        bool busy = bfq_already_existing && bfq_bfqq_busy(bfqq);
 
        if (bic->saved_has_short_ttime)
@@ -1033,7 +1033,13 @@ bfq_bfqq_resume_state(struct bfq_queue *bfqq, struct bfq_data *bfqd,
        bfqq->ttime = bic->saved_ttime;
        bfqq->io_start_time = bic->saved_io_start_time;
        bfqq->tot_idle_time = bic->saved_tot_idle_time;
-       bfqq->wr_coeff = bic->saved_wr_coeff;
+       /*
+        * Restore weight coefficient only if low_latency is on
+        */
+       if (bfqd->low_latency) {
+               old_wr_coeff = bfqq->wr_coeff;
+               bfqq->wr_coeff = bic->saved_wr_coeff;
+       }
        bfqq->service_from_wr = bic->saved_service_from_wr;
        bfqq->wr_start_at_switch_to_srt = bic->saved_wr_start_at_switch_to_srt;
        bfqq->last_wr_start_finish = bic->saved_last_wr_start_finish;