The commit ac33e91e2dac ("blk-iocost: implement vtime loss compensation") add the second current_hweight() in the loop of active iocgs list to get old_hwi to calculate the vtime loss of the iocg. Since the hwi can't change and the first current_hweight already get hwa and hwi, so this second superfluous current_hweight() can be removed. There should be no functional changes. Signed-off-by: Chengming Zhou <zhouchengming@xxxxxxxxxxxxx> --- block/blk-iocost.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 33a11ba971ea..3cda08224d51 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -2238,7 +2238,7 @@ static void ioc_timer_fn(struct timer_list *timer) /* calc usage and see whether some weights need to be moved around */ list_for_each_entry(iocg, &ioc->active_iocgs, active_list) { u64 vdone, vtime, usage_us; - u32 hw_active, hw_inuse; + u32 hwa, old_hwi; /* * Collect unused and wind vtime closer to vnow to prevent @@ -2246,7 +2246,7 @@ static void ioc_timer_fn(struct timer_list *timer) */ vdone = atomic64_read(&iocg->done_vtime); vtime = atomic64_read(&iocg->vtime); - current_hweight(iocg, &hw_active, &hw_inuse); + current_hweight(iocg, &hwa, &old_hwi); /* * Latency QoS detection doesn't account for IOs which are @@ -2271,15 +2271,15 @@ static void ioc_timer_fn(struct timer_list *timer) /* see whether there's surplus vtime */ WARN_ON_ONCE(!list_empty(&iocg->surplus_list)); - if (hw_inuse < hw_active || + if (old_hwi < hwa || (!waitqueue_active(&iocg->waitq) && time_before64(vtime, now.vnow - ioc->margins.low))) { - u32 hwa, old_hwi, hwm, new_hwi, usage; + u32 hwm, new_hwi, usage; u64 usage_dur; if (vdone != vtime) { u64 inflight_us = DIV64_U64_ROUND_UP( - cost_to_abs_cost(vtime - vdone, hw_inuse), + cost_to_abs_cost(vtime - vdone, old_hwi), ioc->vtime_base_rate); usage_us = max(usage_us, inflight_us); @@ -2300,7 +2300,6 @@ static void ioc_timer_fn(struct timer_list *timer) * Already donating or accumulated enough to start. * Determine the donation amount. */ - current_hweight(iocg, &hwa, &old_hwi); hwm = current_hweight_max(iocg); new_hwi = hweight_after_donation(iocg, old_hwi, hwm, usage, &now); -- 2.36.1