linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH block/for-linus] iocost: don't let vrate run wild while there's no saturation signal
@ 2019-10-15  0:18 Tejun Heo
  2020-05-14 14:51 ` Tejun Heo
  0 siblings, 1 reply; 3+ messages in thread
From: Tejun Heo @ 2019-10-15  0:18 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, linux-kernel, kernel-team, newella

When the QoS targets are met and nothing is being throttled, there's
no way to tell how saturated the underlying device is - it could be
almost entirely idle, at the cusp of saturation or anywhere inbetween.
Given that there's no information, it's best to keep vrate as-is in
this state.  Before 7cd806a9a953 ("iocost: improve nr_lagging
handling"), this was the case - if the device isn't missing QoS
targets and nothing is being throttled, busy_level was reset to zero.

While fixing nr_lagging handling, 7cd806a9a953 ("iocost: improve
nr_lagging handling") broke this.  Now, while the device is hitting
QoS targets and nothing is being throttled, vrate keeps getting
adjusted according to the existing busy_level.

This led to vrate keeping climing till it hits max when there's an IO
issuer with limited request concurrency if the vrate started low.
vrate starts getting adjusted upwards until the issuer can issue IOs
w/o being throttled.  From then on, QoS targets keeps getting met and
nothing on the system needs throttling and vrate keeps getting
increased due to the existing busy_level.

This patch makes the following changes to the busy_level logic.

* Reset busy_level if nr_shortages is zero to avoid the above
  scenario.

* Make non-zero nr_lagging block lowering nr_level but still clear
  positive busy_level if there's clear non-saturation signal - QoS
  targets are met and nr_shortages is non-zero.  nr_lagging's role is
  preventing adjusting vrate upwards while there are long-running
  commands and it shouldn't keep busy_level positive while there's
  clear non-saturation signal.

* Restructure code for clarity and add comments.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Andy Newell <newella@fb.com>
Fixes: 7cd806a9a953 ("iocost: improve nr_lagging handling")
---
 block/blk-iocost.c |   28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index 2a3db80c1dce..b6326ab5ffe7 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -1536,19 +1536,39 @@ static void ioc_timer_fn(struct timer_list *timer)
 	if (rq_wait_pct > RQ_WAIT_BUSY_PCT ||
 	    missed_ppm[READ] > ppm_rthr ||
 	    missed_ppm[WRITE] > ppm_wthr) {
+		/* clearly missing QoS targets, slow down vrate */
 		ioc->busy_level = max(ioc->busy_level, 0);
 		ioc->busy_level++;
 	} else if (rq_wait_pct <= RQ_WAIT_BUSY_PCT * UNBUSY_THR_PCT / 100 &&
 		   missed_ppm[READ] <= ppm_rthr * UNBUSY_THR_PCT / 100 &&
 		   missed_ppm[WRITE] <= ppm_wthr * UNBUSY_THR_PCT / 100) {
-		/* take action iff there is contention */
-		if (nr_shortages && !nr_lagging) {
+		/* QoS targets are being met with >25% margin */
+		if (nr_shortages) {
+			/*
+			 * We're throttling while the device has spare
+			 * capacity.  If vrate was being slowed down, stop.
+			 */
 			ioc->busy_level = min(ioc->busy_level, 0);
-			/* redistribute surpluses first */
-			if (!nr_surpluses)
+
+			/*
+			 * If there are IOs spanning multiple periods, wait
+			 * them out before pushing the device harder.  If
+			 * there are surpluses, let redistribution work it
+			 * out first.
+			 */
+			if (!nr_lagging && !nr_surpluses)
 				ioc->busy_level--;
+		} else {
+			/*
+			 * Nobody is being throttled and the users aren't
+			 * issuing enough IOs to saturate the device.  We
+			 * simply don't know how close the device is to
+			 * saturation.  Coast.
+			 */
+			ioc->busy_level = 0;
 		}
 	} else {
+		/* inside the hysterisis margin, we're good */
 		ioc->busy_level = 0;
 	}
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH block/for-linus] iocost: don't let vrate run wild while there's no saturation signal
  2019-10-15  0:18 [PATCH block/for-linus] iocost: don't let vrate run wild while there's no saturation signal Tejun Heo
@ 2020-05-14 14:51 ` Tejun Heo
  2020-05-14 15:34   ` Jens Axboe
  0 siblings, 1 reply; 3+ messages in thread
From: Tejun Heo @ 2020-05-14 14:51 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, linux-kernel, kernel-team, newella

On Mon, Oct 14, 2019 at 05:18:11PM -0700, Tejun Heo wrote:
> When the QoS targets are met and nothing is being throttled, there's
> no way to tell how saturated the underlying device is - it could be
> almost entirely idle, at the cusp of saturation or anywhere inbetween.
> Given that there's no information, it's best to keep vrate as-is in
> this state.  Before 7cd806a9a953 ("iocost: improve nr_lagging
> handling"), this was the case - if the device isn't missing QoS
> targets and nothing is being throttled, busy_level was reset to zero.
...
> Signed-off-by: Tejun Heo <tj@kernel.org>
> Reported-by: Andy Newell <newella@fb.com>
> Fixes: 7cd806a9a953 ("iocost: improve nr_lagging handling")

Jens, this one fell through the cracks. It still applies with only a small
offset. Can you please apply?

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH block/for-linus] iocost: don't let vrate run wild while there's no saturation signal
  2020-05-14 14:51 ` Tejun Heo
@ 2020-05-14 15:34   ` Jens Axboe
  0 siblings, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2020-05-14 15:34 UTC (permalink / raw)
  To: Tejun Heo; +Cc: linux-block, linux-kernel, kernel-team, newella

On 5/14/20 8:51 AM, Tejun Heo wrote:
> On Mon, Oct 14, 2019 at 05:18:11PM -0700, Tejun Heo wrote:
>> When the QoS targets are met and nothing is being throttled, there's
>> no way to tell how saturated the underlying device is - it could be
>> almost entirely idle, at the cusp of saturation or anywhere inbetween.
>> Given that there's no information, it's best to keep vrate as-is in
>> this state.  Before 7cd806a9a953 ("iocost: improve nr_lagging
>> handling"), this was the case - if the device isn't missing QoS
>> targets and nothing is being throttled, busy_level was reset to zero.
> ...
>> Signed-off-by: Tejun Heo <tj@kernel.org>
>> Reported-by: Andy Newell <newella@fb.com>
>> Fixes: 7cd806a9a953 ("iocost: improve nr_lagging handling")
> 
> Jens, this one fell through the cracks. It still applies with only a small
> offset. Can you please apply?

Looks like it did, queued up for 5.8 now.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-14 15:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-15  0:18 [PATCH block/for-linus] iocost: don't let vrate run wild while there's no saturation signal Tejun Heo
2020-05-14 14:51 ` Tejun Heo
2020-05-14 15:34   ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).