* [PATCH] Block: initialize bio_cnt_ret_time for the first time
@ 2018-06-21 3:07 Liu Bo
2018-06-29 19:50 ` Liu Bo
2018-06-29 20:00 ` Jens Axboe
0 siblings, 2 replies; 8+ messages in thread
From: Liu Bo @ 2018-06-21 3:07 UTC (permalink / raw)
To: linux-block
When a new tg is created, tg->bio_cnt_ret_time is 0, so if the first
IO going thru this tg turns out to be a bad one, we fail to record it
in tg->bad_bio_cnt as
if (jiffies > bio_cnt_ret_time) {
tg->bad_bio_cnt /= 2;
}
Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
---
block/blk-throttle.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 82282e6fdcf8..8bd54118dc0a 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -2329,6 +2329,8 @@ void blk_throtl_bio_endio(struct bio *bio)
tg->bio_cnt++;
}
+ if (unlikely(!tg->bio_cnt_reset_time))
+ tg->bio_cnt_reset_time = jiffies;
if (time_after(jiffies, tg->bio_cnt_reset_time) || tg->bio_cnt > 1024) {
tg->bio_cnt_reset_time = tg->td->throtl_slice + jiffies;
tg->bio_cnt /= 2;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH] Block: initialize bio_cnt_ret_time for the first time 2018-06-21 3:07 [PATCH] Block: initialize bio_cnt_ret_time for the first time Liu Bo @ 2018-06-29 19:50 ` Liu Bo 2018-06-29 20:00 ` Jens Axboe 1 sibling, 0 replies; 8+ messages in thread From: Liu Bo @ 2018-06-29 19:50 UTC (permalink / raw) To: Jens Axboe; +Cc: linux-block, Liu Bo Hi Jens, This one is kind of obvious, could you please also take it thru your tree? thanks, liubo On Wed, Jun 20, 2018 at 8:07 PM, Liu Bo <bo.liu@linux.alibaba.com> wrote: > When a new tg is created, tg->bio_cnt_ret_time is 0, so if the first > IO going thru this tg turns out to be a bad one, we fail to record it > in tg->bad_bio_cnt as > > if (jiffies > bio_cnt_ret_time) { > tg->bad_bio_cnt /= 2; > } > > Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com> > --- > block/blk-throttle.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/block/blk-throttle.c b/block/blk-throttle.c > index 82282e6fdcf8..8bd54118dc0a 100644 > --- a/block/blk-throttle.c > +++ b/block/blk-throttle.c > @@ -2329,6 +2329,8 @@ void blk_throtl_bio_endio(struct bio *bio) > tg->bio_cnt++; > } > > + if (unlikely(!tg->bio_cnt_reset_time)) > + tg->bio_cnt_reset_time = jiffies; > if (time_after(jiffies, tg->bio_cnt_reset_time) || tg->bio_cnt > 1024) { > tg->bio_cnt_reset_time = tg->td->throtl_slice + jiffies; > tg->bio_cnt /= 2; > -- > 1.8.3.1 > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Block: initialize bio_cnt_ret_time for the first time 2018-06-21 3:07 [PATCH] Block: initialize bio_cnt_ret_time for the first time Liu Bo 2018-06-29 19:50 ` Liu Bo @ 2018-06-29 20:00 ` Jens Axboe 2018-06-29 20:23 ` Liu Bo 1 sibling, 1 reply; 8+ messages in thread From: Jens Axboe @ 2018-06-29 20:00 UTC (permalink / raw) To: Liu Bo, linux-block On 6/20/18 9:07 PM, Liu Bo wrote: > When a new tg is created, tg->bio_cnt_ret_time is 0, so if the first > IO going thru this tg turns out to be a bad one, we fail to record it > in tg->bad_bio_cnt as > > if (jiffies > bio_cnt_ret_time) { > tg->bad_bio_cnt /= 2; > } Shouldn't we rather ensure that ->bio_cnt_ret_time is initialized to jiffies? -- Jens Axboe ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Block: initialize bio_cnt_ret_time for the first time 2018-06-29 20:00 ` Jens Axboe @ 2018-06-29 20:23 ` Liu Bo 2018-06-29 20:26 ` Jens Axboe 0 siblings, 1 reply; 8+ messages in thread From: Liu Bo @ 2018-06-29 20:23 UTC (permalink / raw) To: Jens Axboe; +Cc: linux-block On Fri, Jun 29, 2018 at 02:00:01PM -0600, Jens Axboe wrote: > On 6/20/18 9:07 PM, Liu Bo wrote: > > When a new tg is created, tg->bio_cnt_ret_time is 0, so if the first > > IO going thru this tg turns out to be a bad one, we fail to record it > > in tg->bad_bio_cnt as > > > > if (jiffies > bio_cnt_ret_time) { > > tg->bad_bio_cnt /= 2; > > } > > Shouldn't we rather ensure that ->bio_cnt_ret_time is initialized to > jiffies? > Indeed, it's what the patch does, i.e. initialize tg->bio_cnt_reset_time to jiffies on the first use. thanks, -liubo ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Block: initialize bio_cnt_ret_time for the first time 2018-06-29 20:23 ` Liu Bo @ 2018-06-29 20:26 ` Jens Axboe 2018-06-29 20:43 ` Liu Bo 0 siblings, 1 reply; 8+ messages in thread From: Jens Axboe @ 2018-06-29 20:26 UTC (permalink / raw) To: bo.liu; +Cc: linux-block On 6/29/18 2:23 PM, Liu Bo wrote: > On Fri, Jun 29, 2018 at 02:00:01PM -0600, Jens Axboe wrote: >> On 6/20/18 9:07 PM, Liu Bo wrote: >>> When a new tg is created, tg->bio_cnt_ret_time is 0, so if the first >>> IO going thru this tg turns out to be a bad one, we fail to record it >>> in tg->bad_bio_cnt as >>> >>> if (jiffies > bio_cnt_ret_time) { >>> tg->bad_bio_cnt /= 2; >>> } >> >> Shouldn't we rather ensure that ->bio_cnt_ret_time is initialized to >> jiffies? >> > > Indeed, it's what the patch does, i.e. initialize tg->bio_cnt_reset_time to > jiffies on the first use. You do it on the first use, on the hot path, presumable. My suggestion was to do it when tg is instantiated instead. From a quick look, that would appear to be in throtl_pd_alloc(). -- Jens Axboe ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Block: initialize bio_cnt_ret_time for the first time 2018-06-29 20:26 ` Jens Axboe @ 2018-06-29 20:43 ` Liu Bo 2018-06-29 20:46 ` Jens Axboe 0 siblings, 1 reply; 8+ messages in thread From: Liu Bo @ 2018-06-29 20:43 UTC (permalink / raw) To: Jens Axboe; +Cc: linux-block On Fri, Jun 29, 2018 at 02:26:07PM -0600, Jens Axboe wrote: > On 6/29/18 2:23 PM, Liu Bo wrote: > > On Fri, Jun 29, 2018 at 02:00:01PM -0600, Jens Axboe wrote: > >> On 6/20/18 9:07 PM, Liu Bo wrote: > >>> When a new tg is created, tg->bio_cnt_ret_time is 0, so if the first > >>> IO going thru this tg turns out to be a bad one, we fail to record it > >>> in tg->bad_bio_cnt as > >>> > >>> if (jiffies > bio_cnt_ret_time) { > >>> tg->bad_bio_cnt /= 2; > >>> } > >> > >> Shouldn't we rather ensure that ->bio_cnt_ret_time is initialized to > >> jiffies? > >> > > > > Indeed, it's what the patch does, i.e. initialize tg->bio_cnt_reset_time to > > jiffies on the first use. > > You do it on the first use, on the hot path, presumable. My suggestion > was to do it when tg is instantiated instead. From a quick look, that > would appear to be in throtl_pd_alloc(). > Doing it when tg is instantiated would end up with the same problem. 1) tg is instantiated, tg->bio_cnt_reset_time is set to jiffies. (after a few jiffies...) 2) the 1st IO gets dispatched and reaches endio. 2.1) tg->bad_bio_cnt++ #if the IO's latency > threshold. 2.2) if (jiffies > bio_cnt_reset_time) At 2.2), (the jiffies at this point > tg->bio_cnt_reset_time). If this IO is a bad one, then tg->bad_bio_cnt would become 0 instead of 1 since we do tg->bad_bio_cnt /= 2 in the if statement. thanks, -liubo ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Block: initialize bio_cnt_ret_time for the first time 2018-06-29 20:43 ` Liu Bo @ 2018-06-29 20:46 ` Jens Axboe 2018-06-29 21:41 ` Liu Bo 0 siblings, 1 reply; 8+ messages in thread From: Jens Axboe @ 2018-06-29 20:46 UTC (permalink / raw) To: bo.liu; +Cc: linux-block On 6/29/18 2:43 PM, Liu Bo wrote: > On Fri, Jun 29, 2018 at 02:26:07PM -0600, Jens Axboe wrote: >> On 6/29/18 2:23 PM, Liu Bo wrote: >>> On Fri, Jun 29, 2018 at 02:00:01PM -0600, Jens Axboe wrote: >>>> On 6/20/18 9:07 PM, Liu Bo wrote: >>>>> When a new tg is created, tg->bio_cnt_ret_time is 0, so if the first >>>>> IO going thru this tg turns out to be a bad one, we fail to record it >>>>> in tg->bad_bio_cnt as >>>>> >>>>> if (jiffies > bio_cnt_ret_time) { >>>>> tg->bad_bio_cnt /= 2; >>>>> } >>>> >>>> Shouldn't we rather ensure that ->bio_cnt_ret_time is initialized to >>>> jiffies? >>>> >>> >>> Indeed, it's what the patch does, i.e. initialize tg->bio_cnt_reset_time to >>> jiffies on the first use. >> >> You do it on the first use, on the hot path, presumable. My suggestion >> was to do it when tg is instantiated instead. From a quick look, that >> would appear to be in throtl_pd_alloc(). >> > > Doing it when tg is instantiated would end up with the same problem. > > 1) tg is instantiated, tg->bio_cnt_reset_time is set to jiffies. > (after a few jiffies...) > 2) the 1st IO gets dispatched and reaches endio. > 2.1) tg->bad_bio_cnt++ #if the IO's latency > threshold. > 2.2) if (jiffies > bio_cnt_reset_time) > > At 2.2), (the jiffies at this point > tg->bio_cnt_reset_time). If > this IO is a bad one, then tg->bad_bio_cnt would become 0 instead of 1 > since we do tg->bad_bio_cnt /= 2 in the if statement. That's kind of an ugly way to use it. How is it any different from when the tg has been idle for a while? There shouldn't be a need to special case this. -- Jens Axboe ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Block: initialize bio_cnt_ret_time for the first time 2018-06-29 20:46 ` Jens Axboe @ 2018-06-29 21:41 ` Liu Bo 0 siblings, 0 replies; 8+ messages in thread From: Liu Bo @ 2018-06-29 21:41 UTC (permalink / raw) To: Jens Axboe; +Cc: linux-block On Fri, Jun 29, 2018 at 02:46:27PM -0600, Jens Axboe wrote: > On 6/29/18 2:43 PM, Liu Bo wrote: > > On Fri, Jun 29, 2018 at 02:26:07PM -0600, Jens Axboe wrote: > >> On 6/29/18 2:23 PM, Liu Bo wrote: > >>> On Fri, Jun 29, 2018 at 02:00:01PM -0600, Jens Axboe wrote: > >>>> On 6/20/18 9:07 PM, Liu Bo wrote: > >>>>> When a new tg is created, tg->bio_cnt_ret_time is 0, so if the first > >>>>> IO going thru this tg turns out to be a bad one, we fail to record it > >>>>> in tg->bad_bio_cnt as > >>>>> > >>>>> if (jiffies > bio_cnt_ret_time) { > >>>>> tg->bad_bio_cnt /= 2; > >>>>> } > >>>> > >>>> Shouldn't we rather ensure that ->bio_cnt_ret_time is initialized to > >>>> jiffies? > >>>> > >>> > >>> Indeed, it's what the patch does, i.e. initialize tg->bio_cnt_reset_time to > >>> jiffies on the first use. > >> > >> You do it on the first use, on the hot path, presumable. My suggestion > >> was to do it when tg is instantiated instead. From a quick look, that > >> would appear to be in throtl_pd_alloc(). > >> > > > > Doing it when tg is instantiated would end up with the same problem. > > > > 1) tg is instantiated, tg->bio_cnt_reset_time is set to jiffies. > > (after a few jiffies...) > > 2) the 1st IO gets dispatched and reaches endio. > > 2.1) tg->bad_bio_cnt++ #if the IO's latency > threshold. > > 2.2) if (jiffies > bio_cnt_reset_time) > > > > At 2.2), (the jiffies at this point > tg->bio_cnt_reset_time). If > > this IO is a bad one, then tg->bad_bio_cnt would become 0 instead of 1 > > since we do tg->bad_bio_cnt /= 2 in the if statement. > > That's kind of an ugly way to use it. How is it any different from when > the tg has been idle for a while? There shouldn't be a need to special > case this. Yes, we can leave this corner case alone. thanks, -liubo ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-06-29 21:42 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-06-21 3:07 [PATCH] Block: initialize bio_cnt_ret_time for the first time Liu Bo 2018-06-29 19:50 ` Liu Bo 2018-06-29 20:00 ` Jens Axboe 2018-06-29 20:23 ` Liu Bo 2018-06-29 20:26 ` Jens Axboe 2018-06-29 20:43 ` Liu Bo 2018-06-29 20:46 ` Jens Axboe 2018-06-29 21:41 ` Liu Bo
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox