This is a note to let you know that I've just added the patch titled blk-throttle: Fix that bps of child could exceed bps limited in parent 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-fix-that-bps-of-child-could-exceed-bps-limited-in-parent.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. >From 84aca0a7e039c8735abc0f89f3f48e9006c0dfc7 Mon Sep 17 00:00:00 2001 From: Kemeng Shi <shikemeng@xxxxxxxxxx> Date: Mon, 5 Dec 2022 19:57:02 +0800 Subject: blk-throttle: Fix that bps of child could exceed bps limited in parent From: Kemeng Shi <shikemeng@xxxxxxxxxx> commit 84aca0a7e039c8735abc0f89f3f48e9006c0dfc7 upstream. Consider situation as following (on the default hierarchy): HDD | root (bps limit: 4k) | child (bps limit :8k) | fio bs=8k Rate of fio is supposed to be 4k, but result is 8k. Reason is as following: Size of single IO from fio is larger than bytes allowed in one throtl_slice in child, so IOs are always queued in child group first. When queued IOs in child are dispatched to parent group, BIO_BPS_THROTTLED is set and these IOs will not be limited by tg_within_bps_limit anymore. Fix this by only set BIO_BPS_THROTTLED when the bio traversed the entire tree. There patch has no influence on situation which is not on the default hierarchy as each group is a single root group without parent. Acked-by: Tejun Heo <tj@xxxxxxxxxx> Signed-off-by: Kemeng Shi <shikemeng@xxxxxxxxxx> Link: https://lore.kernel.org/r/20221205115709.251489-3-shikemeng@xxxxxxxxxxxxxxx Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> Cc: Khazhy Kumykov <khazhy@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- block/blk-throttle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -1066,7 +1066,6 @@ static void tg_dispatch_one_bio(struct t sq->nr_queued[rw]--; throtl_charge_bio(tg, bio); - bio_set_flag(bio, BIO_BPS_THROTTLED); /* * If our parent is another tg, we just need to transfer @bio to @@ -1079,6 +1078,7 @@ static void tg_dispatch_one_bio(struct t throtl_add_bio_tg(bio, &tg->qnode_on_parent[rw], parent_tg); start_parent_slice_with_credit(tg, parent_tg, rw); } else { + bio_set_flag(bio, BIO_BPS_THROTTLED); throtl_qnode_add_bio(bio, &tg->qnode_on_parent[rw], &parent_sq->queued[rw]); BUG_ON(tg->td->nr_queued[rw] <= 0); Patches currently in stable-queue which might be from shikemeng@xxxxxxxxxx are queue-6.1/blk-throttle-fix-that-bps-of-child-could-exceed-bps-limited-in-parent.patch