Re: [PATCH 1/3] blk-iolatency: clear delay state when freeing policy data

From: Usama Arif

Date: Wed Aug 12 2026 - 06:05:25 EST




On 10/08/2026 19:48, Tejun Heo wrote:
> On Thu, Aug 06, 2026 at 11:37:18AM -0700, Usama Arif wrote:
>> static void iolatency_pd_free(struct blkg_policy_data *pd)
>> {
>> + struct blkcg_gq *blkg = pd_to_blkg(pd);
>> +
>> + /*
>> + * Groups throttled as collateral have min_lat_nsec == 0, so
>> + * iolatency_pd_offline() leaves their delay set. Drop it here, where
>> + * no in-flight bio can re-arm it via check_scale_change().
>> + */
>> + if (blkg)
>
> When can blkg be NULL here?
>
> Thanks.
>

Not in the normal case.

pd->blkg is only set when the pd is attached to a blkg.
blkcg_activate_policy() pre-allocates one outside the queue_lock when the
GFP_NOWAIT allocation fails, and frees it through pd_free_fn() if it ends up
unused — both at the retry and at the out: label. That pd never had ->blkg assigned.
It reads as NULL rather than garbage because iolatency_pd_alloc() uses kzalloc_node().

Good to keep as a guard in this case?