All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] Some cleanups and improvements for blk-iocost
@ 2020-11-26  8:16 Baolin Wang
  2020-11-26  8:16 ` [PATCH v2 1/5] blk-iocost: Fix some typos in comments Baolin Wang
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: Baolin Wang @ 2020-11-26  8:16 UTC (permalink / raw)
  To: axboe, tj; +Cc: baolin.wang, baolin.wang7, linux-block, linux-kernel

Hi,

This patch set did some cleanups and improvements for blk-iocost, and
no big functional changes. Please help to review. Thanks.

Changes from v1:
 - Add acked-by tag from Tejun.
 - Drop 2 unnecessary patches.
 - Move the related variable declarations inside the block together
 with the code in patch 3.
 - Move the commit_weights() into ioc_check_iocgs().
 - Move more related logics of adjusting base vrate into the
 ioc_adjust_base_vrate().
 - Rename the new functions.

Baolin Wang (5):
  blk-iocost: Fix some typos in comments
  blk-iocost: Remove unnecessary advance declaration
  blk-iocost: Move the usage ratio calculation to the correct place
  blk-iocost: Factor out the active iocgs' state check into a separate
    function
  blk-iocost: Factor out the base vrate change into a separate function

 block/blk-iocost.c | 251 +++++++++++++++++++++++++++++------------------------
 1 file changed, 137 insertions(+), 114 deletions(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 1/5] blk-iocost: Fix some typos in comments
  2020-11-26  8:16 [PATCH v2 0/5] Some cleanups and improvements for blk-iocost Baolin Wang
@ 2020-11-26  8:16 ` Baolin Wang
  2020-11-26  8:16 ` [PATCH v2 2/5] blk-iocost: Remove unnecessary advance declaration Baolin Wang
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Baolin Wang @ 2020-11-26  8:16 UTC (permalink / raw)
  To: axboe, tj; +Cc: baolin.wang, baolin.wang7, linux-block, linux-kernel

Fix some typos in comments.

Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Acked-by: Tejun Heo <tj@kernel.org>
---
 block/blk-iocost.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index bbe86d1..4ffde36 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -39,7 +39,7 @@
  * On top of that, a size cost proportional to the length of the IO is
  * added.  While simple, this model captures the operational
  * characteristics of a wide varienty of devices well enough.  Default
- * paramters for several different classes of devices are provided and the
+ * parameters for several different classes of devices are provided and the
  * parameters can be configured from userspace via
  * /sys/fs/cgroup/io.cost.model.
  *
@@ -77,7 +77,7 @@
  *
  * This constitutes the basis of IO capacity distribution.  Each cgroup's
  * vtime is running at a rate determined by its hweight.  A cgroup tracks
- * the vtime consumed by past IOs and can issue a new IO iff doing so
+ * the vtime consumed by past IOs and can issue a new IO if doing so
  * wouldn't outrun the current device vtime.  Otherwise, the IO is
  * suspended until the vtime has progressed enough to cover it.
  *
@@ -155,7 +155,7 @@
  * Instead of debugfs or other clumsy monitoring mechanisms, this
  * controller uses a drgn based monitoring script -
  * tools/cgroup/iocost_monitor.py.  For details on drgn, please see
- * https://github.com/osandov/drgn.  The ouput looks like the following.
+ * https://github.com/osandov/drgn.  The output looks like the following.
  *
  *  sdb RUN   per=300ms cur_per=234.218:v203.695 busy= +1 vrate= 62.12%
  *                 active      weight      hweight% inflt% dbt  delay usages%
@@ -492,7 +492,7 @@ struct ioc_gq {
 	/*
 	 * `vtime` is this iocg's vtime cursor which progresses as IOs are
 	 * issued.  If lagging behind device vtime, the delta represents
-	 * the currently available IO budget.  If runnning ahead, the
+	 * the currently available IO budget.  If running ahead, the
 	 * overage.
 	 *
 	 * `vtime_done` is the same but progressed on completion rather
@@ -1046,7 +1046,7 @@ static void __propagate_weights(struct ioc_gq *iocg, u32 active, u32 inuse,
 
 		/*
 		 * The delta between inuse and active sums indicates that
-		 * that much of weight is being given away.  Parent's inuse
+		 * much of weight is being given away.  Parent's inuse
 		 * and active should reflect the ratio.
 		 */
 		if (parent->child_active_sum) {
@@ -2400,7 +2400,7 @@ static u64 adjust_inuse_and_calc_cost(struct ioc_gq *iocg, u64 vtime,
 		return cost;
 
 	/*
-	 * We only increase inuse during period and do so iff the margin has
+	 * We only increase inuse during period and do so if the margin has
 	 * deteriorated since the previous adjustment.
 	 */
 	if (margin >= iocg->saved_margin || margin >= margins->low ||
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 2/5] blk-iocost: Remove unnecessary advance declaration
  2020-11-26  8:16 [PATCH v2 0/5] Some cleanups and improvements for blk-iocost Baolin Wang
  2020-11-26  8:16 ` [PATCH v2 1/5] blk-iocost: Fix some typos in comments Baolin Wang
@ 2020-11-26  8:16 ` Baolin Wang
  2020-11-26  8:16 ` [PATCH v2 3/5] blk-iocost: Move the usage ratio calculation to the correct place Baolin Wang
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Baolin Wang @ 2020-11-26  8:16 UTC (permalink / raw)
  To: axboe, tj; +Cc: baolin.wang, baolin.wang7, linux-block, linux-kernel

Remove unnecessary advance declaration of struct ioc_gq.

Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Acked-by: Tejun Heo <tj@kernel.org>
---
 block/blk-iocost.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index 4ffde36..103ccbd 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -370,8 +370,6 @@ enum {
 	AUTOP_SSD_FAST,
 };
 
-struct ioc_gq;
-
 struct ioc_params {
 	u32				qos[NR_QOS_PARAMS];
 	u64				i_lcoefs[NR_I_LCOEFS];
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 3/5] blk-iocost: Move the usage ratio calculation to the correct place
  2020-11-26  8:16 [PATCH v2 0/5] Some cleanups and improvements for blk-iocost Baolin Wang
  2020-11-26  8:16 ` [PATCH v2 1/5] blk-iocost: Fix some typos in comments Baolin Wang
  2020-11-26  8:16 ` [PATCH v2 2/5] blk-iocost: Remove unnecessary advance declaration Baolin Wang
@ 2020-11-26  8:16 ` Baolin Wang
  2020-12-02 19:56   ` Tejun Heo
  2020-11-26  8:16 ` [PATCH v2 4/5] blk-iocost: Factor out the active iocgs' state check into a separate function Baolin Wang
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 11+ messages in thread
From: Baolin Wang @ 2020-11-26  8:16 UTC (permalink / raw)
  To: axboe, tj; +Cc: baolin.wang, baolin.wang7, linux-block, linux-kernel

We only use the hweight based usage ratio to calculate the new
hweight_inuse of the iocg to decide if this iocg can donate some
surplus vtime.

Thus move the usage ratio calculation to the correct place to
avoid unnecessary calculation for some vtime shortage iocgs.

Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
 block/blk-iocost.c | 44 +++++++++++++++++++++++---------------------
 1 file changed, 23 insertions(+), 21 deletions(-)

diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index 103ccbd..a926179 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -2168,8 +2168,8 @@ 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, usage_dur;
-		u32 usage, hw_active, hw_inuse;
+		u64 vdone, vtime, usage_us;
+		u32 hw_active, hw_inuse;
 
 		/*
 		 * Collect unused and wind vtime closer to vnow to prevent
@@ -2200,30 +2200,32 @@ static void ioc_timer_fn(struct timer_list *timer)
 		usage_us = iocg->usage_delta_us;
 		usage_us_sum += usage_us;
 
-		if (vdone != vtime) {
-			u64 inflight_us = DIV64_U64_ROUND_UP(
-				cost_to_abs_cost(vtime - vdone, hw_inuse),
-				ioc->vtime_base_rate);
-			usage_us = max(usage_us, inflight_us);
-		}
-
-		/* convert to hweight based usage ratio */
-		if (time_after64(iocg->activated_at, ioc->period_at))
-			usage_dur = max_t(u64, now.now - iocg->activated_at, 1);
-		else
-			usage_dur = max_t(u64, now.now - ioc->period_at, 1);
-
-		usage = clamp_t(u32,
-				DIV64_U64_ROUND_UP(usage_us * WEIGHT_ONE,
-						   usage_dur),
-				1, WEIGHT_ONE);
-
 		/* see whether there's surplus vtime */
 		WARN_ON_ONCE(!list_empty(&iocg->surplus_list));
 		if (hw_inuse < hw_active ||
 		    (!waitqueue_active(&iocg->waitq) &&
 		     time_before64(vtime, now.vnow - ioc->margins.low))) {
-			u32 hwa, old_hwi, hwm, new_hwi;
+			u32 hwa, old_hwi, 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),
+					ioc->vtime_base_rate);
+
+				usage_us = max(usage_us, inflight_us);
+			}
+
+			/* convert to hweight based usage ratio */
+			if (time_after64(iocg->activated_at, ioc->period_at))
+				usage_dur = max_t(u64, now.now - iocg->activated_at, 1);
+			else
+				usage_dur = max_t(u64, now.now - ioc->period_at, 1);
+
+			usage = clamp_t(u32,
+				DIV64_U64_ROUND_UP(usage_us * WEIGHT_ONE,
+						   usage_dur),
+				1, WEIGHT_ONE);
 
 			/*
 			 * Already donating or accumulated enough to start.
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 4/5] blk-iocost: Factor out the active iocgs' state check into a separate function
  2020-11-26  8:16 [PATCH v2 0/5] Some cleanups and improvements for blk-iocost Baolin Wang
                   ` (2 preceding siblings ...)
  2020-11-26  8:16 ` [PATCH v2 3/5] blk-iocost: Move the usage ratio calculation to the correct place Baolin Wang
@ 2020-11-26  8:16 ` Baolin Wang
  2020-12-02 19:58   ` Tejun Heo
  2020-11-26  8:16 ` [PATCH v2 5/5] blk-iocost: Factor out the base vrate change " Baolin Wang
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 11+ messages in thread
From: Baolin Wang @ 2020-11-26  8:16 UTC (permalink / raw)
  To: axboe, tj; +Cc: baolin.wang, baolin.wang7, linux-block, linux-kernel

Factor out the iocgs' state check into a separate function to
simplify the ioc_timer_fn().

No functional change.

Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
 block/blk-iocost.c | 94 +++++++++++++++++++++++++++++++-----------------------
 1 file changed, 54 insertions(+), 40 deletions(-)

diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index a926179..93abfe0 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -2069,40 +2069,21 @@ static void ioc_forgive_debts(struct ioc *ioc, u64 usage_us_sum, int nr_debtors,
 	}
 }
 
-static void ioc_timer_fn(struct timer_list *timer)
+/*
+ * Check the active iocgs' state to avoid oversleeping and deactive
+ * idle iocgs.
+ *
+ * Since waiters determine the sleep durations based on the vrate
+ * they saw at the time of sleep, if vrate has increased, some
+ * waiters could be sleeping for too long. Wake up tardy waiters
+ * which should have woken up in the last period and expire idle
+ * iocgs.
+ */
+static int ioc_check_iocgs(struct ioc *ioc, struct ioc_now *now)
 {
-	struct ioc *ioc = container_of(timer, struct ioc, timer);
+	int nr_debtors = 0;
 	struct ioc_gq *iocg, *tiocg;
-	struct ioc_now now;
-	LIST_HEAD(surpluses);
-	int nr_debtors = 0, nr_shortages = 0, nr_lagging = 0;
-	u64 usage_us_sum = 0;
-	u32 ppm_rthr = MILLION - ioc->params.qos[QOS_RPPM];
-	u32 ppm_wthr = MILLION - ioc->params.qos[QOS_WPPM];
-	u32 missed_ppm[2], rq_wait_pct;
-	u64 period_vtime;
-	int prev_busy_level;
-
-	/* how were the latencies during the period? */
-	ioc_lat_stat(ioc, missed_ppm, &rq_wait_pct);
 
-	/* take care of active iocgs */
-	spin_lock_irq(&ioc->lock);
-
-	ioc_now(ioc, &now);
-
-	period_vtime = now.vnow - ioc->period_at_vtime;
-	if (WARN_ON_ONCE(!period_vtime)) {
-		spin_unlock_irq(&ioc->lock);
-		return;
-	}
-
-	/*
-	 * Waiters determine the sleep durations based on the vrate they
-	 * saw at the time of sleep.  If vrate has increased, some waiters
-	 * could be sleeping for too long.  Wake up tardy waiters which
-	 * should have woken up in the last period and expire idle iocgs.
-	 */
 	list_for_each_entry_safe(iocg, tiocg, &ioc->active_iocgs, active_list) {
 		if (!waitqueue_active(&iocg->waitq) && !iocg->abs_vdebt &&
 		    !iocg->delay && !iocg_is_idle(iocg))
@@ -2112,24 +2093,24 @@ static void ioc_timer_fn(struct timer_list *timer)
 
 		/* flush wait and indebt stat deltas */
 		if (iocg->wait_since) {
-			iocg->local_stat.wait_us += now.now - iocg->wait_since;
-			iocg->wait_since = now.now;
+			iocg->local_stat.wait_us += now->now - iocg->wait_since;
+			iocg->wait_since = now->now;
 		}
 		if (iocg->indebt_since) {
 			iocg->local_stat.indebt_us +=
-				now.now - iocg->indebt_since;
-			iocg->indebt_since = now.now;
+				now->now - iocg->indebt_since;
+			iocg->indebt_since = now->now;
 		}
 		if (iocg->indelay_since) {
 			iocg->local_stat.indelay_us +=
-				now.now - iocg->indelay_since;
-			iocg->indelay_since = now.now;
+				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);
+			iocg_kick_waitq(iocg, true, now);
 			if (iocg->abs_vdebt || iocg->delay)
 				nr_debtors++;
 		} else if (iocg_is_idle(iocg)) {
@@ -2143,7 +2124,7 @@ static void ioc_timer_fn(struct timer_list *timer)
 			 * error and throw away. On reactivation, it'll start
 			 * with the target budget.
 			 */
-			excess = now.vnow - vtime - ioc->margins.target;
+			excess = now->vnow - vtime - ioc->margins.target;
 			if (excess > 0) {
 				u32 old_hwi;
 
@@ -2152,13 +2133,46 @@ static void ioc_timer_fn(struct timer_list *timer)
 							    WEIGHT_ONE);
 			}
 
-			__propagate_weights(iocg, 0, 0, false, &now);
+			__propagate_weights(iocg, 0, 0, false, now);
 			list_del_init(&iocg->active_list);
 		}
 
 		spin_unlock(&iocg->waitq.lock);
 	}
+
 	commit_weights(ioc);
+	return nr_debtors;
+}
+
+static void ioc_timer_fn(struct timer_list *timer)
+{
+	struct ioc *ioc = container_of(timer, struct ioc, timer);
+	struct ioc_gq *iocg, *tiocg;
+	struct ioc_now now;
+	LIST_HEAD(surpluses);
+	int nr_debtors, nr_shortages = 0, nr_lagging = 0;
+	u64 usage_us_sum = 0;
+	u32 ppm_rthr = MILLION - ioc->params.qos[QOS_RPPM];
+	u32 ppm_wthr = MILLION - ioc->params.qos[QOS_WPPM];
+	u32 missed_ppm[2], rq_wait_pct;
+	u64 period_vtime;
+	int prev_busy_level;
+
+	/* how were the latencies during the period? */
+	ioc_lat_stat(ioc, missed_ppm, &rq_wait_pct);
+
+	/* take care of active iocgs */
+	spin_lock_irq(&ioc->lock);
+
+	ioc_now(ioc, &now);
+
+	period_vtime = now.vnow - ioc->period_at_vtime;
+	if (WARN_ON_ONCE(!period_vtime)) {
+		spin_unlock_irq(&ioc->lock);
+		return;
+	}
+
+	nr_debtors = ioc_check_iocgs(ioc, &now);
 
 	/*
 	 * Wait and indebt stat are flushed above and the donation calculation
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 5/5] blk-iocost: Factor out the base vrate change into a separate function
  2020-11-26  8:16 [PATCH v2 0/5] Some cleanups and improvements for blk-iocost Baolin Wang
                   ` (3 preceding siblings ...)
  2020-11-26  8:16 ` [PATCH v2 4/5] blk-iocost: Factor out the active iocgs' state check into a separate function Baolin Wang
@ 2020-11-26  8:16 ` Baolin Wang
  2020-12-02 19:59   ` Tejun Heo
  2020-12-07  7:19 ` [PATCH v2 0/5] Some cleanups and improvements for blk-iocost Baolin Wang
  2020-12-07 15:02 ` Jens Axboe
  6 siblings, 1 reply; 11+ messages in thread
From: Baolin Wang @ 2020-11-26  8:16 UTC (permalink / raw)
  To: axboe, tj; +Cc: baolin.wang, baolin.wang7, linux-block, linux-kernel

Factor out the base vrate change code into a separate function
to fimplify the ioc_timer_fn().

No functional change.

Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
 block/blk-iocost.c | 99 +++++++++++++++++++++++++++++-------------------------
 1 file changed, 54 insertions(+), 45 deletions(-)

diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index 93abfe0..8348db4 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -971,6 +971,58 @@ static void ioc_refresh_vrate(struct ioc *ioc, struct ioc_now *now)
 	ioc->vtime_err = clamp(ioc->vtime_err, -vperiod, vperiod);
 }
 
+static void ioc_adjust_base_vrate(struct ioc *ioc, u32 rq_wait_pct,
+				  int nr_lagging, int nr_shortages,
+				  int prev_busy_level, u32 *missed_ppm)
+{
+	u64 vrate = ioc->vtime_base_rate;
+	u64 vrate_min = ioc->vrate_min, vrate_max = ioc->vrate_max;
+
+	if (!ioc->busy_level || (ioc->busy_level < 0 && nr_lagging)) {
+		if (ioc->busy_level != prev_busy_level || nr_lagging)
+			trace_iocost_ioc_vrate_adj(ioc, atomic64_read(&ioc->vtime_rate),
+						   missed_ppm, rq_wait_pct,
+						   nr_lagging, nr_shortages);
+
+		return;
+	}
+
+	/* rq_wait signal is always reliable, ignore user vrate_min */
+	if (rq_wait_pct > RQ_WAIT_BUSY_PCT)
+		vrate_min = VRATE_MIN;
+
+	/*
+	 * If vrate is out of bounds, apply clamp gradually as the
+	 * bounds can change abruptly.  Otherwise, apply busy_level
+	 * based adjustment.
+	 */
+	if (vrate < vrate_min) {
+		vrate = div64_u64(vrate * (100 + VRATE_CLAMP_ADJ_PCT), 100);
+		vrate = min(vrate, vrate_min);
+	} else if (vrate > vrate_max) {
+		vrate = div64_u64(vrate * (100 - VRATE_CLAMP_ADJ_PCT), 100);
+		vrate = max(vrate, vrate_max);
+	} else {
+		int idx = min_t(int, abs(ioc->busy_level),
+				ARRAY_SIZE(vrate_adj_pct) - 1);
+		u32 adj_pct = vrate_adj_pct[idx];
+
+		if (ioc->busy_level > 0)
+			adj_pct = 100 - adj_pct;
+		else
+			adj_pct = 100 + adj_pct;
+
+		vrate = clamp(DIV64_U64_ROUND_UP(vrate * adj_pct, 100),
+			      vrate_min, vrate_max);
+	}
+
+	trace_iocost_ioc_vrate_adj(ioc, vrate, missed_ppm, rq_wait_pct,
+				   nr_lagging, nr_shortages);
+
+	ioc->vtime_base_rate = vrate;
+	ioc_refresh_margins(ioc);
+}
+
 /* take a snapshot of the current [v]time and vrate */
 static void ioc_now(struct ioc *ioc, struct ioc_now *now)
 {
@@ -2323,51 +2375,8 @@ static void ioc_timer_fn(struct timer_list *timer)
 
 	ioc->busy_level = clamp(ioc->busy_level, -1000, 1000);
 
-	if (ioc->busy_level > 0 || (ioc->busy_level < 0 && !nr_lagging)) {
-		u64 vrate = ioc->vtime_base_rate;
-		u64 vrate_min = ioc->vrate_min, vrate_max = ioc->vrate_max;
-
-		/* rq_wait signal is always reliable, ignore user vrate_min */
-		if (rq_wait_pct > RQ_WAIT_BUSY_PCT)
-			vrate_min = VRATE_MIN;
-
-		/*
-		 * If vrate is out of bounds, apply clamp gradually as the
-		 * bounds can change abruptly.  Otherwise, apply busy_level
-		 * based adjustment.
-		 */
-		if (vrate < vrate_min) {
-			vrate = div64_u64(vrate * (100 + VRATE_CLAMP_ADJ_PCT),
-					  100);
-			vrate = min(vrate, vrate_min);
-		} else if (vrate > vrate_max) {
-			vrate = div64_u64(vrate * (100 - VRATE_CLAMP_ADJ_PCT),
-					  100);
-			vrate = max(vrate, vrate_max);
-		} else {
-			int idx = min_t(int, abs(ioc->busy_level),
-					ARRAY_SIZE(vrate_adj_pct) - 1);
-			u32 adj_pct = vrate_adj_pct[idx];
-
-			if (ioc->busy_level > 0)
-				adj_pct = 100 - adj_pct;
-			else
-				adj_pct = 100 + adj_pct;
-
-			vrate = clamp(DIV64_U64_ROUND_UP(vrate * adj_pct, 100),
-				      vrate_min, vrate_max);
-		}
-
-		trace_iocost_ioc_vrate_adj(ioc, vrate, missed_ppm, rq_wait_pct,
-					   nr_lagging, nr_shortages);
-
-		ioc->vtime_base_rate = vrate;
-		ioc_refresh_margins(ioc);
-	} else if (ioc->busy_level != prev_busy_level || nr_lagging) {
-		trace_iocost_ioc_vrate_adj(ioc, atomic64_read(&ioc->vtime_rate),
-					   missed_ppm, rq_wait_pct, nr_lagging,
-					   nr_shortages);
-	}
+	ioc_adjust_base_vrate(ioc, rq_wait_pct, nr_lagging, nr_shortages,
+			      prev_busy_level, missed_ppm);
 
 	ioc_refresh_params(ioc, false);
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 3/5] blk-iocost: Move the usage ratio calculation to the correct place
  2020-11-26  8:16 ` [PATCH v2 3/5] blk-iocost: Move the usage ratio calculation to the correct place Baolin Wang
@ 2020-12-02 19:56   ` Tejun Heo
  0 siblings, 0 replies; 11+ messages in thread
From: Tejun Heo @ 2020-12-02 19:56 UTC (permalink / raw)
  To: Baolin Wang; +Cc: axboe, baolin.wang7, linux-block, linux-kernel

On Thu, Nov 26, 2020 at 04:16:13PM +0800, Baolin Wang wrote:
> We only use the hweight based usage ratio to calculate the new
> hweight_inuse of the iocg to decide if this iocg can donate some
> surplus vtime.
> 
> Thus move the usage ratio calculation to the correct place to
> avoid unnecessary calculation for some vtime shortage iocgs.
> 
> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 4/5] blk-iocost: Factor out the active iocgs' state check into a separate function
  2020-11-26  8:16 ` [PATCH v2 4/5] blk-iocost: Factor out the active iocgs' state check into a separate function Baolin Wang
@ 2020-12-02 19:58   ` Tejun Heo
  0 siblings, 0 replies; 11+ messages in thread
From: Tejun Heo @ 2020-12-02 19:58 UTC (permalink / raw)
  To: Baolin Wang; +Cc: axboe, baolin.wang7, linux-block, linux-kernel

On Thu, Nov 26, 2020 at 04:16:14PM +0800, Baolin Wang wrote:
> Factor out the iocgs' state check into a separate function to
> simplify the ioc_timer_fn().
> 
> No functional change.
> 
> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 5/5] blk-iocost: Factor out the base vrate change into a separate function
  2020-11-26  8:16 ` [PATCH v2 5/5] blk-iocost: Factor out the base vrate change " Baolin Wang
@ 2020-12-02 19:59   ` Tejun Heo
  0 siblings, 0 replies; 11+ messages in thread
From: Tejun Heo @ 2020-12-02 19:59 UTC (permalink / raw)
  To: Baolin Wang; +Cc: axboe, baolin.wang7, linux-block, linux-kernel

On Thu, Nov 26, 2020 at 04:16:15PM +0800, Baolin Wang wrote:
> Factor out the base vrate change code into a separate function
> to fimplify the ioc_timer_fn().
> 
> No functional change.
> 
> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 0/5] Some cleanups and improvements for blk-iocost
  2020-11-26  8:16 [PATCH v2 0/5] Some cleanups and improvements for blk-iocost Baolin Wang
                   ` (4 preceding siblings ...)
  2020-11-26  8:16 ` [PATCH v2 5/5] blk-iocost: Factor out the base vrate change " Baolin Wang
@ 2020-12-07  7:19 ` Baolin Wang
  2020-12-07 15:02 ` Jens Axboe
  6 siblings, 0 replies; 11+ messages in thread
From: Baolin Wang @ 2020-12-07  7:19 UTC (permalink / raw)
  To: axboe, tj; +Cc: baolin.wang7, linux-block, linux-kernel

Hi Jens,

> Hi,
> 
> This patch set did some cleanups and improvements for blk-iocost, and
> no big functional changes. Please help to review. Thanks.
> 
> Changes from v1:
>   - Add acked-by tag from Tejun.
>   - Drop 2 unnecessary patches.
>   - Move the related variable declarations inside the block together
>   with the code in patch 3.
>   - Move the commit_weights() into ioc_check_iocgs().
>   - Move more related logics of adjusting base vrate into the
>   ioc_adjust_base_vrate().
>   - Rename the new functions.

Could you take this patch set if no objection from your side? Thanks.

> 
> Baolin Wang (5):
>    blk-iocost: Fix some typos in comments
>    blk-iocost: Remove unnecessary advance declaration
>    blk-iocost: Move the usage ratio calculation to the correct place
>    blk-iocost: Factor out the active iocgs' state check into a separate
>      function
>    blk-iocost: Factor out the base vrate change into a separate function
> 
>   block/blk-iocost.c | 251 +++++++++++++++++++++++++++++------------------------
>   1 file changed, 137 insertions(+), 114 deletions(-)
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 0/5] Some cleanups and improvements for blk-iocost
  2020-11-26  8:16 [PATCH v2 0/5] Some cleanups and improvements for blk-iocost Baolin Wang
                   ` (5 preceding siblings ...)
  2020-12-07  7:19 ` [PATCH v2 0/5] Some cleanups and improvements for blk-iocost Baolin Wang
@ 2020-12-07 15:02 ` Jens Axboe
  6 siblings, 0 replies; 11+ messages in thread
From: Jens Axboe @ 2020-12-07 15:02 UTC (permalink / raw)
  To: Baolin Wang, tj; +Cc: baolin.wang7, linux-block, linux-kernel

On 11/26/20 1:16 AM, Baolin Wang wrote:
> Hi,
> 
> This patch set did some cleanups and improvements for blk-iocost, and
> no big functional changes. Please help to review. Thanks.
> 
> Changes from v1:
>  - Add acked-by tag from Tejun.
>  - Drop 2 unnecessary patches.
>  - Move the related variable declarations inside the block together
>  with the code in patch 3.
>  - Move the commit_weights() into ioc_check_iocgs().
>  - Move more related logics of adjusting base vrate into the
>  ioc_adjust_base_vrate().
>  - Rename the new functions.
> 
> Baolin Wang (5):
>   blk-iocost: Fix some typos in comments
>   blk-iocost: Remove unnecessary advance declaration
>   blk-iocost: Move the usage ratio calculation to the correct place
>   blk-iocost: Factor out the active iocgs' state check into a separate
>     function
>   blk-iocost: Factor out the base vrate change into a separate function
> 
>  block/blk-iocost.c | 251 +++++++++++++++++++++++++++++------------------------
>  1 file changed, 137 insertions(+), 114 deletions(-)

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-12-07 15:03 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-26  8:16 [PATCH v2 0/5] Some cleanups and improvements for blk-iocost Baolin Wang
2020-11-26  8:16 ` [PATCH v2 1/5] blk-iocost: Fix some typos in comments Baolin Wang
2020-11-26  8:16 ` [PATCH v2 2/5] blk-iocost: Remove unnecessary advance declaration Baolin Wang
2020-11-26  8:16 ` [PATCH v2 3/5] blk-iocost: Move the usage ratio calculation to the correct place Baolin Wang
2020-12-02 19:56   ` Tejun Heo
2020-11-26  8:16 ` [PATCH v2 4/5] blk-iocost: Factor out the active iocgs' state check into a separate function Baolin Wang
2020-12-02 19:58   ` Tejun Heo
2020-11-26  8:16 ` [PATCH v2 5/5] blk-iocost: Factor out the base vrate change " Baolin Wang
2020-12-02 19:59   ` Tejun Heo
2020-12-07  7:19 ` [PATCH v2 0/5] Some cleanups and improvements for blk-iocost Baolin Wang
2020-12-07 15:02 ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.