[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <beb9ab5875427431b58e1001e481b7a43e9188eb.1606186717.git.baolin.wang@linux.alibaba.com>
Date: Tue, 24 Nov 2020 11:33:33 +0800
From: Baolin Wang <baolin.wang@...ux.alibaba.com>
To: axboe@...nel.dk, tj@...nel.org
Cc: baolin.wang@...ux.alibaba.com, baolin.wang7@...il.com,
linux-block@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 4/7] blk-iocost: Add a flag to indicate if need update hwi
We can get the hwa and hwi at one time if no debt need to pay off,
thus add a flag to indicate if the hw_inuse has been changed and
need to update, which can avoid calling current_hweight() twice
for no debt iocgs.
Signed-off-by: Baolin Wang <baolin.wang@...ux.alibaba.com>
---
block/blk-iocost.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index 089f3fe..5305afd 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -1405,10 +1405,11 @@ static void iocg_kick_waitq(struct ioc_gq *iocg, bool pay_debt,
u64 vshortage, expires, oexpires;
s64 vbudget;
u32 hwa;
+ bool need_update_hwi = false;
lockdep_assert_held(&iocg->waitq.lock);
- current_hweight(iocg, &hwa, NULL);
+ current_hweight(iocg, &hwa, &ctx.hw_inuse);
vbudget = now->vnow - atomic64_read(&iocg->vtime);
/* pay off debt */
@@ -1423,6 +1424,7 @@ static void iocg_kick_waitq(struct ioc_gq *iocg, bool pay_debt,
atomic64_add(vpay, &iocg->done_vtime);
iocg_pay_debt(iocg, abs_vpay, now);
vbudget -= vpay;
+ need_update_hwi = true;
}
if (iocg->abs_vdebt || iocg->delay)
@@ -1445,7 +1447,8 @@ static void iocg_kick_waitq(struct ioc_gq *iocg, bool pay_debt,
* after the above debt payment.
*/
ctx.vbudget = vbudget;
- current_hweight(iocg, NULL, &ctx.hw_inuse);
+ if (need_update_hwi)
+ current_hweight(iocg, NULL, &ctx.hw_inuse);
__wake_up_locked_key(&iocg->waitq, TASK_NORMAL, &ctx);
--
1.8.3.1
Powered by blists - more mailing lists