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

Usama Arif <[email protected]>
Newsgroups org.kernel.vger.linux-block,org.kernel.vger.cgroups,org.kernel.vger.linux-kernel
Message-ID <[email protected]>

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?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.