Re: [PATCH 3/3] block: skip blkcg walk in blk_cgroup_congested() when nothing throttled
From: Usama Arif
Date: Wed Aug 12 2026 - 06:04:37 EST
On 10/08/2026 19:56, Tejun Heo wrote:
> Hello,
>
> On Thu, Aug 06, 2026 at 11:37:20AM -0700, Usama Arif wrote:
>> @@ -53,6 +53,9 @@ EXPORT_SYMBOL_GPL(blkcg_root);
>> struct cgroup_subsys_state * const blkcg_root_css = &blkcg_root.css;
>> EXPORT_SYMBOL_GPL(blkcg_root_css);
>>
>> +/* number of blkcgs with a non-zero congestion_count */
>> +atomic_t blkcg_congested_blkcgs __read_mostly = ATOMIC_INIT(0);
>
> Maybe name it to clarify that this is a count. nr_ or _cnt or whatever.
>
>> @@ -1350,6 +1353,16 @@ static void blkcg_css_free(struct cgroup_subsys_state *css)
>> struct blkcg *blkcg = css_to_blkcg(css);
>> int i;
>>
>> + /*
>> + * Every blkg holds a reference on this css and drops any delay it
>> + * still has from pd_free_fn(), so this is expected to be zero. Should
>> + * a policy ever leave one behind, drop it here rather than let it pin
>> + * blkcg_congested_blkcgs and disable the fast path for the rest of the
>> + * boot. Nothing can race with us at this point.
>> + */
>> + if (atomic_xchg(&blkcg->congestion_count, 0) > 0)
>> + atomic_dec(&blkcg_congested_blkcgs);
>
> Maybe put WARN_ON_ONCE() on it?
>
>> +static inline void blkcg_dec_congestion_count(struct blkcg *blkcg)
>> +{
>> + if (atomic_dec_return(&blkcg->congestion_count) == 0)
>> + atomic_dec(&blkcg_congested_blkcgs);
>
> atomic_dec_and_test() is minutely more efficient.
>
> Thanks.
>
Thanks! Ack on all 3. I will wait a day incase there are more comments
and send a new revision tomorrow with all 3 addressed.