Re: [PATCH] blk-cgroup: fix missing pd_online_fn() while activating policy

From: Yu Kuai
Date: Wed Jan 04 2023 - 20:43:30 EST


Hi, Michal

在 2023/01/04 23:12, Michal Koutný 写道:
Hello.

On Tue, Jan 03, 2023 at 07:28:33PM +0800, Yu Kuai <yukuai1@xxxxxxxxxxxxxxx> wrote:
If the policy defines pd_online_fn(), it should be called after
pd_init_fn(), like blkg_create().

Is this based only on code review or has it some negative effects?

This is based only on code review, currently the only negative effects
is that root blkg from blk-throtl won't call pd_online_fn().

I assume this would affect hot-plugged (read after cgroup creation) devices.

I took a cursory look at:

blkcg_init_disk
blkg_create
pol->pd_init_fn(blkg->pd[i]);
pol->pd_online_fn(blkg->pd[i]);
blk_throtl_init
blkcg_activate_policy
pol->pd_init_fn(blkg->pd[i]);
?? pol->pd_online_fn(blkg->pd[i]);

I.e. the pd_online_fn is already called and pd_init_fn is called 2nd
time?

No, this is not true, before blkcg_activate_policy() is called,
blkg_create() won't see this policy, hence pd_init_fn/pd_online_fn won't
be called from blkg_create().

Thanks,
Kuai

Thanks,
Michal