[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220516084045.96004-1-zhouchengming@bytedance.com>
Date: Mon, 16 May 2022 16:40:45 +0800
From: Chengming Zhou <zhouchengming@...edance.com>
To: tj@...nel.org, axboe@...nel.dk
Cc: linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
duanxiongchun@...edance.com, songmuchun@...edance.com,
Chengming Zhou <zhouchengming@...edance.com>
Subject: [PATCH] blk-iocost: fix very large vtime when iocg activate
When the first iocg activate after blk_iocost_init(), now->vnow
maybe smaller than ioc->margins.target, cause very large vtarget
since it's u64.
vtarget = now->vnow - ioc->margins.target;
atomic64_add(vtarget - vtime, &iocg->vtime);
Then the iocg's vtime will be very large too, larger than now->vnow.
Signed-off-by: Chengming Zhou <zhouchengming@...edance.com>
---
block/blk-iocost.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index 5019dff524a4..a2ee12175c49 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -1248,7 +1248,7 @@ static bool iocg_activate(struct ioc_gq *iocg, struct ioc_now *now)
{
struct ioc *ioc = iocg->ioc;
u64 last_period, cur_period;
- u64 vtime, vtarget;
+ u64 vtime, vtarget = 0;
int i;
/*
@@ -1290,7 +1290,8 @@ static bool iocg_activate(struct ioc_gq *iocg, struct ioc_now *now)
* Always start with the target budget. On deactivation, we throw away
* anything above it.
*/
- vtarget = now->vnow - ioc->margins.target;
+ if (now->vnow > ioc->margins.target)
+ vtarget = now->vnow - ioc->margins.target;
vtime = atomic64_read(&iocg->vtime);
atomic64_add(vtarget - vtime, &iocg->vtime);
--
2.36.1
Powered by blists - more mailing lists