linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Some improvements for blk throttle
@ 2020-09-20  9:10 Baolin Wang
  2020-09-20  9:10 ` [PATCH 1/4] blk-throttle: Remove a meaningless parameter for throtl_downgrade_state() Baolin Wang
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Baolin Wang @ 2020-09-20  9:10 UTC (permalink / raw)
  To: tj, axboe; +Cc: baolin.wang, baolin.wang7, linux-block, cgroups, linux-kernel

Hi,

This patch set did some improvements for blk throttle, please
help to review. Thanks.

Baolin Wang (4):
  blk-throttle: Remove a meaningless parameter for
    throtl_downgrade_state()
  blk-throttle: Avoid getting the current time if tg->last_finish_time
    is 0
  blk-throttle: Avoid tracking latency if low limit is invalid
  blk-throttle: Fix IO hang for a corner case

 block/blk-throttle.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

-- 
1.8.3.1


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

* [PATCH 1/4] blk-throttle: Remove a meaningless parameter for throtl_downgrade_state()
  2020-09-20  9:10 [PATCH 0/4] Some improvements for blk throttle Baolin Wang
@ 2020-09-20  9:10 ` Baolin Wang
  2020-09-20  9:10 ` [PATCH 2/4] blk-throttle: Avoid getting the current time if tg->last_finish_time is 0 Baolin Wang
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Baolin Wang @ 2020-09-20  9:10 UTC (permalink / raw)
  To: tj, axboe; +Cc: baolin.wang, baolin.wang7, linux-block, cgroups, linux-kernel

The throtl_downgrade_state() is always used to change to LIMIT_LOW
limitation, thus remove the latter meaningless parameter which
indicates the limitation index.

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

diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 36ba61c..4007b26 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -1970,7 +1970,7 @@ static void throtl_upgrade_state(struct throtl_data *td)
 	queue_work(kthrotld_workqueue, &td->dispatch_work);
 }
 
-static void throtl_downgrade_state(struct throtl_data *td, int new)
+static void throtl_downgrade_state(struct throtl_data *td)
 {
 	td->scale /= 2;
 
@@ -1980,7 +1980,7 @@ static void throtl_downgrade_state(struct throtl_data *td, int new)
 		return;
 	}
 
-	td->limit_index = new;
+	td->limit_index = LIMIT_LOW;
 	td->low_downgrade_time = jiffies;
 }
 
@@ -2067,7 +2067,7 @@ static void throtl_downgrade_check(struct throtl_grp *tg)
 	 * cgroups
 	 */
 	if (throtl_hierarchy_can_downgrade(tg))
-		throtl_downgrade_state(tg->td, LIMIT_LOW);
+		throtl_downgrade_state(tg->td);
 
 	tg->last_bytes_disp[READ] = 0;
 	tg->last_bytes_disp[WRITE] = 0;
-- 
1.8.3.1


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

* [PATCH 2/4] blk-throttle: Avoid getting the current time if tg->last_finish_time is 0
  2020-09-20  9:10 [PATCH 0/4] Some improvements for blk throttle Baolin Wang
  2020-09-20  9:10 ` [PATCH 1/4] blk-throttle: Remove a meaningless parameter for throtl_downgrade_state() Baolin Wang
@ 2020-09-20  9:10 ` Baolin Wang
  2020-09-20  9:14 ` [PATCH 3/4] blk-throttle: Avoid tracking latency if low limit is invalid Baolin Wang
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Baolin Wang @ 2020-09-20  9:10 UTC (permalink / raw)
  To: tj, axboe; +Cc: baolin.wang, baolin.wang7, linux-block, cgroups, linux-kernel

We only update the tg->last_finish_time when the low limitaion is
enabled, so we can move the tg->last_finish_time validation a little
forward to avoid getting the unnecessary current time stamp if the
the low limitation is not enabled.

Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
 block/blk-throttle.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 4007b26..7e72102 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -2077,10 +2077,14 @@ static void throtl_downgrade_check(struct throtl_grp *tg)
 
 static void blk_throtl_update_idletime(struct throtl_grp *tg)
 {
-	unsigned long now = ktime_get_ns() >> 10;
+	unsigned long now;
 	unsigned long last_finish_time = tg->last_finish_time;
 
-	if (now <= last_finish_time || last_finish_time == 0 ||
+	if (last_finish_time == 0)
+		return;
+
+	now = ktime_get_ns() >> 10;
+	if (now <= last_finish_time ||
 	    last_finish_time == tg->checked_last_finish_time)
 		return;
 
-- 
1.8.3.1


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

* [PATCH 3/4] blk-throttle: Avoid tracking latency if low limit is invalid
  2020-09-20  9:10 [PATCH 0/4] Some improvements for blk throttle Baolin Wang
  2020-09-20  9:10 ` [PATCH 1/4] blk-throttle: Remove a meaningless parameter for throtl_downgrade_state() Baolin Wang
  2020-09-20  9:10 ` [PATCH 2/4] blk-throttle: Avoid getting the current time if tg->last_finish_time is 0 Baolin Wang
@ 2020-09-20  9:14 ` Baolin Wang
  2020-09-20  9:14 ` [PATCH 4/4] blk-throttle: Fix IO hang for a corner case Baolin Wang
  2020-09-29 14:52 ` [PATCH 0/4] Some improvements for blk throttle Baolin Wang
  4 siblings, 0 replies; 6+ messages in thread
From: Baolin Wang @ 2020-09-20  9:14 UTC (permalink / raw)
  To: tj, axboe; +Cc: baolin.wang, baolin.wang7, linux-block, cgroups, linux-kernel

The IO latency tracking is only for LOW limit, so we should add a
validation to avoid redundant latency tracking if the LOW limit
is not valid.

Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
 block/blk-throttle.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 7e72102..b0d8f7c 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -2100,7 +2100,7 @@ static void throtl_update_latency_buckets(struct throtl_data *td)
 	unsigned long last_latency[2] = { 0 };
 	unsigned long latency[2];
 
-	if (!blk_queue_nonrot(td->queue))
+	if (!blk_queue_nonrot(td->queue) || !td->limit_valid[LIMIT_LOW])
 		return;
 	if (time_before(jiffies, td->last_calculate_time + HZ))
 		return;
@@ -2338,6 +2338,8 @@ void blk_throtl_bio_endio(struct bio *bio)
 	if (!blkg)
 		return;
 	tg = blkg_to_tg(blkg);
+	if (!tg->td->limit_valid[LIMIT_LOW])
+		return;
 
 	finish_time_ns = ktime_get_ns();
 	tg->last_finish_time = finish_time_ns >> 10;
-- 
1.8.3.1


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

* [PATCH 4/4] blk-throttle: Fix IO hang for a corner case
  2020-09-20  9:10 [PATCH 0/4] Some improvements for blk throttle Baolin Wang
                   ` (2 preceding siblings ...)
  2020-09-20  9:14 ` [PATCH 3/4] blk-throttle: Avoid tracking latency if low limit is invalid Baolin Wang
@ 2020-09-20  9:14 ` Baolin Wang
  2020-09-29 14:52 ` [PATCH 0/4] Some improvements for blk throttle Baolin Wang
  4 siblings, 0 replies; 6+ messages in thread
From: Baolin Wang @ 2020-09-20  9:14 UTC (permalink / raw)
  To: tj, axboe; +Cc: baolin.wang, baolin.wang7, linux-block, cgroups, linux-kernel

It can not scale up in throtl_adjusted_limit() if we set bps or iops is
1, which will cause IO hang when enable low limit. Thus we should treat
1 as a illegal value to avoid this issue.

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

diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index b0d8f7c..0649bce 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -1687,13 +1687,13 @@ static ssize_t tg_set_limit(struct kernfs_open_file *of,
 			goto out_finish;
 
 		ret = -EINVAL;
-		if (!strcmp(tok, "rbps"))
+		if (!strcmp(tok, "rbps") && val > 1)
 			v[0] = val;
-		else if (!strcmp(tok, "wbps"))
+		else if (!strcmp(tok, "wbps") && val > 1)
 			v[1] = val;
-		else if (!strcmp(tok, "riops"))
+		else if (!strcmp(tok, "riops") && val > 1)
 			v[2] = min_t(u64, val, UINT_MAX);
-		else if (!strcmp(tok, "wiops"))
+		else if (!strcmp(tok, "wiops") && val > 1)
 			v[3] = min_t(u64, val, UINT_MAX);
 		else if (off == LIMIT_LOW && !strcmp(tok, "idle"))
 			idle_time = val;
-- 
1.8.3.1


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

* Re: [PATCH 0/4] Some improvements for blk throttle
  2020-09-20  9:10 [PATCH 0/4] Some improvements for blk throttle Baolin Wang
                   ` (3 preceding siblings ...)
  2020-09-20  9:14 ` [PATCH 4/4] blk-throttle: Fix IO hang for a corner case Baolin Wang
@ 2020-09-29 14:52 ` Baolin Wang
  4 siblings, 0 replies; 6+ messages in thread
From: Baolin Wang @ 2020-09-29 14:52 UTC (permalink / raw)
  To: tj, axboe; +Cc: baolin.wang7, linux-block, cgroups, linux-kernel

Hi Jens,

> Hi,
> 
> This patch set did some improvements for blk throttle, please
> help to review. Thanks.

Do you have any comments for this patch set? Thanks.

> 
> Baolin Wang (4):
>    blk-throttle: Remove a meaningless parameter for
>      throtl_downgrade_state()
>    blk-throttle: Avoid getting the current time if tg->last_finish_time
>      is 0
>    blk-throttle: Avoid tracking latency if low limit is invalid
>    blk-throttle: Fix IO hang for a corner case
> 
>   block/blk-throttle.c | 26 ++++++++++++++++----------
>   1 file changed, 16 insertions(+), 10 deletions(-)
> 

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

end of thread, other threads:[~2020-09-29 14:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-20  9:10 [PATCH 0/4] Some improvements for blk throttle Baolin Wang
2020-09-20  9:10 ` [PATCH 1/4] blk-throttle: Remove a meaningless parameter for throtl_downgrade_state() Baolin Wang
2020-09-20  9:10 ` [PATCH 2/4] blk-throttle: Avoid getting the current time if tg->last_finish_time is 0 Baolin Wang
2020-09-20  9:14 ` [PATCH 3/4] blk-throttle: Avoid tracking latency if low limit is invalid Baolin Wang
2020-09-20  9:14 ` [PATCH 4/4] blk-throttle: Fix IO hang for a corner case Baolin Wang
2020-09-29 14:52 ` [PATCH 0/4] Some improvements for blk throttle Baolin Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).