lkml.org 
[lkml]   [2022]   [May]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] blk-iocost: fix very large vtime when iocg activate
Date
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@bytedance.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
\
 
 \ /
  Last update: 2022-05-16 10:42    [W:0.107 / U:0.936 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site