Commit bec02dbb authored by Tejun Heo's avatar Tejun Heo Committed by Jens Axboe

iocost: consider iocgs with active delays for debt forgiveness

An iocg may have 0 debt but non-zero delay. The current debt forgiveness
logic doesn't act on such iocgs. This can lead to unexpected behaviors - an
iocg with a little bit of debt will have its delay canceled through debt
forgiveness but one w/o any debt but active delay will have to wait out
until its delay decays out.

This patch updates the debt handling logic so that it treats delays the same
as debts. If either debt or delay is active, debt forgiveness logic kicks in
and acts on both the same way.

Also, avoid turning the debt and delay directly to zero as that can confuse
state transitions.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent c5a6561b
...@@ -2048,7 +2048,7 @@ static void ioc_forgive_debts(struct ioc *ioc, u64 usage_us_sum, int nr_debtors, ...@@ -2048,7 +2048,7 @@ static void ioc_forgive_debts(struct ioc *ioc, u64 usage_us_sum, int nr_debtors,
list_for_each_entry(iocg, &ioc->active_iocgs, active_list) { list_for_each_entry(iocg, &ioc->active_iocgs, active_list) {
u64 __maybe_unused old_debt, __maybe_unused old_delay; u64 __maybe_unused old_debt, __maybe_unused old_delay;
if (!iocg->abs_vdebt) if (!iocg->abs_vdebt && !iocg->delay)
continue; continue;
spin_lock(&iocg->waitq.lock); spin_lock(&iocg->waitq.lock);
...@@ -2056,8 +2056,11 @@ static void ioc_forgive_debts(struct ioc *ioc, u64 usage_us_sum, int nr_debtors, ...@@ -2056,8 +2056,11 @@ static void ioc_forgive_debts(struct ioc *ioc, u64 usage_us_sum, int nr_debtors,
old_debt = iocg->abs_vdebt; old_debt = iocg->abs_vdebt;
old_delay = iocg->delay; old_delay = iocg->delay;
iocg->abs_vdebt >>= nr_cycles; if (iocg->abs_vdebt)
iocg->delay = 0; /* kick_waitq will recalc */ iocg->abs_vdebt = iocg->abs_vdebt >> nr_cycles ?: 1;
if (iocg->delay)
iocg->delay = iocg->delay >> nr_cycles ?: 1;
iocg_kick_waitq(iocg, true, now); iocg_kick_waitq(iocg, true, now);
TRACE_IOCG_PATH(iocg_forgive_debt, iocg, now, usage_pct, TRACE_IOCG_PATH(iocg_forgive_debt, iocg, now, usage_pct,
...@@ -2129,7 +2132,7 @@ static void ioc_timer_fn(struct timer_list *timer) ...@@ -2129,7 +2132,7 @@ static void ioc_timer_fn(struct timer_list *timer)
iocg->delay) { iocg->delay) {
/* might be oversleeping vtime / hweight changes, kick */ /* might be oversleeping vtime / hweight changes, kick */
iocg_kick_waitq(iocg, true, &now); iocg_kick_waitq(iocg, true, &now);
if (iocg->abs_vdebt) if (iocg->abs_vdebt || iocg->delay)
nr_debtors++; nr_debtors++;
} else if (iocg_is_idle(iocg)) { } else if (iocg_is_idle(iocg)) {
/* no waiter and idle, deactivate */ /* no waiter and idle, deactivate */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment