2022-12-05 04:35:10

by Kemeng Shi

[permalink] [raw]
Subject: [PATCH v3 0/9] A few bugfix and cleanup patches for blk-throttle

Hi, this series contain a few patches to fix problem when on the default
hierarchy, corret comment and so on. More details can be found in
respective changelogs. Thanks.

---
V2->V3:
-Thanks for the review and advice from Tejun. Now all patches are acked
by Tejun.
-remove quotes around parent in corrected comment in patch "blk-throttle:
correct stale comment in throtl_pd_init"
-improve log message and rename throtl_tg_reach_low_limit to
throtl_low_limit_reached.
-drop patch "blk-throttle: avoid dead code in
throtl_hierarchy_can_upgrade"
---
V1->V2:
-Thanks for the review and advice from Tejun. The corrected comment of
"blk-throttle: correct stale comment in throtl_pd_init" and the
solution of "blk-throttle: Fix that bps of child could exceed bps
limited in parent" are from reply of Tejun.
-Collect Ack from Tejun.
-Fix the compile problem when CONFIG_BLK_DEV_THROTTLING_LOW is set.
-Drop "blk-throttle: Limit whole system if root group is configured
when on the default hierarchy", "blk-throttle: remove unnecessary check
for validation of limit index" and "blk-throttle: remove unused variable
td in tg_update_has_rules"
-Add "blk-throttle: correct stale comment in throtl_pd_init" and
"blk-throttle: avoid dead code in throtl_hierarchy_can_upgrade"
-Use solution that set the BIO_BPS_THROTTLED flag only when the bio
traversed the entire tree to fix that bps of child could exceed bps
limited in parent in patch 2/10.
-Improve the description and comment of most commits.
---

Kemeng Shi (9):
blk-throttle: correct stale comment in throtl_pd_init
blk-throttle: Fix that bps of child could exceed bps limited in parent
blk-throttle: ignore cgroup without io queued in
blk_throtl_cancel_bios
blk-throttle: correct calculation of wait time in tg_may_dispatch
blk-throttle: simpfy low limit reached check in throtl_tg_can_upgrade
blk-throttle: fix typo in comment of throtl_adjusted_limit
blk-throttle: remove incorrect comment for tg_last_low_overflow_time
blk-throttle: remove repeat check of elapsed time from last upgrade in
throtl_hierarchy_can_downgrade
blk-throttle: Use more siutable time_after check for update of
slice_start

block/blk-throttle.c | 102 +++++++++++++++++++++++--------------------
1 file changed, 55 insertions(+), 47 deletions(-)

--
2.30.0


2022-12-05 04:47:08

by Kemeng Shi

[permalink] [raw]
Subject: [PATCH v3 3/9] blk-throttle: ignore cgroup without io queued in blk_throtl_cancel_bios

From: Kemeng Shi <[email protected]>

Ignore cgroup without io queued in blk_throtl_cancel_bios for two
reasons:
1. Save cpu cycle for trying to dispatch cgroup which is no io queued.
2. Avoid non-consistent state that cgroup is inserted to service queue
without THROTL_TG_PENDING set as tg_update_disptime will unconditional
re-insert cgroup to service queue. If we are on the default hierarchy,
IO dispatched from child in tg_dispatch_one_bio will trigger inserting
cgroup to service queue without erase first and ruin the tree.

Signed-off-by: Kemeng Shi <[email protected]>
Acked-by: Tejun Heo <[email protected]>
Signed-off-by: Kemeng Shi <[email protected]>
---
block/blk-throttle.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 2444ebf5f11d..75010110d481 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -1738,7 +1738,18 @@ void blk_throtl_cancel_bios(struct gendisk *disk)
* Set the flag to make sure throtl_pending_timer_fn() won't
* stop until all throttled bios are dispatched.
*/
- blkg_to_tg(blkg)->flags |= THROTL_TG_CANCELING;
+ tg->flags |= THROTL_TG_CANCELING;
+
+ /*
+ * Do not dispatch cgroup without THROTL_TG_PENDING or cgroup
+ * will be inserted to service queue without THROTL_TG_PENDING
+ * set in tg_update_disptime below. Then IO dispatched from
+ * child in tg_dispatch_one_bio will trigger double insertion
+ * and corrupt the tree.
+ */
+ if (!(tg->flags & THROTL_TG_PENDING))
+ continue;
+
/*
* Update disptime after setting the above flag to make sure
* throtl_select_dispatch() won't exit without dispatching.
--
2.30.0

2022-12-05 20:57:23

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCH v3 0/9] A few bugfix and cleanup patches for blk-throttle


On Mon, 05 Dec 2022 19:57:00 +0800, Kemeng Shi wrote:
> hierarchy, corret comment and so on. More details can be found in
> respective changelogs. Thanks.
>

Applied, thanks!

[1/9] blk-throttle: correct stale comment in throtl_pd_init
commit: f56019aef353576f43f945fdd065858145090582
[2/9] blk-throttle: Fix that bps of child could exceed bps limited in parent
commit: 84aca0a7e039c8735abc0f89f3f48e9006c0dfc7
[3/9] blk-throttle: ignore cgroup without io queued in blk_throtl_cancel_bios
commit: eb184791821409c37fef4f67638bb56bdaa82900
[4/9] blk-throttle: correct calculation of wait time in tg_may_dispatch
commit: 183daeb11de871b073515d14ec1e3bc0da79e038
[5/9] blk-throttle: simpfy low limit reached check in throtl_tg_can_upgrade
commit: a4d508e333829a8394e59efa06ce56e51f3e2b29
[6/9] blk-throttle: fix typo in comment of throtl_adjusted_limit
commit: 009df341714c6c20a44dd9268681a8bff10bb050
[7/9] blk-throttle: remove incorrect comment for tg_last_low_overflow_time
commit: e3031d4c7d2c5bff6b5944d61d4e31319739d216
[8/9] blk-throttle: remove repeat check of elapsed time from last upgrade in throtl_hierarchy_can_downgrade
commit: 9c9f209d9d81ea67cd84f53f470a592c252d845d
[9/9] blk-throttle: Use more siutable time_after check for update of slice_start
commit: eea3e8b74aa1648fc96b739458d067a6e498c302

Best regards,
--
Jens Axboe