public inbox for linux-block@vger.kernel.org
 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: remove the second superfluous current_hweight
Date: Thu,  9 Jun 2022 15:34:49 +0800	[thread overview]
Message-ID: <20220609073450.98975-1-zhouchengming@bytedance.com> (raw)

The commit ac33e91e2dac ("blk-iocost: implement vtime loss compensation")
add the second current_hweight() in the loop of active iocgs list to
get old_hwi to calculate the vtime loss of the iocg.

Since the hwi can't change and the first current_hweight already get
hwa and hwi, so this second superfluous current_hweight() can be
removed. There should be no functional changes.

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

diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index 33a11ba971ea..3cda08224d51 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -2238,7 +2238,7 @@ static void ioc_timer_fn(struct timer_list *timer)
 	/* calc usage and see whether some weights need to be moved around */
 	list_for_each_entry(iocg, &ioc->active_iocgs, active_list) {
 		u64 vdone, vtime, usage_us;
-		u32 hw_active, hw_inuse;
+		u32 hwa, old_hwi;
 
 		/*
 		 * Collect unused and wind vtime closer to vnow to prevent
@@ -2246,7 +2246,7 @@ static void ioc_timer_fn(struct timer_list *timer)
 		 */
 		vdone = atomic64_read(&iocg->done_vtime);
 		vtime = atomic64_read(&iocg->vtime);
-		current_hweight(iocg, &hw_active, &hw_inuse);
+		current_hweight(iocg, &hwa, &old_hwi);
 
 		/*
 		 * Latency QoS detection doesn't account for IOs which are
@@ -2271,15 +2271,15 @@ static void ioc_timer_fn(struct timer_list *timer)
 
 		/* see whether there's surplus vtime */
 		WARN_ON_ONCE(!list_empty(&iocg->surplus_list));
-		if (hw_inuse < hw_active ||
+		if (old_hwi < hwa ||
 		    (!waitqueue_active(&iocg->waitq) &&
 		     time_before64(vtime, now.vnow - ioc->margins.low))) {
-			u32 hwa, old_hwi, hwm, new_hwi, usage;
+			u32 hwm, new_hwi, usage;
 			u64 usage_dur;
 
 			if (vdone != vtime) {
 				u64 inflight_us = DIV64_U64_ROUND_UP(
-					cost_to_abs_cost(vtime - vdone, hw_inuse),
+					cost_to_abs_cost(vtime - vdone, old_hwi),
 					ioc->vtime_base_rate);
 
 				usage_us = max(usage_us, inflight_us);
@@ -2300,7 +2300,6 @@ static void ioc_timer_fn(struct timer_list *timer)
 			 * Already donating or accumulated enough to start.
 			 * Determine the donation amount.
 			 */
-			current_hweight(iocg, &hwa, &old_hwi);
 			hwm = current_hweight_max(iocg);
 			new_hwi = hweight_after_donation(iocg, old_hwi, hwm,
 							 usage, &now);
-- 
2.36.1


             reply	other threads:[~2022-06-09  7:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-09  7:34 Chengming Zhou [this message]
2022-06-09  7:34 ` [PATCH 2/2] blk-iocost: fix vtime loss calculation when iocg deactivate Chengming Zhou
2022-06-10  8:45 ` [PATCH 1/2] blk-iocost: remove the second superfluous current_hweight Andreas Herrmann

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=20220609073450.98975-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