mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH -next v2 0/4] cleanup and fixes for 'carryover_ios/bytes'
@ 2023-08-16  1:27 Yu Kuai
  2023-08-16  1:27 ` [PATCH -next v2 1/4] blk-throttle: print signed value 'carryover_bytes/ios' for user Yu Kuai
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Yu Kuai @ 2023-08-16  1:27 UTC (permalink / raw)
  To: tj, josef, axboe, yukuai3, mkoutny
  Cc: cgroups, linux-block, linux-kernel, yukuai1, yi.zhang, yangerkun

From: Yu Kuai <yukuai3@huawei.com>

changes in v2:
 - fix missing adjustment in throtl_log().

Patch 1 print signed value for 'carryover_ios/bytes' to user.

Patch 2 fix that comparation ”unsigned value < negative value“ will
pass, causing that io won't be throttled in the silce.

Patch 3,4 fix that 'carryover_ios/bytes' is not cleared while
'io/bytes_disp' is cleared, causing that throttle is not accurate.

Yu Kuai (4):
  blk-throttle: print signed value 'carryover_bytes/ios' for user
  blk-throttle: fix wrong comparation while 'carryover_ios/bytes' is
    negative
  blk-throttle: use calculate_io/bytes_allowed() for throtl_trim_slice()
  blk-throttle: consider 'carryover_ios/bytes' in throtl_trim_slice()

 block/blk-throttle.c | 112 +++++++++++++++++++++----------------------
 block/blk-throttle.h |   4 +-
 2 files changed, 58 insertions(+), 58 deletions(-)

-- 
2.39.2


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

* [PATCH -next v2 1/4] blk-throttle: print signed value 'carryover_bytes/ios' for user
  2023-08-16  1:27 [PATCH -next v2 0/4] cleanup and fixes for 'carryover_ios/bytes' Yu Kuai
@ 2023-08-16  1:27 ` Yu Kuai
  2023-08-29 22:17   ` Tejun Heo
  2023-08-16  1:27 ` [PATCH -next v2 2/4] blk-throttle: fix wrong comparation while 'carryover_ios/bytes' is negative Yu Kuai
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Yu Kuai @ 2023-08-16  1:27 UTC (permalink / raw)
  To: tj, josef, axboe, yukuai3, mkoutny
  Cc: cgroups, linux-block, linux-kernel, yukuai1, yi.zhang, yangerkun

From: Yu Kuai <yukuai3@huawei.com>

'carryover_bytes/ios' can be negative, indicate that some bio is
dispatched in advance within slice while configuration is updated.
Print a huge value is not user-friendly.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 block/blk-throttle.c | 2 +-
 block/blk-throttle.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 7397ff199d66..5184f17f5129 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -816,7 +816,7 @@ static void tg_update_carryover(struct throtl_grp *tg)
 		__tg_update_carryover(tg, WRITE);
 
 	/* see comments in struct throtl_grp for meaning of these fields. */
-	throtl_log(&tg->service_queue, "%s: %llu %llu %u %u\n", __func__,
+	throtl_log(&tg->service_queue, "%s: %lld %lld %d %d\n", __func__,
 		   tg->carryover_bytes[READ], tg->carryover_bytes[WRITE],
 		   tg->carryover_ios[READ], tg->carryover_ios[WRITE]);
 }
diff --git a/block/blk-throttle.h b/block/blk-throttle.h
index d1ccbfe9f797..bffbc9cfc8ab 100644
--- a/block/blk-throttle.h
+++ b/block/blk-throttle.h
@@ -127,8 +127,8 @@ struct throtl_grp {
 	 * bytes/ios are waited already in previous configuration, and they will
 	 * be used to calculate wait time under new configuration.
 	 */
-	uint64_t carryover_bytes[2];
-	unsigned int carryover_ios[2];
+	long long carryover_bytes[2];
+	int carryover_ios[2];
 
 	unsigned long last_check_time;
 
-- 
2.39.2


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

* [PATCH -next v2 2/4] blk-throttle: fix wrong comparation while 'carryover_ios/bytes' is negative
  2023-08-16  1:27 [PATCH -next v2 0/4] cleanup and fixes for 'carryover_ios/bytes' Yu Kuai
  2023-08-16  1:27 ` [PATCH -next v2 1/4] blk-throttle: print signed value 'carryover_bytes/ios' for user Yu Kuai
@ 2023-08-16  1:27 ` Yu Kuai
  2023-08-29 22:18   ` Tejun Heo
  2023-08-16  1:27 ` [PATCH -next v2 3/4] blk-throttle: use calculate_io/bytes_allowed() for throtl_trim_slice() Yu Kuai
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Yu Kuai @ 2023-08-16  1:27 UTC (permalink / raw)
  To: tj, josef, axboe, yukuai3, mkoutny
  Cc: cgroups, linux-block, linux-kernel, yukuai1, yi.zhang, yangerkun

From: Yu Kuai <yukuai3@huawei.com>

carryover_ios/bytes[] can be negative in the case that ios are
dispatched in the slice in advance, and then configuration is updated.
For example:

1) set iops limit to 1000, and slice start is 0, slice end is 100ms;
2) current time is 0, and 100 ios are dispatched, those ios will not be
   throttled, hence io_disp is 100;
3) still at current time 0, update iops limit to 100, then carryover_ios
   is (0 - 100) = -100;
4) then, dispatch a new io at time 0, the expected result is that this
   io will wait for 1s. The calculation in tg_within_iops_limit:

   io_disp = 0;
   io_allowed = calculate_io_allowed + carryover_ios
	      = 10 + (-100) = -90;
   io won't be throttled if (io_disp + 1 < io_allowed) passed.

Before this patch, in step 4) (io_disp + 1 < io_allowed) is passed,
because -90 for unsigned value is very huge, and such io won't be
throttled.

Fix this problem by checking if 'io/bytes_allowed' is negative first.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 block/blk-throttle.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 5184f17f5129..7c93144d03da 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -825,7 +825,7 @@ static unsigned long tg_within_iops_limit(struct throtl_grp *tg, struct bio *bio
 				 u32 iops_limit)
 {
 	bool rw = bio_data_dir(bio);
-	unsigned int io_allowed;
+	int io_allowed;
 	unsigned long jiffy_elapsed, jiffy_wait, jiffy_elapsed_rnd;
 
 	if (iops_limit == UINT_MAX) {
@@ -838,9 +838,8 @@ static unsigned long tg_within_iops_limit(struct throtl_grp *tg, struct bio *bio
 	jiffy_elapsed_rnd = roundup(jiffy_elapsed + 1, tg->td->throtl_slice);
 	io_allowed = calculate_io_allowed(iops_limit, jiffy_elapsed_rnd) +
 		     tg->carryover_ios[rw];
-	if (tg->io_disp[rw] + 1 <= io_allowed) {
+	if (io_allowed > 0 && tg->io_disp[rw] + 1 <= io_allowed)
 		return 0;
-	}
 
 	/* Calc approx time to dispatch */
 	jiffy_wait = jiffy_elapsed_rnd - jiffy_elapsed;
@@ -851,7 +850,8 @@ static unsigned long tg_within_bps_limit(struct throtl_grp *tg, struct bio *bio,
 				u64 bps_limit)
 {
 	bool rw = bio_data_dir(bio);
-	u64 bytes_allowed, extra_bytes;
+	long long bytes_allowed;
+	u64 extra_bytes;
 	unsigned long jiffy_elapsed, jiffy_wait, jiffy_elapsed_rnd;
 	unsigned int bio_size = throtl_bio_data_size(bio);
 
@@ -869,9 +869,8 @@ static unsigned long tg_within_bps_limit(struct throtl_grp *tg, struct bio *bio,
 	jiffy_elapsed_rnd = roundup(jiffy_elapsed_rnd, tg->td->throtl_slice);
 	bytes_allowed = calculate_bytes_allowed(bps_limit, jiffy_elapsed_rnd) +
 			tg->carryover_bytes[rw];
-	if (tg->bytes_disp[rw] + bio_size <= bytes_allowed) {
+	if (bytes_allowed > 0 && tg->bytes_disp[rw] + bio_size <= bytes_allowed)
 		return 0;
-	}
 
 	/* Calc approx time to dispatch */
 	extra_bytes = tg->bytes_disp[rw] + bio_size - bytes_allowed;
-- 
2.39.2


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

* [PATCH -next v2 3/4] blk-throttle: use calculate_io/bytes_allowed() for throtl_trim_slice()
  2023-08-16  1:27 [PATCH -next v2 0/4] cleanup and fixes for 'carryover_ios/bytes' Yu Kuai
  2023-08-16  1:27 ` [PATCH -next v2 1/4] blk-throttle: print signed value 'carryover_bytes/ios' for user Yu Kuai
  2023-08-16  1:27 ` [PATCH -next v2 2/4] blk-throttle: fix wrong comparation while 'carryover_ios/bytes' is negative Yu Kuai
@ 2023-08-16  1:27 ` Yu Kuai
  2023-08-29 22:20   ` Tejun Heo
  2023-08-16  1:27 ` [PATCH -next v2 4/4] blk-throttle: consider 'carryover_ios/bytes' in throtl_trim_slice() Yu Kuai
  2023-08-30 16:15 ` [PATCH -next v2 0/4] cleanup and fixes for 'carryover_ios/bytes' Jens Axboe
  4 siblings, 1 reply; 10+ messages in thread
From: Yu Kuai @ 2023-08-16  1:27 UTC (permalink / raw)
  To: tj, josef, axboe, yukuai3, mkoutny
  Cc: cgroups, linux-block, linux-kernel, yukuai1, yi.zhang, yangerkun

From: Yu Kuai <yukuai3@huawei.com>

There are no functional changes, just make the code cleaner.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 block/blk-throttle.c | 86 +++++++++++++++++++++-----------------------
 1 file changed, 41 insertions(+), 45 deletions(-)

diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 7c93144d03da..69a994156772 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -697,11 +697,40 @@ static bool throtl_slice_used(struct throtl_grp *tg, bool rw)
 	return true;
 }
 
+static unsigned int calculate_io_allowed(u32 iops_limit,
+					 unsigned long jiffy_elapsed)
+{
+	unsigned int io_allowed;
+	u64 tmp;
+
+	/*
+	 * jiffy_elapsed should not be a big value as minimum iops can be
+	 * 1 then at max jiffy elapsed should be equivalent of 1 second as we
+	 * will allow dispatch after 1 second and after that slice should
+	 * have been trimmed.
+	 */
+
+	tmp = (u64)iops_limit * jiffy_elapsed;
+	do_div(tmp, HZ);
+
+	if (tmp > UINT_MAX)
+		io_allowed = UINT_MAX;
+	else
+		io_allowed = tmp;
+
+	return io_allowed;
+}
+
+static u64 calculate_bytes_allowed(u64 bps_limit, unsigned long jiffy_elapsed)
+{
+	return mul_u64_u64_div_u64(bps_limit, (u64)jiffy_elapsed, (u64)HZ);
+}
+
 /* Trim the used slices and adjust slice start accordingly */
 static inline void throtl_trim_slice(struct throtl_grp *tg, bool rw)
 {
-	unsigned long nr_slices, time_elapsed, io_trim;
-	u64 bytes_trim, tmp;
+	unsigned long time_elapsed, io_trim;
+	u64 bytes_trim;
 
 	BUG_ON(time_before(tg->slice_end[rw], tg->slice_start[rw]));
 
@@ -723,19 +752,14 @@ static inline void throtl_trim_slice(struct throtl_grp *tg, bool rw)
 
 	throtl_set_slice_end(tg, rw, jiffies + tg->td->throtl_slice);
 
-	time_elapsed = jiffies - tg->slice_start[rw];
-
-	nr_slices = time_elapsed / tg->td->throtl_slice;
-
-	if (!nr_slices)
+	time_elapsed = rounddown(jiffies - tg->slice_start[rw],
+				 tg->td->throtl_slice);
+	if (!time_elapsed)
 		return;
-	tmp = tg_bps_limit(tg, rw) * tg->td->throtl_slice * nr_slices;
-	do_div(tmp, HZ);
-	bytes_trim = tmp;
-
-	io_trim = (tg_iops_limit(tg, rw) * tg->td->throtl_slice * nr_slices) /
-		HZ;
 
+	bytes_trim = calculate_bytes_allowed(tg_bps_limit(tg, rw),
+					     time_elapsed);
+	io_trim = calculate_io_allowed(tg_iops_limit(tg, rw), time_elapsed);
 	if (!bytes_trim && !io_trim)
 		return;
 
@@ -749,41 +773,13 @@ static inline void throtl_trim_slice(struct throtl_grp *tg, bool rw)
 	else
 		tg->io_disp[rw] = 0;
 
-	tg->slice_start[rw] += nr_slices * tg->td->throtl_slice;
+	tg->slice_start[rw] += time_elapsed;
 
 	throtl_log(&tg->service_queue,
 		   "[%c] trim slice nr=%lu bytes=%llu io=%lu start=%lu end=%lu jiffies=%lu",
-		   rw == READ ? 'R' : 'W', nr_slices, bytes_trim, io_trim,
-		   tg->slice_start[rw], tg->slice_end[rw], jiffies);
-}
-
-static unsigned int calculate_io_allowed(u32 iops_limit,
-					 unsigned long jiffy_elapsed)
-{
-	unsigned int io_allowed;
-	u64 tmp;
-
-	/*
-	 * jiffy_elapsed should not be a big value as minimum iops can be
-	 * 1 then at max jiffy elapsed should be equivalent of 1 second as we
-	 * will allow dispatch after 1 second and after that slice should
-	 * have been trimmed.
-	 */
-
-	tmp = (u64)iops_limit * jiffy_elapsed;
-	do_div(tmp, HZ);
-
-	if (tmp > UINT_MAX)
-		io_allowed = UINT_MAX;
-	else
-		io_allowed = tmp;
-
-	return io_allowed;
-}
-
-static u64 calculate_bytes_allowed(u64 bps_limit, unsigned long jiffy_elapsed)
-{
-	return mul_u64_u64_div_u64(bps_limit, (u64)jiffy_elapsed, (u64)HZ);
+		   rw == READ ? 'R' : 'W', time_elapsed / tg->td->throtl_slice,
+		   bytes_trim, io_trim, tg->slice_start[rw], tg->slice_end[rw],
+		   jiffies);
 }
 
 static void __tg_update_carryover(struct throtl_grp *tg, bool rw)
-- 
2.39.2


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

* [PATCH -next v2 4/4] blk-throttle: consider 'carryover_ios/bytes' in throtl_trim_slice()
  2023-08-16  1:27 [PATCH -next v2 0/4] cleanup and fixes for 'carryover_ios/bytes' Yu Kuai
                   ` (2 preceding siblings ...)
  2023-08-16  1:27 ` [PATCH -next v2 3/4] blk-throttle: use calculate_io/bytes_allowed() for throtl_trim_slice() Yu Kuai
@ 2023-08-16  1:27 ` Yu Kuai
  2023-08-29 22:20   ` Tejun Heo
  2023-08-30 16:15 ` [PATCH -next v2 0/4] cleanup and fixes for 'carryover_ios/bytes' Jens Axboe
  4 siblings, 1 reply; 10+ messages in thread
From: Yu Kuai @ 2023-08-16  1:27 UTC (permalink / raw)
  To: tj, josef, axboe, yukuai3, mkoutny
  Cc: cgroups, linux-block, linux-kernel, yukuai1, yi.zhang, yangerkun

From: Yu Kuai <yukuai3@huawei.com>

Currently, 'carryover_ios/bytes' is not handled in throtl_trim_slice(),
for consequence, 'carryover_ios/bytes' will be used to throttle bio
multiple times, for example:

1) set iops limit to 100, and slice start is 0, slice end is 100ms;
2) current time is 0, and 10 ios are dispatched, those io won't be
   throttled and io_disp is 10;
3) still at current time 0, update iops limit to 1000, carryover_ios is
   updated to (0 - 10) = -10;
4) in this slice(0 - 100ms), io_allowed = 100 + (-10) = 90, which means
   only 90 ios can be dispatched without waiting;
5) assume that io is throttled in slice(0 - 100ms), and
   throtl_trim_slice() update silce to (100ms - 200ms). In this case,
   'carryover_ios/bytes' is not cleared and still only 90 ios can be
   dispatched between 100ms - 200ms.

Fix this problem by updating 'carryover_ios/bytes' in
throtl_trim_slice().

Fixes: a880ae93e5b5 ("blk-throttle: fix io hung due to configuration updates")
Reported-by: zhuxiaohui <zhuxiaohui.400@bytedance.com>
Link: https://lore.kernel.org/all/20230812072116.42321-1-zhuxiaohui.400@bytedance.com/
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 block/blk-throttle.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 69a994156772..38a881cf97d0 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -729,8 +729,9 @@ static u64 calculate_bytes_allowed(u64 bps_limit, unsigned long jiffy_elapsed)
 /* Trim the used slices and adjust slice start accordingly */
 static inline void throtl_trim_slice(struct throtl_grp *tg, bool rw)
 {
-	unsigned long time_elapsed, io_trim;
-	u64 bytes_trim;
+	unsigned long time_elapsed;
+	long long bytes_trim;
+	int io_trim;
 
 	BUG_ON(time_before(tg->slice_end[rw], tg->slice_start[rw]));
 
@@ -758,17 +759,21 @@ static inline void throtl_trim_slice(struct throtl_grp *tg, bool rw)
 		return;
 
 	bytes_trim = calculate_bytes_allowed(tg_bps_limit(tg, rw),
-					     time_elapsed);
-	io_trim = calculate_io_allowed(tg_iops_limit(tg, rw), time_elapsed);
-	if (!bytes_trim && !io_trim)
+					     time_elapsed) +
+		     tg->carryover_bytes[rw];
+	io_trim = calculate_io_allowed(tg_iops_limit(tg, rw), time_elapsed) +
+		  tg->carryover_ios[rw];
+	if (bytes_trim <= 0 && io_trim <= 0)
 		return;
 
-	if (tg->bytes_disp[rw] >= bytes_trim)
+	tg->carryover_bytes[rw] = 0;
+	if ((long long)tg->bytes_disp[rw] >= bytes_trim)
 		tg->bytes_disp[rw] -= bytes_trim;
 	else
 		tg->bytes_disp[rw] = 0;
 
-	if (tg->io_disp[rw] >= io_trim)
+	tg->carryover_ios[rw] = 0;
+	if ((int)tg->io_disp[rw] >= io_trim)
 		tg->io_disp[rw] -= io_trim;
 	else
 		tg->io_disp[rw] = 0;
@@ -776,7 +781,7 @@ static inline void throtl_trim_slice(struct throtl_grp *tg, bool rw)
 	tg->slice_start[rw] += time_elapsed;
 
 	throtl_log(&tg->service_queue,
-		   "[%c] trim slice nr=%lu bytes=%llu io=%lu start=%lu end=%lu jiffies=%lu",
+		   "[%c] trim slice nr=%lu bytes=%lld io=%d start=%lu end=%lu jiffies=%lu",
 		   rw == READ ? 'R' : 'W', time_elapsed / tg->td->throtl_slice,
 		   bytes_trim, io_trim, tg->slice_start[rw], tg->slice_end[rw],
 		   jiffies);
-- 
2.39.2


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

* Re: [PATCH -next v2 1/4] blk-throttle: print signed value 'carryover_bytes/ios' for user
  2023-08-16  1:27 ` [PATCH -next v2 1/4] blk-throttle: print signed value 'carryover_bytes/ios' for user Yu Kuai
@ 2023-08-29 22:17   ` Tejun Heo
  0 siblings, 0 replies; 10+ messages in thread
From: Tejun Heo @ 2023-08-29 22:17 UTC (permalink / raw)
  To: Yu Kuai
  Cc: josef, axboe, yukuai3, mkoutny, cgroups, linux-block,
	linux-kernel, yi.zhang, yangerkun

On Wed, Aug 16, 2023 at 09:27:05AM +0800, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
> 
> 'carryover_bytes/ios' can be negative, indicate that some bio is
> dispatched in advance within slice while configuration is updated.
> Print a huge value is not user-friendly.
> 
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>

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

Thanks.

-- 
tejun

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

* Re: [PATCH -next v2 2/4] blk-throttle: fix wrong comparation while 'carryover_ios/bytes' is negative
  2023-08-16  1:27 ` [PATCH -next v2 2/4] blk-throttle: fix wrong comparation while 'carryover_ios/bytes' is negative Yu Kuai
@ 2023-08-29 22:18   ` Tejun Heo
  0 siblings, 0 replies; 10+ messages in thread
From: Tejun Heo @ 2023-08-29 22:18 UTC (permalink / raw)
  To: Yu Kuai
  Cc: josef, axboe, yukuai3, mkoutny, cgroups, linux-block,
	linux-kernel, yi.zhang, yangerkun

On Wed, Aug 16, 2023 at 09:27:06AM +0800, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
> 
> carryover_ios/bytes[] can be negative in the case that ios are
> dispatched in the slice in advance, and then configuration is updated.
> For example:
> 
> 1) set iops limit to 1000, and slice start is 0, slice end is 100ms;
> 2) current time is 0, and 100 ios are dispatched, those ios will not be
>    throttled, hence io_disp is 100;
> 3) still at current time 0, update iops limit to 100, then carryover_ios
>    is (0 - 100) = -100;
> 4) then, dispatch a new io at time 0, the expected result is that this
>    io will wait for 1s. The calculation in tg_within_iops_limit:
> 
>    io_disp = 0;
>    io_allowed = calculate_io_allowed + carryover_ios
> 	      = 10 + (-100) = -90;
>    io won't be throttled if (io_disp + 1 < io_allowed) passed.
> 
> Before this patch, in step 4) (io_disp + 1 < io_allowed) is passed,
> because -90 for unsigned value is very huge, and such io won't be
> throttled.
> 
> Fix this problem by checking if 'io/bytes_allowed' is negative first.
> 
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>

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

Thanks.

-- 
tejun

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

* Re: [PATCH -next v2 3/4] blk-throttle: use calculate_io/bytes_allowed() for throtl_trim_slice()
  2023-08-16  1:27 ` [PATCH -next v2 3/4] blk-throttle: use calculate_io/bytes_allowed() for throtl_trim_slice() Yu Kuai
@ 2023-08-29 22:20   ` Tejun Heo
  0 siblings, 0 replies; 10+ messages in thread
From: Tejun Heo @ 2023-08-29 22:20 UTC (permalink / raw)
  To: Yu Kuai
  Cc: josef, axboe, yukuai3, mkoutny, cgroups, linux-block,
	linux-kernel, yi.zhang, yangerkun

On Wed, Aug 16, 2023 at 09:27:07AM +0800, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
> 
> There are no functional changes, just make the code cleaner.
> 
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>

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

Thanks.

-- 
tejun

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

* Re: [PATCH -next v2 4/4] blk-throttle: consider 'carryover_ios/bytes' in throtl_trim_slice()
  2023-08-16  1:27 ` [PATCH -next v2 4/4] blk-throttle: consider 'carryover_ios/bytes' in throtl_trim_slice() Yu Kuai
@ 2023-08-29 22:20   ` Tejun Heo
  0 siblings, 0 replies; 10+ messages in thread
From: Tejun Heo @ 2023-08-29 22:20 UTC (permalink / raw)
  To: Yu Kuai
  Cc: josef, axboe, yukuai3, mkoutny, cgroups, linux-block,
	linux-kernel, yi.zhang, yangerkun

On Wed, Aug 16, 2023 at 09:27:08AM +0800, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
> 
> Currently, 'carryover_ios/bytes' is not handled in throtl_trim_slice(),
> for consequence, 'carryover_ios/bytes' will be used to throttle bio
> multiple times, for example:
> 
> 1) set iops limit to 100, and slice start is 0, slice end is 100ms;
> 2) current time is 0, and 10 ios are dispatched, those io won't be
>    throttled and io_disp is 10;
> 3) still at current time 0, update iops limit to 1000, carryover_ios is
>    updated to (0 - 10) = -10;
> 4) in this slice(0 - 100ms), io_allowed = 100 + (-10) = 90, which means
>    only 90 ios can be dispatched without waiting;
> 5) assume that io is throttled in slice(0 - 100ms), and
>    throtl_trim_slice() update silce to (100ms - 200ms). In this case,
>    'carryover_ios/bytes' is not cleared and still only 90 ios can be
>    dispatched between 100ms - 200ms.
> 
> Fix this problem by updating 'carryover_ios/bytes' in
> throtl_trim_slice().
> 
> Fixes: a880ae93e5b5 ("blk-throttle: fix io hung due to configuration updates")
> Reported-by: zhuxiaohui <zhuxiaohui.400@bytedance.com>
> Link: https://lore.kernel.org/all/20230812072116.42321-1-zhuxiaohui.400@bytedance.com/
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>

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

Thanks.

-- 
tejun

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

* Re: [PATCH -next v2 0/4] cleanup and fixes for 'carryover_ios/bytes'
  2023-08-16  1:27 [PATCH -next v2 0/4] cleanup and fixes for 'carryover_ios/bytes' Yu Kuai
                   ` (3 preceding siblings ...)
  2023-08-16  1:27 ` [PATCH -next v2 4/4] blk-throttle: consider 'carryover_ios/bytes' in throtl_trim_slice() Yu Kuai
@ 2023-08-30 16:15 ` Jens Axboe
  4 siblings, 0 replies; 10+ messages in thread
From: Jens Axboe @ 2023-08-30 16:15 UTC (permalink / raw)
  To: tj, josef, yukuai3, mkoutny, Yu Kuai
  Cc: cgroups, linux-block, linux-kernel, yi.zhang, yangerkun


On Wed, 16 Aug 2023 09:27:04 +0800, Yu Kuai wrote:
> changes in v2:
>  - fix missing adjustment in throtl_log().
> 
> Patch 1 print signed value for 'carryover_ios/bytes' to user.
> 
> Patch 2 fix that comparation ”unsigned value < negative value“ will
> pass, causing that io won't be throttled in the silce.
> 
> [...]

Applied, thanks!

[1/4] blk-throttle: print signed value 'carryover_bytes/ios' for user
      commit: ef100397fac3e2e403d5d510e66f36e242654073
[2/4] blk-throttle: fix wrong comparation while 'carryover_ios/bytes' is negative
      commit: bb8d5587bdc3ab211e1eae2eeb966f7a7d1f9c0b
[3/4] blk-throttle: use calculate_io/bytes_allowed() for throtl_trim_slice()
      commit: e8368b57c006dc0e02dcd8a9dc9f2060ff5476fe
[4/4] blk-throttle: consider 'carryover_ios/bytes' in throtl_trim_slice()
      commit: eead0056648cef49d7b15c07ae612fa217083165

Best regards,
-- 
Jens Axboe




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

end of thread, other threads:[~2023-08-30 18:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-16  1:27 [PATCH -next v2 0/4] cleanup and fixes for 'carryover_ios/bytes' Yu Kuai
2023-08-16  1:27 ` [PATCH -next v2 1/4] blk-throttle: print signed value 'carryover_bytes/ios' for user Yu Kuai
2023-08-29 22:17   ` Tejun Heo
2023-08-16  1:27 ` [PATCH -next v2 2/4] blk-throttle: fix wrong comparation while 'carryover_ios/bytes' is negative Yu Kuai
2023-08-29 22:18   ` Tejun Heo
2023-08-16  1:27 ` [PATCH -next v2 3/4] blk-throttle: use calculate_io/bytes_allowed() for throtl_trim_slice() Yu Kuai
2023-08-29 22:20   ` Tejun Heo
2023-08-16  1:27 ` [PATCH -next v2 4/4] blk-throttle: consider 'carryover_ios/bytes' in throtl_trim_slice() Yu Kuai
2023-08-29 22:20   ` Tejun Heo
2023-08-30 16:15 ` [PATCH -next v2 0/4] cleanup and fixes for 'carryover_ios/bytes' Jens Axboe

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®