From 1c17b7ca813b93ca720acc5c47705dde655b8058 Mon Sep 17 00:00:00 2001 From: Chunguang Xu Date: Wed, 7 Sep 2022 09:08:46 +0000 Subject: [PATCH] block: fix the problem of io_ticks becoming smaller mainline inclusion from mainline-v5.14-rc1 commit d80c228d44640f0b47b57a2ca4afa26ef87e16b0 category: bugfix bugzilla: 187475, https://gitee.com/openeuler/kernel/issues/I5ME0J CVE: NA -------------------------------- On the IO submission path, blk_account_io_start() may interrupt the system interruption. When the interruption returns, the value of part->stamp may have been updated by other cores, so the time value collected before the interruption may be less than part-> stamp. So when this happens, we should do nothing to make io_ticks more accurate? For kernels less than 5.0, this may cause io_ticks to become smaller, which in turn may cause abnormal ioutil values. Signed-off-by: Chunguang Xu Reviewed-by: Christoph Hellwig Link: https://lore.kernel.org/r/1625521646-1069-1-git-send-email-brookxu.cn@gmail.com Signed-off-by: Jens Axboe conflict: block/blk-core.c Signed-off-by: Li Nan Reviewed-by: Jason Yan Signed-off-by: Yongqiang Liu --- block/bio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/bio.c b/block/bio.c index 48092fe0c116..21c56c177b25 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1673,7 +1673,7 @@ void update_io_ticks(int cpu, struct hd_struct *part, unsigned long now, bool en unsigned long stamp; again: stamp = READ_ONCE(part->stamp); - if (unlikely(stamp != now)) { + if (unlikely(time_after(now, stamp))) { if (likely(cmpxchg(&part->stamp, stamp, now) == stamp)) __part_stat_add(cpu, part, io_ticks, end ? now - stamp : 1); } -- GitLab