Hi,
在 2025/9/4 18:05, Han Guangjiang 写道:
Hi,
static inline bool blk_throtl_activated(struct request_queue *q)
{
- return q->td != NULL;
+ return q->td != NULL && test_bit(blkcg_policy_throtl.plid, q->blkcg_pols);
}
You can just remove the fist checking, p->td must be set if policy is
enabled. And please make blkcg_policy_enabled() inline function in
blk-cgroup.h and use it here.
We intentionally kept the q->td != NULL check because we cannot guarantee
that the policy module is fully loaded when this function is called.
If the policy module is not loaded yet, blkcg_policy_throtl.plid might not be
assigned, which could cause the test_bit() check to be incorrect.
By keeping this check, we ensure that we have at least reached the cgroup
configuration flow, indicating that the policy loading is complete.
I'm wondering if there are any risks here and whether we should remove
the q->td != NULL check?
I think there is none. blk-throttle can't be build as module, if config is n,
blk_throtl_bio() is a non-function, if config is y, policy is registered during
init. And throtl_init() failure will panic, noted blkcg_policy_register() will
never fail for blk-throttle. BTW, policy pid is not a dynamic value at runtime.
Perhaps remove the checking and add some comments?
Thanks,
Kuai
Thanks,
Han Guangjiang