* [PATCH] blk-throttle: fix zero wait time for iops throttled group
@ 2019-07-08 15:29 Konstantin Khlebnikov
2019-07-08 19:08 ` Liu Bo
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Konstantin Khlebnikov @ 2019-07-08 15:29 UTC (permalink / raw)
To: linux-block, Jens Axboe, linux-kernel; +Cc: Liu Bo, stable
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+
---
block/blk-throttle.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 9ea7c0ecad10..8ab6c8153223 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] blk-throttle: fix zero wait time for iops throttled group
2019-07-08 15:29 [PATCH] blk-throttle: fix zero wait time for iops throttled group Konstantin Khlebnikov
@ 2019-07-08 19:08 ` Liu Bo
2019-07-09 7:18 ` Konstantin Khlebnikov
2019-07-10 10:42 ` Konstantin Khlebnikov
2019-07-10 14:00 ` Jens Axboe
2 siblings, 1 reply; 7+ messages in thread
From: Liu Bo @ 2019-07-08 19:08 UTC (permalink / raw)
To: Konstantin Khlebnikov; +Cc: linux-block, Jens Axboe, linux-kernel, stable
On Mon, Jul 08, 2019 at 06:29:57PM +0300, Konstantin Khlebnikov wrote:
> 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+
> ---
> block/blk-throttle.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/block/blk-throttle.c b/block/blk-throttle.c
> index 9ea7c0ecad10..8ab6c8153223 100644
> --- a/block/blk-throttle.c
> +++ b/block/blk-throttle.c
> @@ -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
Did you use a tiny iops limit to run into this?
thanks,
-liubo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] blk-throttle: fix zero wait time for iops throttled group
2019-07-08 19:08 ` Liu Bo
@ 2019-07-09 7:18 ` Konstantin Khlebnikov
0 siblings, 0 replies; 7+ messages in thread
From: Konstantin Khlebnikov @ 2019-07-09 7:18 UTC (permalink / raw)
To: bo.liu; +Cc: linux-block, Jens Axboe, linux-kernel, stable
On 08.07.2019 22:08, Liu Bo wrote:
> On Mon, Jul 08, 2019 at 06:29:57PM +0300, Konstantin Khlebnikov wrote:
>> 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+
>> ---
>> block/blk-throttle.c | 9 +++------
>> 1 file changed, 3 insertions(+), 6 deletions(-)
>>
>> diff --git a/block/blk-throttle.c b/block/blk-throttle.c
>> index 9ea7c0ecad10..8ab6c8153223 100644
>> --- a/block/blk-throttle.c
>> +++ b/block/blk-throttle.c
>> @@ -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
>
> Did you use a tiny iops limit to run into this?
Yep. 25 iops
also kernel built with HZ=250, this might be related
>
> thanks,
> -liubo
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] blk-throttle: fix zero wait time for iops throttled group
2019-07-08 15:29 [PATCH] blk-throttle: fix zero wait time for iops throttled group Konstantin Khlebnikov
2019-07-08 19:08 ` Liu Bo
@ 2019-07-10 10:42 ` Konstantin Khlebnikov
2019-07-10 14:00 ` Jens Axboe
2 siblings, 0 replies; 7+ messages in thread
From: Konstantin Khlebnikov @ 2019-07-10 10:42 UTC (permalink / raw)
To: linux-block, Jens Axboe, linux-kernel; +Cc: Liu Bo, Stable, cgroups
On 08.07.2019 18:29, Konstantin Khlebnikov wrote:
> 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.
To be clear: this almost instantly kills entire machine - other cpus stuck at sending ipi.
>
> 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+
> ---
> block/blk-throttle.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/block/blk-throttle.c b/block/blk-throttle.c
> index 9ea7c0ecad10..8ab6c8153223 100644
> --- a/block/blk-throttle.c
> +++ b/block/blk-throttle.c
> @@ -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
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] blk-throttle: fix zero wait time for iops throttled group
2019-07-08 15:29 [PATCH] blk-throttle: fix zero wait time for iops throttled group Konstantin Khlebnikov
2019-07-08 19:08 ` Liu Bo
2019-07-10 10:42 ` Konstantin Khlebnikov
@ 2019-07-10 14:00 ` Jens Axboe
2019-07-10 14:24 ` Konstantin Khlebnikov
2 siblings, 1 reply; 7+ messages in thread
From: Jens Axboe @ 2019-07-10 14:00 UTC (permalink / raw)
To: Konstantin Khlebnikov, linux-block, linux-kernel; +Cc: Liu Bo, stable
On 7/8/19 9:29 AM, Konstantin Khlebnikov wrote:
> 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.
Applied, thanks. In the future, please break lines at 72 chars in
commit messages, I fixed it up.
--
Jens Axboe
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] blk-throttle: fix zero wait time for iops throttled group
2019-07-10 14:00 ` Jens Axboe
@ 2019-07-10 14:24 ` Konstantin Khlebnikov
2019-07-10 14:25 ` Jens Axboe
0 siblings, 1 reply; 7+ messages in thread
From: Konstantin Khlebnikov @ 2019-07-10 14:24 UTC (permalink / raw)
To: Jens Axboe, linux-block, linux-kernel; +Cc: Liu Bo, stable
On 10.07.2019 17:00, Jens Axboe wrote:
> On 7/8/19 9:29 AM, Konstantin Khlebnikov wrote:
>> 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.
>
> Applied, thanks. In the future, please break lines at 72 chars in
> commit messages, I fixed it up.
>
Ok, but Documentation/process/submitting-patches.rst and
scripts/checkpatch.pl recommends 75 chars per line.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] blk-throttle: fix zero wait time for iops throttled group
2019-07-10 14:24 ` Konstantin Khlebnikov
@ 2019-07-10 14:25 ` Jens Axboe
0 siblings, 0 replies; 7+ messages in thread
From: Jens Axboe @ 2019-07-10 14:25 UTC (permalink / raw)
To: Konstantin Khlebnikov, linux-block, linux-kernel; +Cc: Liu Bo, stable
On 7/10/19 8:24 AM, Konstantin Khlebnikov wrote:
> On 10.07.2019 17:00, Jens Axboe wrote:
>> On 7/8/19 9:29 AM, Konstantin Khlebnikov wrote:
>>> 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.
>>
>> Applied, thanks. In the future, please break lines at 72 chars in
>> commit messages, I fixed it up.
>>
>
> Ok, but Documentation/process/submitting-patches.rst and
> scripts/checkpatch.pl recommends 75 chars per line.
Huh, oh well. Not a big deal for me, line breaking is easily automated.
--
Jens Axboe
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-07-10 14:25 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-08 15:29 [PATCH] blk-throttle: fix zero wait time for iops throttled group Konstantin Khlebnikov
2019-07-08 19:08 ` Liu Bo
2019-07-09 7:18 ` Konstantin Khlebnikov
2019-07-10 10:42 ` Konstantin Khlebnikov
2019-07-10 14:00 ` Jens Axboe
2019-07-10 14:24 ` Konstantin Khlebnikov
2019-07-10 14:25 ` 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).