iocost: recalculate delay after debt reduction
authorTejun Heo <tj@kernel.org>
Fri, 18 Sep 2020 00:44:54 +0000 (20:44 -0400)
committerJens Axboe <axboe@kernel.dk>
Fri, 25 Sep 2020 14:35:02 +0000 (08:35 -0600)
Debt sets the initial delay duration which is decayed over time. The current
debt reduction halved the debt but didn't change the delay. It prevented
future debts from increasing delay but didn't do anything to lower the
existing delay, limiting the mechanism's ability to reduce unnecessary
idling.

Reset iocg->delay to 0 after debt reduction so that iocg_kick_waitq()
recalculates new delay value based on the reduced debt amount.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-iocost.c

index c0499c294da90f617caf4bf32b1dc880be4a704b..ffcb78126ab700dd4188ede9843e2ed6962bc6bb 100644 (file)
@@ -1984,7 +1984,8 @@ static void transfer_surpluses(struct list_head *surpluses, struct ioc_now *now)
  * up blocked paying its debt while the IO device is idle.
  *
  * The following protects against such cases. If the device has been
- * sufficiently idle for a while, the debts are halved.
+ * sufficiently idle for a while, the debts are halved and delays are
+ * recalculated.
  */
 static void ioc_forgive_debts(struct ioc *ioc, u64 usage_us_sum, int nr_debtors,
                              struct ioc_now *now)
@@ -2002,6 +2003,7 @@ static void ioc_forgive_debts(struct ioc *ioc, u64 usage_us_sum, int nr_debtors,
                        if (iocg->abs_vdebt) {
                                spin_lock(&iocg->waitq.lock);
                                iocg->abs_vdebt /= 2;
+                               iocg->delay = 0; /* kick_waitq will recalc */
                                iocg_kick_waitq(iocg, true, now);
                                spin_unlock(&iocg->waitq.lock);
                        }