diff mbox series

[2/2] blk-iocost: only flush wait and indebt stat deltas when needed

Message ID 20220601122007.1057-2-zhouchengming@bytedance.com (mailing list archive)
State New, archived
Headers show
Series [1/2] blk-iocost: factor out iocg_deactivate() | expand

Commit Message

Chengming Zhou June 1, 2022, 12:20 p.m. UTC
We only need to flush wait and indebt stat deltas when the iocg
is in these status.

Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
---
 block/blk-iocost.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

Comments

Tejun Heo June 1, 2022, 4:23 p.m. UTC | #1
On Wed, Jun 01, 2022 at 08:20:07PM +0800, Chengming Zhou wrote:
> We only need to flush wait and indebt stat deltas when the iocg
> is in these status.

Hey, so, I'm not seeing any actual benefits of the suggested patches and
none of them has actual justifications. For the time being, I'm gonna be
ignoring these patches.

Thanks.
Chengming Zhou June 1, 2022, 11:57 p.m. UTC | #2
On 2022/6/2 00:23, Tejun Heo wrote:
> On Wed, Jun 01, 2022 at 08:20:07PM +0800, Chengming Zhou wrote:
>> We only need to flush wait and indebt stat deltas when the iocg
>> is in these status.
> 
> Hey, so, I'm not seeing any actual benefits of the suggested patches and
> none of them has actual justifications. For the time being, I'm gonna be
> ignoring these patches.

Hi, the current code will flush wait and indebt stat deltas even for idle
iocgs, which seems strange. This patch only do that for iocgs that are in
wait or indebt status, so it's a performance and code improvements, although
it's minor.

Thanks.

> 
> Thanks.
>
diff mbox series

Patch

diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index b1f2305e8032..502425b44475 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -2174,28 +2174,28 @@  static int ioc_check_iocgs(struct ioc *ioc, struct ioc_now *now)
 
 		spin_lock(&iocg->waitq.lock);
 
-		/* flush wait and indebt stat deltas */
-		if (iocg->wait_since) {
-			iocg->stat.wait_us += now->now - iocg->wait_since;
-			iocg->wait_since = now->now;
-		}
-		if (iocg->indebt_since) {
-			iocg->stat.indebt_us +=
-				now->now - iocg->indebt_since;
-			iocg->indebt_since = now->now;
-		}
-		if (iocg->indelay_since) {
-			iocg->stat.indelay_us +=
-				now->now - iocg->indelay_since;
-			iocg->indelay_since = now->now;
-		}
-
 		if (waitqueue_active(&iocg->waitq) || iocg->abs_vdebt ||
 		    iocg->delay) {
 			/* might be oversleeping vtime / hweight changes, kick */
 			iocg_kick_waitq(iocg, true, now);
 			if (iocg->abs_vdebt || iocg->delay)
 				nr_debtors++;
+
+			/* flush wait and indebt stat deltas */
+			if (iocg->wait_since) {
+				iocg->stat.wait_us += now->now - iocg->wait_since;
+				iocg->wait_since = now->now;
+			}
+			if (iocg->indebt_since) {
+				iocg->stat.indebt_us +=
+					now->now - iocg->indebt_since;
+				iocg->indebt_since = now->now;
+			}
+			if (iocg->indelay_since) {
+				iocg->stat.indelay_us +=
+					now->now - iocg->indelay_since;
+				iocg->indelay_since = now->now;
+			}
 		} else if (iocg_is_idle(iocg))
 			iocg_deactivate(iocg, now);