[7/8] blk-iocost: Remove redundant initialization of struct ioc_gq
Commit Message
Some member of struct ioc_gq will not be accessed before it's
first activation and will be initialized again in it's first
activation after ioc_pd_init. To be more specific:
1)Member iocg->vtime and iocg->done_vtime will set to target in
activation which only expects vtime is equal to done_vtime in
first activation.
2)Member iocg->active_period will be set with ioc->cur_period
again in first activation.
Remove the redundant initialization to improve ioc_pd_init a
littile bit.
The parameter now of weight_updated will not be used if iocg is
not active, so pass NULL to weight_update here is safe and we
can remove call to ioc_now.
Signed-off-by: Kemeng Shi <shikemeng@huawei.com>
---
block/blk-iocost.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
Comments
On Mon, Oct 17, 2022 at 10:00:10AM +0800, Kemeng Shi wrote:
> Some member of struct ioc_gq will not be accessed before it's
> first activation and will be initialized again in it's first
> activation after ioc_pd_init. To be more specific:
> 1)Member iocg->vtime and iocg->done_vtime will set to target in
> activation which only expects vtime is equal to done_vtime in
> first activation.
> 2)Member iocg->active_period will be set with ioc->cur_period
> again in first activation.
>
> Remove the redundant initialization to improve ioc_pd_init a
> littile bit.
>
> The parameter now of weight_updated will not be used if iocg is
> not active, so pass NULL to weight_update here is safe and we
> can remove call to ioc_now.
This isn't a meaningful optimization and makes the code fragile for no
practical gain. Let's not do this.
Thanks.
@@ -2946,16 +2946,10 @@ static void ioc_pd_init(struct blkg_policy_data *pd)
struct ioc_gq *iocg = pd_to_iocg(pd);
struct blkcg_gq *blkg = pd_to_blkg(&iocg->pd);
struct ioc *ioc = q_to_ioc(blkg->q);
- struct ioc_now now;
struct blkcg_gq *tblkg;
unsigned long flags;
- ioc_now(ioc, &now);
-
iocg->ioc = ioc;
- atomic64_set(&iocg->vtime, now.vnow);
- atomic64_set(&iocg->done_vtime, now.vnow);
- atomic64_set(&iocg->active_period, atomic64_read(&ioc->cur_period));
INIT_LIST_HEAD(&iocg->active_list);
INIT_LIST_HEAD(&iocg->walk_list);
INIT_LIST_HEAD(&iocg->surplus_list);
@@ -2974,7 +2968,7 @@ static void ioc_pd_init(struct blkg_policy_data *pd)
}
spin_lock_irqsave(&ioc->lock, flags);
- weight_updated(iocg, &now);
+ weight_updated(iocg, NULL);
spin_unlock_irqrestore(&ioc->lock, flags);
}