Patch "blk-throttle: consider 'carryover_ios/bytes' in throtl_trim_slice()" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    blk-throttle: consider 'carryover_ios/bytes' in throtl_trim_slice()

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     blk-throttle-consider-carryover_ios-bytes-in-throtl_.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit b70ad61469004a72e48df14394fe63c889c76f43
Author: Yu Kuai <yukuai3@xxxxxxxxxx>
Date:   Wed Aug 16 09:27:08 2023 +0800

    blk-throttle: consider 'carryover_ios/bytes' in throtl_trim_slice()
    
    [ Upstream commit eead0056648cef49d7b15c07ae612fa217083165 ]
    
    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@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/all/20230812072116.42321-1-zhuxiaohui.400@xxxxxxxxxxxxx/
    Signed-off-by: Yu Kuai <yukuai3@xxxxxxxxxx>
    Acked-by: Tejun Heo <tj@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230816012708.1193747-5-yukuai1@xxxxxxxxxxxxxxx
    Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 931795da4d65d..1007f80278579 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);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux