block, bfq: do not tag totally seeky queues as soft rt
authorPaolo Valente <paolo.valente@linaro.org>
Tue, 12 Mar 2019 08:59:31 +0000 (09:59 +0100)
committerJens Axboe <axboe@kernel.dk>
Mon, 1 Apr 2019 14:15:40 +0000 (08:15 -0600)
Sync random I/O is likely to be confused with soft real-time I/O,
because it is characterized by limited throughput and apparently
isochronous arrival pattern. To avoid false positives, this commits
prevents bfq_queues containing only random (seeky) I/O from being
tagged as soft real-time.

Tested-by: Holger Hoffstätte <holger@applied-asynchrony.com>
Tested-by: Oleksandr Natalenko <oleksandr@natalenko.name>
Signed-off-by: Paolo Valente <paolo.valente@linaro.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bfq-iosched.c

index b957e9d..7044da0 100644 (file)
@@ -242,6 +242,14 @@ static struct kmem_cache *bfq_pool;
          blk_rq_sectors(rq) < BFQQ_SECT_THR_NONROT))
 #define BFQQ_CLOSE_THR         (sector_t)(8 * 1024)
 #define BFQQ_SEEKY(bfqq)       (hweight32(bfqq->seek_history) > 19)
+/*
+ * Sync random I/O is likely to be confused with soft real-time I/O,
+ * because it is characterized by limited throughput and apparently
+ * isochronous arrival pattern. To avoid false positives, queues
+ * containing only random (seeky) I/O are prevented from being tagged
+ * as soft real-time.
+ */
+#define BFQQ_TOTALLY_SEEKY(bfqq)       (bfqq->seek_history & -1)
 
 /* Min number of samples required to perform peak-rate update */
 #define BFQ_RATE_MIN_SAMPLES   32
@@ -1622,6 +1630,7 @@ static void bfq_bfqq_handle_idle_busy_switch(struct bfq_data *bfqd,
         */
        in_burst = bfq_bfqq_in_large_burst(bfqq);
        soft_rt = bfqd->bfq_wr_max_softrt_rate > 0 &&
+               !BFQQ_TOTALLY_SEEKY(bfqq) &&
                !in_burst &&
                time_is_before_jiffies(bfqq->soft_rt_next_start) &&
                bfqq->dispatched == 0;
@@ -4816,6 +4825,11 @@ bfq_update_io_seektime(struct bfq_data *bfqd, struct bfq_queue *bfqq,
 {
        bfqq->seek_history <<= 1;
        bfqq->seek_history |= BFQ_RQ_SEEKY(bfqd, bfqq->last_request_pos, rq);
+
+       if (bfqq->wr_coeff > 1 &&
+           bfqq->wr_cur_max_time == bfqd->bfq_wr_rt_max_time &&
+           BFQQ_TOTALLY_SEEKY(bfqq))
+               bfq_bfqq_end_wr(bfqq);
 }
 
 static void bfq_update_has_short_ttime(struct bfq_data *bfqd,