blk-throttle: fix zero wait time for iops throttled group
Subsystems (4)
PATCH 1/1 blk-throttle: fix zero wait time for iops throttled group
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.
--- block/blk-throttle.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
block/blk-throttle.c +3 -6
@@ -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
Quoted 25 lines · Konstantin Khlebnikov
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 resultthrotl_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 <[email protected]>Cc [email protected] # v4.19+--- block/blk-throttle.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)block/blk-throttle.c +0
-3@@ -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 */
block/blk-throttle.c static bool tg_with_in_iops_limit(struct throtl_grp *tg, struct bio *bio, · line 890
Quoted 10 lines
block/blk-throttle.c +3
-3-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
Quoted 30 lines · Liu Bo
Quoted 29 lines · Konstantin Khlebnikov
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 resultthrotl_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 <[email protected]>Cc [email protected] # v4.19+--- block/blk-throttle.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)block/blk-throttle.c +1
-5@@ -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];
Quoted 8 lines
block/blk-throttle.c static bool tg_with_in_iops_limit(struct throtl_grp *tg, struct bio *bio, · line 890
Quoted 6 lines
block/blk-throttle.c +2
-1- 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
Quoted 4 lines
thanks,
-liubo
Quoted 4 lines · Konstantin Khlebnikov
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 resultthrotl_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.
Quoted 32 lines
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 <[email protected]>Cc [email protected] # v4.19+--- block/blk-throttle.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)block/blk-throttle.c +3
-6@@ -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
Quoted 6 lines · Konstantin Khlebnikov
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 resultthrotl_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.
Signature · 1 line
Jens Axboe
Quoted 11 lines · Jens Axboe
Quoted 6 lines · Konstantin Khlebnikov
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 resultthrotl_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.
Jens Axboe
maintainerQuoted 7 lines · Konstantin Khlebnikov
Quoted 6 lines · Jens Axboe
Quoted 5 lines · Konstantin Khlebnikov
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 resultthrotl_select_dispatch()turns into busy-loop under irq-safe queue spinlock.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
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.rstandscripts/checkpatch.plrecommends 75 chars per line.
Huh, oh well. Not a big deal for me, line breaking is easily automated.
Signature · 1 line
Jens Axboe