Re: [PATCH] blk-cgroup: skip rstat flush for cgroups without blkgs
From: Tejun Heo
Date: Thu Sep 17 2026 - 17:01:54 EST
On Thu, Sep 17, 2026 at 09:10:20AM -0700, Usama Arif wrote:
> Non-root io.stat reads flush the blkcg rstat subtree before walking
> ->blkg_list. This takes the subsystem rstat lock and checks for pending
> updates on every possible CPU, even when there is no per-device state to
> print.
>
> Blkg creation is hierarchical. A descendant blkg implies an ancestor
> blkg on the same device, so an empty ->blkg_list means the subtree cannot
> contribute any output. Return early in that case.
>
> A concurrent first blkg may be deferred to the next read. This is
> consistent with the existing non-atomic flush and list walk.
>
> This is not rare: 340 of 969 io.stat files were empty on a 316-CPU host.
> In a 16-vCPU lockdep-enabled guest, the median
Can you please test on a kernel w/ lockdep disabled? It doesn't make much
sense to compare performance numbers with lockdep enabled.
> open/read/close time over 35 batches of 20,000 reads changed as follows:
>
> before after
> empty io.stat 49.1 us 41.0 us
> populated io.stat 49.9 us 50.2 us
>
> This is a 16.6% reduction for empty reads. Populated reads were unchanged
> within measurement noise.
>
> Signed-off-by: Usama Arif <usama.arif@xxxxxxxxx>
That said, I don't see any downsides:
Acked-by: Tejun Heo <tj@xxxxxxxxxx>
Thanks.
--
tejun