mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chengming Zhou <zhouchengming@bytedance.com>
To: tj@kernel.org, axboe@kernel.dk
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	Chengming Zhou <zhouchengming@bytedance.com>
Subject: [PATCH 1/2] blk-iocost: factor out iocg_deactivate()
Date: Wed,  1 Jun 2022 20:20:06 +0800	[thread overview]
Message-ID: <20220601122007.1057-1-zhouchengming@bytedance.com> (raw)

This patch factor out iocg deactivation into a separate function:
iocg_deactivate(). No functional changes.

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

diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index 33a11ba971ea..b1f2305e8032 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -1322,6 +1322,37 @@ static bool iocg_activate(struct ioc_gq *iocg, struct ioc_now *now)
 	return false;
 }
 
+static void iocg_deactivate(struct ioc_gq *iocg, struct ioc_now *now)
+{
+	struct ioc *ioc = iocg->ioc;
+	u64 vtime = atomic64_read(&iocg->vtime);
+	s64 excess;
+
+	lockdep_assert_held(&ioc->lock);
+	lockdep_assert_held(&iocg->waitq.lock);
+
+	/*
+	 * @iocg has been inactive for a full duration and will
+	 * have a high budget. Account anything above target as
+	 * error and throw away. On reactivation, it'll start
+	 * with the target budget.
+	 */
+	excess = now->vnow - vtime - ioc->margins.target;
+	if (excess > 0) {
+		u32 old_hwi;
+
+		current_hweight(iocg, NULL, &old_hwi);
+		ioc->vtime_err -= div64_u64(excess * old_hwi,
+					    WEIGHT_ONE);
+	}
+
+	TRACE_IOCG_PATH(iocg_idle, iocg, now,
+			atomic64_read(&iocg->active_period),
+			atomic64_read(&ioc->cur_period), vtime);
+	__propagate_weights(iocg, 0, 0, false, now);
+	list_del_init(&iocg->active_list);
+}
+
 static bool iocg_kick_delay(struct ioc_gq *iocg, struct ioc_now *now)
 {
 	struct ioc *ioc = iocg->ioc;
@@ -2165,32 +2196,8 @@ static int ioc_check_iocgs(struct ioc *ioc, struct ioc_now *now)
 			iocg_kick_waitq(iocg, true, now);
 			if (iocg->abs_vdebt || iocg->delay)
 				nr_debtors++;
-		} else if (iocg_is_idle(iocg)) {
-			/* no waiter and idle, deactivate */
-			u64 vtime = atomic64_read(&iocg->vtime);
-			s64 excess;
-
-			/*
-			 * @iocg has been inactive for a full duration and will
-			 * have a high budget. Account anything above target as
-			 * error and throw away. On reactivation, it'll start
-			 * with the target budget.
-			 */
-			excess = now->vnow - vtime - ioc->margins.target;
-			if (excess > 0) {
-				u32 old_hwi;
-
-				current_hweight(iocg, NULL, &old_hwi);
-				ioc->vtime_err -= div64_u64(excess * old_hwi,
-							    WEIGHT_ONE);
-			}
-
-			TRACE_IOCG_PATH(iocg_idle, iocg, now,
-					atomic64_read(&iocg->active_period),
-					atomic64_read(&ioc->cur_period), vtime);
-			__propagate_weights(iocg, 0, 0, false, now);
-			list_del_init(&iocg->active_list);
-		}
+		} else if (iocg_is_idle(iocg))
+			iocg_deactivate(iocg, now);
 
 		spin_unlock(&iocg->waitq.lock);
 	}
-- 
2.36.1


             reply	other threads:[~2022-06-01 12:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-01 12:20 Chengming Zhou [this message]
2022-06-01 12:20 ` [PATCH 2/2] blk-iocost: only flush wait and indebt stat deltas when needed Chengming Zhou
2022-06-01 16:23   ` Tejun Heo
2022-06-01 23:57     ` Chengming Zhou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220601122007.1057-1-zhouchengming@bytedance.com \
    --to=zhouchengming@bytedance.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®