Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iocost: improve nr_lagging handling

Some IOs may span multiple periods. As latencies are collected on
completion, the inbetween periods won't register them and may
incorrectly decide to increase vrate. nr_lagging tracks these IOs to
avoid those situations. Currently, whenever there are IOs which are
spanning from the previous period, busy_level is reset to 0 if
negative thus suppressing vrate increase.

This has the following two problems.

* When latency target percentiles aren't set, vrate adjustment should
only be governed by queue depth depletion; however, the current code
keeps nr_lagging active which pulls in latency results and can keep
down vrate unexpectedly.

* When lagging condition is detected, it resets the entire negative
busy_level. This turned out to be way too aggressive on some
devices which sometimes experience extended latencies on a small
subset of commands. In addition, a lagging IO will be accounted as
latency target miss on completion anyway and resetting busy_level
amplifies its impact unnecessarily.

This patch fixes the above two problems by disabling nr_lagging
counting when latency target percentiles aren't set and blocking vrate
increases when there are lagging IOs while leaving busy_level as-is.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Tejun Heo and committed by
Jens Axboe
7cd806a9 25d41e4a

+11 -8
+11 -8
block/blk-iocost.c
··· 1407 1407 * comparing vdone against period start. If lagging behind 1408 1408 * IOs from past periods, don't increase vrate. 1409 1409 */ 1410 - if (!atomic_read(&iocg_to_blkg(iocg)->use_delay) && 1410 + if ((ppm_rthr != MILLION || ppm_wthr != MILLION) && 1411 + !atomic_read(&iocg_to_blkg(iocg)->use_delay) && 1411 1412 time_after64(vtime, vdone) && 1412 1413 time_after64(vtime, now.vnow - 1413 1414 MAX_LAGGING_PERIODS * period_vtime) && ··· 1538 1537 missed_ppm[WRITE] > ppm_wthr) { 1539 1538 ioc->busy_level = max(ioc->busy_level, 0); 1540 1539 ioc->busy_level++; 1541 - } else if (nr_lagging) { 1542 - ioc->busy_level = max(ioc->busy_level, 0); 1543 - } else if (nr_shortages && !nr_surpluses && 1544 - rq_wait_pct <= RQ_WAIT_BUSY_PCT * UNBUSY_THR_PCT / 100 && 1540 + } else if (rq_wait_pct <= RQ_WAIT_BUSY_PCT * UNBUSY_THR_PCT / 100 && 1545 1541 missed_ppm[READ] <= ppm_rthr * UNBUSY_THR_PCT / 100 && 1546 1542 missed_ppm[WRITE] <= ppm_wthr * UNBUSY_THR_PCT / 100) { 1547 - ioc->busy_level = min(ioc->busy_level, 0); 1548 - ioc->busy_level--; 1543 + /* take action iff there is contention */ 1544 + if (nr_shortages && !nr_lagging) { 1545 + ioc->busy_level = min(ioc->busy_level, 0); 1546 + /* redistribute surpluses first */ 1547 + if (!nr_surpluses) 1548 + ioc->busy_level--; 1549 + } 1549 1550 } else { 1550 1551 ioc->busy_level = 0; 1551 1552 } 1552 1553 1553 1554 ioc->busy_level = clamp(ioc->busy_level, -1000, 1000); 1554 1555 1555 - if (ioc->busy_level) { 1556 + if (ioc->busy_level > 0 || (ioc->busy_level < 0 && !nr_lagging)) { 1556 1557 u64 vrate = atomic64_read(&ioc->vtime_rate); 1557 1558 u64 vrate_min = ioc->vrate_min, vrate_max = ioc->vrate_max; 1558 1559