[PATCH OLK-6.6] blk-ioinf: accumulate total latency properly across sampling periods
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/ID0C1D -------------------------------- QoS evaluation based on delta_stat should only be performed when the number of samples exceeds IOINF_MIN_SAMPLES. Otherwise, abnormal cases in small sample sets may cause overly aggressive adjustments. Therefore, when updating delta_stat, it is only reset if the number of I/Os exceeds IOINF_MIN_SAMPLES; otherwise, sampling results are accumulated across multiple periods until the total sample count reaches at least IOINF_MIN_SAMPLES. However, when accumulating across multiple periods, the average latency was treated as total latency, leading to underestimated values. Fix this by introducing a variable to track total latency. In addition, since the update logic for read and write is identical, a helper function ioinf_update_delta_io_stat() is added to avoid code duplication. Fixes: 4192ef0b0776 ("blk-ioinf: add rqos/inflight/stat debufs interface") Signed-off-by: Baokun Li <libaokun1@huawei.com> --- block/blk-ioinf.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/block/blk-ioinf.c b/block/blk-ioinf.c index 623c2715802b..1be9c690d8a4 100644 --- a/block/blk-ioinf.c +++ b/block/blk-ioinf.c @@ -680,20 +680,24 @@ static void ioinf_sample_cpu_lat(struct ioinf_lat_stat *cur, int cpu, cur->write.met += pstat->write.met; } +static inline void ioinf_update_delta_io_stat(struct ioinf_io_stat cur, + struct ioinf_io_stat last, struct ioinf_io_stat *delta) +{ + u64 lat = delta->nr * delta->lat; + + delta->nr += cur.nr - last.nr; + delta->met += cur.met - last.met; + if (delta->nr > 0) { + lat += cur.lat - last.lat; + delta->lat = div_u64(lat, delta->nr); + } +} + static void ioinf_update_delta_stat(struct ioinf_lat_stat *cur, struct ioinf_lat_stat *last, struct ioinf_lat_stat *delta) { - delta->read.nr += cur->read.nr - last->read.nr; - delta->read.met += cur->read.met - last->read.met; - delta->read.lat += cur->read.lat - last->read.lat; - if (delta->read.nr > 0) - delta->read.lat = div_u64(delta->read.lat, delta->read.nr); - - delta->write.nr += cur->write.nr - last->write.nr; - delta->write.met += cur->write.met - last->write.met; - delta->write.lat += cur->write.lat - last->write.lat; - if (delta->write.nr > 0) - delta->write.lat = div_u64(delta->write.lat, delta->write.nr); + ioinf_update_delta_io_stat(cur->read, last->read, &delta->read); + ioinf_update_delta_io_stat(cur->write, last->write, &delta->write); } static void ioinf_sample_lat(struct ioinf *inf) -- 2.46.1
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/19292 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/2YS... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/19292 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/2YS...
participants (2)
-
Baokun Li -
patchwork bot