Message ID | 20221123060401.20392-9-shikemeng@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | A few bugfix and cleanup patches for blk-throttle | expand |
On Wed, Nov 23, 2022 at 02:03:58PM +0800, Kemeng Shi wrote: > static bool throtl_hierarchy_can_downgrade(struct throtl_grp *tg) > { > + if (time_before(now, tg->td->low_upgrade_time + td->throtl_slice)) > + return false; Does this even build? Where is td defined?
on 11/24/2022 2:28 AM, Tejun Heo wrote: > On Wed, Nov 23, 2022 at 02:03:58PM +0800, Kemeng Shi wrote: >> static bool throtl_hierarchy_can_downgrade(struct throtl_grp *tg) >> { >> + if (time_before(now, tg->td->low_upgrade_time + td->throtl_slice)) >> + return false; > > Does this even build? Where is td defined? Sorry for this mistake, CONFIG_BLK_DEV_THROTTLING_LOW seems not be set on default. I will fix this and build with CONFIG_BLK_DEV_THROTTLING_LOW set.
diff --git a/block/blk-throttle.c b/block/blk-throttle.c index bd07f562c799..3eccc7af4368 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -1932,8 +1932,7 @@ static bool throtl_tg_can_downgrade(struct throtl_grp *tg) * If cgroup is below low limit, consider downgrade and throttle other * cgroups */ - if (time_after_eq(now, td->low_upgrade_time + td->throtl_slice) && - time_after_eq(now, tg_last_low_overflow_time(tg) + + if (time_after_eq(now, tg_last_low_overflow_time(tg) + td->throtl_slice) && (!throtl_tg_is_idle(tg) || !list_empty(&tg_to_blkg(tg)->blkcg->css.children))) @@ -1943,6 +1942,9 @@ static bool throtl_tg_can_downgrade(struct throtl_grp *tg) static bool throtl_hierarchy_can_downgrade(struct throtl_grp *tg) { + if (time_before(now, tg->td->low_upgrade_time + td->throtl_slice)) + return false; + while (true) { if (!throtl_tg_can_downgrade(tg)) return false;
There is no need to check elapsed time from last upgrade for each node in hierarchy. Move this check before traversing as throtl_can_upgrade do to remove repeat check. Signed-off-by: Kemeng Shi <shikemeng@huawei.com> --- block/blk-throttle.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)