]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
blk-throttle: fix zero wait time for iops throttled group
authorKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
Mon, 8 Jul 2019 15:29:57 +0000 (18:29 +0300)
committerJens Axboe <axboe@kernel.dk>
Wed, 10 Jul 2019 15:00:57 +0000 (09:00 -0600)
After commit 991f61fe7e1d ("Blk-throttle: reduce tail io latency when
iops limit is enforced") wait time could be zero even if group is
throttled and cannot issue requests right now. As a result
throtl_select_dispatch() turns into busy-loop under irq-safe queue
spinlock.

Fix is simple: always round up target time to the next throttle slice.

Fixes: 991f61fe7e1d ("Blk-throttle: reduce tail io latency when iops limit is enforced")
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Cc: stable@vger.kernel.org # v4.19+
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-throttle.c

index 9ea7c0ecad100a41301782cf8be6b14e820eba3e..8ab6c8153223630a6b8d4b6fc4b1acc23ad8fc04 100644 (file)
@@ -881,13 +881,10 @@ static bool tg_with_in_iops_limit(struct throtl_grp *tg, struct bio *bio,
        unsigned long jiffy_elapsed, jiffy_wait, jiffy_elapsed_rnd;
        u64 tmp;
 
-       jiffy_elapsed = jiffy_elapsed_rnd = jiffies - tg->slice_start[rw];
-
-       /* Slice has just started. Consider one slice interval */
-       if (!jiffy_elapsed)
-               jiffy_elapsed_rnd = tg->td->throtl_slice;
+       jiffy_elapsed = jiffies - tg->slice_start[rw];
 
-       jiffy_elapsed_rnd = roundup(jiffy_elapsed_rnd, tg->td->throtl_slice);
+       /* Round up to the next throttle slice, wait time must be nonzero */
+       jiffy_elapsed_rnd = roundup(jiffy_elapsed + 1, tg->td->throtl_slice);
 
        /*
         * jiffy_elapsed_rnd should not be a big value as minimum iops can be