blk-iocost: fix false positive lagging
Subsystems (2)
PATCH 1/1 blk-iocost: fix false positive lagging
I found many false positive lagging during iocost test.
Since iocg->vtime will be advanced to (vnow - margins.target) in hweight_after_donation(), which called throw away excess, the iocg->done_vtime will also be advanced that much.
period_at_vtime <--period_vtime--> vnow
| |
--------------------------------------------------->
|<--->|
margins.target
|-> vtime, done_vtime
If that iocg has some inflight io when vnow, but its done_vtime is before period_at_vtime, ioc_timer_fn() will think it has lagging io, even these io maybe issued just before now.
This patch change the condition to check if vdone is before (period_at_vtime - margins.target) instead of period_at_vtime.
But there is another problem that this patch doesn't fix. Since vtime will be advanced, we can't check if vtime is after (vnow - MAX_LAGGING_PERIODS * period_vtime) to tell whether this iocg pin lagging for too long.
Maybe we can add lagging_periods in iocg to record how many periods this iocg pin lagging, but I don't know when to clean it.
--- block/blk-iocost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-iocost.c +1 -1
@@ -2259,7 +2259,7 @@ static void ioc_timer_fn(struct timer_list *timer)time_after64 (vtime, vdone) &&time_after64 (vtime, now.vnow -MAX_LAGGING_PERIODS * period_vtime) && - time_before64(vdone, now.vnow - period_vtime)) + time_before64(vdone, ioc->period_at_vtime - ioc->margins.target)) nr_lagging++;/*
Signature · 1 line
2.36.1
Tejun Heo
maintainerHello,
Quoted 6 lines · Chengming Zhou
I found many false positive lagging during iocost test.
Since
iocg->vtimewill be advanced to (vnow - margins.target) inhweight_after_donation(), which called throw away excess, theiocg->done_vtimewill also be advanced that much.
Quoted 7 lines
period_at_vtime <--period_vtime--> vnow | | ---------------------------------------------------> |<--->| margins.target |->vtime,
done_vtime
All it does is shifting the vtime (and done_vtime) within the current window so that we don't build up budget too lage a budget possibly spanning multiple periods. The lagging detection is supposed to detect IOs which are issued two+ periods ago which didn't finish in the last period. So, I don't think the above sliding up the window affects that detection given that the lagging detection is done before the window sliding. All it's checking is whether there still are in-flight IOs which were issued two+ windows ago, so how the last window has been fast forwarded shouldn't affect the detection, no?
Thanks.
Signature · 1 line
tejun
Hello,
Quoted 17 lines · Tejun Heo
Hello,
Quoted 6 lines · Chengming Zhou
I found many false positive lagging during iocost test.
Since
iocg->vtimewill be advanced to (vnow - margins.target) inhweight_after_donation(), which called throw away excess, theiocg->done_vtimewill also be advanced that much.Quoted 7 lines
period_at_vtime <--period_vtime--> vnow | | ---------------------------------------------------> |<--->| margins.target |->vtime,
done_vtime
Quoted 3 lines
All it does is shifting the vtime (and
done_vtime) within the current window so that we don't build up budget too lage a budget possibly spanning multiple periods.
Yes, this is necessary. Suppose in the last timer, the iocg doesn't have inflights and have excess, then iocg->vtime = iocg->done_vtime = (period_at_vtime - margins.target)
Quoted 2 lines
The lagging detection is supposed to detect IOs which are issued two+ periods ago which didn't finish in the last period. So, I don't
Yes, I understand.
Quoted 5 lines
think the above sliding up the window affects that detection given that the lagging detection is done before the window sliding. All it's checking is whether there still are in-flight IOs which were issued two+ windows ago, so how the last window has been fast forwarded shouldn't affect the detection, no?
Right, the lagging detection is done before the window sliding in this period timer. The conditions that it checks vtime, done_vtime have been slided in the last timer.
time_after64(vtime, vdone) &&time_after64(vtime, now.vnow - MAX_LAGGING_PERIODS * period_vtime) && time_before64(vdone, now.vnow - period_vtime)
The first condition says it has some inflights, the second condition is always true if vtime has been slided in the last timer, the third condition will be true if the cost of io completed since last timer < ioc->margins.target.
So I think it doesn't check correctly whether it has inflights that were issued two+ windows ago.
Thanks.
Quoted 3 lines
Thanks.
Quoted 21 lines · Chengming Zhou
I found many false positive lagging during iocost test.
Since
iocg->vtimewill be advanced to (vnow - margins.target) inhweight_after_donation(), which called throw away excess, theiocg->done_vtimewill also be advanced that much.period_at_vtime <--period_vtime--> vnow | | ---------------------------------------------------> |<--->| margins.target |->vtime,
done_vtimeIf that iocg has some inflight io when vnow, but its
done_vtimeis beforeperiod_at_vtime,ioc_timer_fn()will think it has lagging io, even these io maybe issued just before now.This patch change the condition to check if vdone is before (
period_at_vtime- margins.target) instead ofperiod_at_vtime.
Quoted 7 lines
But there is another problem that this patch doesn't fix. Since vtime will be advanced, we can't check if vtime is after (vnow -
MAX_LAGGING_PERIODS*period_vtime) to tell whether this iocg pin lagging for too long.Maybe we can add
lagging_periodsin iocg to record how many periods this iocg pin lagging, but I don't know when to clean it.
Hello tejun, I add lagging_periods in iocg based on the original patch, to record how many periods this iocg pin lagging. So we can use it to avoid letting cmds which take a very long time pin lagging for too long.
Thanks.
block/blk-iocost.c +9 -4
@@ -541,6 +541,8 @@ struct ioc_gq {u64 indebt_since;u64 indelay_since; +int lagging_periods; +/* this iocg's depth in the hierarchy and ancestors including self */ int level;struct ioc_gq *ancestors[];
@@ -2257,10 +2259,13 @@ static void ioc_timer_fn(struct timer_list *timer)if ((ppm_rthr !=MILLION || ppm_wthr !=MILLION ) && !atomic_read (&iocg_to_blkg (iocg)->use_delay) &&time_after64 (vtime, vdone) && -time_after64 (vtime, now.vnow - -MAX_LAGGING_PERIODS * period_vtime) && -time_before64 (vdone, now.vnow - period_vtime)) - nr_lagging++; +time_before64 (vdone, ioc->period_at_vtime - ioc->margins.target)) { +if (iocg->lagging_periods <MAX_LAGGING_PERIODS ) { + nr_lagging++; + iocg->lagging_periods++; + } + }else if (iocg->lagging_periods) + iocg->lagging_periods =0 ;/* * Determine absolute usage factoring in in-flight IOs to avoid
Quoted 19 lines
Signed-off-by Chengming Zhou <[email protected]>--- block/blk-iocost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)block/blk-iocost.c +1
-1@@ -2259,7 +2259,7 @@ static void ioc_timer_fn(struct timer_list *timer)time_after64 (vtime, vdone) &&time_after64 (vtime, now.vnow -MAX_LAGGING_PERIODS * period_vtime) && - time_before64(vdone, now.vnow - period_vtime)) + time_before64(vdone, ioc->period_at_vtime - ioc->margins.target)) nr_lagging++;/*
Quoted 59 lines · Chengming Zhou
Quoted 21 lines · Chengming Zhou
I found many false positive lagging during iocost test.
Since
iocg->vtimewill be advanced to (vnow - margins.target) inhweight_after_donation(), which called throw away excess, theiocg->done_vtimewill also be advanced that much.period_at_vtime <--period_vtime--> vnow | | ---------------------------------------------------> |<--->| margins.target |->vtime,
done_vtimeIf that iocg has some inflight io when vnow, but its
done_vtimeis beforeperiod_at_vtime,ioc_timer_fn()will think it has lagging io, even these io maybe issued just before now.This patch change the condition to check if vdone is before (
period_at_vtime- margins.target) instead ofperiod_at_vtime.Quoted 7 lines
But there is another problem that this patch doesn't fix. Since vtime will be advanced, we can't check if vtime is after (vnow -
MAX_LAGGING_PERIODS*period_vtime) to tell whether this iocg pin lagging for too long.Maybe we can add
lagging_periodsin iocg to record how many periods this iocg pin lagging, but I don't know when to clean it.Hello tejun, I add
lagging_periodsin iocg based on the original patch, to record how many periods this iocg pin lagging. So we can use it to avoid letting cmds which take a very long time pin lagging for too long.Thanks.
block/blk-iocost.c +2
-4@@ -541,6 +541,8 @@ struct ioc_gq {u64 indebt_since;u64 indelay_since; +int lagging_periods; +/* this iocg's depth in the hierarchy and ancestors including self */ int level;struct ioc_gq *ancestors[];@@ -2257,10 +2259,13 @@ static void ioc_timer_fn(struct timer_list *timer) if ((ppm_rthr != MILLION || ppm_wthr != MILLION) && !atomic_read(&iocg_to_blkg(iocg)->use_delay) && time_after64(vtime, vdone) && -time_after64 (vtime, now.vnow - -MAX_LAGGING_PERIODS * period_vtime) && -time_before64 (vdone, now.vnow - period_vtime)) - nr_lagging++;
block/blk-iocost.c static void ioc_timer_fn(struct timer_list *timer) · line 2271
Quoted 10 lines
block/blk-iocost.c +7
-0+ time_before64(vdone, ioc->period_at_vtime - ioc->margins.target)) { +if (iocg->lagging_periods <MAX_LAGGING_PERIODS ) { + nr_lagging++; + iocg->lagging_periods++; + } + } else if (iocg->lagging_periods) + iocg->lagging_periods = 0;/* * Determine absolute usage factoring in in-flight IOs to avoid
Hi, I tested with this version, previous false laggings are gone. So I wonder if I should send v2 for review?
Thanks!
Quoted 20 lines
Quoted 20 lines
Signed-off-by Chengming Zhou <[email protected]>--- block/blk-iocost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)block/blk-iocost.c +1
-1@@ -2259,7 +2259,7 @@ static void ioc_timer_fn(struct timer_list *timer)time_after64 (vtime, vdone) &&time_after64 (vtime, now.vnow -MAX_LAGGING_PERIODS * period_vtime) && - time_before64(vdone, now.vnow - period_vtime)) + time_before64(vdone, ioc->period_at_vtime - ioc->margins.target)) nr_lagging++;/*