Skip to content

blkcg: decouple cgroup v1 I/O accounting from throttling - #1587

Open
ghost wants to merge 3 commits into
linus-master_basefrom
series/1207126=>linus-master
Open

ghost wants to merge 3 commits into
linus-master_basefrom
series/1207126=>linus-master

Conversation

@ghost

@ghost ghost commented Nov 10, 2026

Copy link
Copy Markdown

Pull request for series with
subject: blkcg: decouple cgroup v1 I/O accounting from throttling
version: 1
url: https://patchwork.kernel.org/series/1207126/

Zhe Liu added 3 commits November 10, 2026 19:50
The existing rwstat formatter takes a blkg_policy_data pointer, although
it only uses it to obtain the associated blkg. This unnecessarily ties
statistics formatting to a policy.

Introduce blkg_print_rwstat() to print rwstat samples directly from a
blkg, allowing cgroup v1 I/O statistics to be reported independently of
the throttle policy.

Keep __blkg_prfill_rwstat() as a wrapper for existing policy users,
including BFQ. The output format and total calculation remain unchanged.

Signed-off-by: Zhe Liu <liuzhe1@kylinos.cn>
Cgroup v1 I/O statistics are currently stored in throtl_grp, making
their allocation and lifetime dependent on the throttle policy. With
lazy throttle initialization, these counters may not be available until
an I/O limit is configured.

Move the byte and I/O counters into an optional blkg-owned statistics
object, independent of throttle activation. Allocate the counters for
v1 and root blkgs to support late controller binding, while avoiding
unnecessary allocations for non-root v2 blkgs.

Move cgroup v1 statistics reporting, reset and offline propagation into
the blkcg core. Add recursive aggregation for the optional statistics
objects and preserve accumulated statistics when child blkgs are
destroyed. Keep the existing userspace interfaces unchanged.

Keep the accounting call site in blk_should_throtl(), routed through
the new blkcg_account_v1_bio(). Moving accounting before the throttle
activation check is handled in a separate patch.

Signed-off-by: Zhe Liu <liuzhe1@kylinos.cn>
Commit a3166c5 ("blk-throttle: delay initialization until
configuration") made throttle policy activation conditional on
configuring a limit. However, blk_should_throtl() returns before
updating the v1 counters when the policy is inactive. A cgroup v1
workload that only monitors I/O therefore gets no accounting until a
limit is configured on the device.

Now that the counters belong to the blkg, move their updates out of
blk_should_throtl() and account immediately before blk_throtl_bio() in
both submit_bio_noacct() and bio_submit_split_bioset(). This records I/O
even when the throttle policy has never been activated.

Keep BIO_CGROUP_ACCT byte deduplication and count each split-remainder
submission as an I/O. Throttle worker dispatch continues to use the
nocheck submission path, avoiding a second accounting update. The
inline hierarchy check skips v1 accounting on cgroup v2.

Fixes: a3166c5 ("blk-throttle: delay initialization until configuration")
Signed-off-by: Zhe Liu <liuzhe1@kylinos.cn>
@ghost

ghost commented Nov 10, 2026

Copy link
Copy Markdown
Author

Upstream branch: b3dfbde
series: https://patchwork.kernel.org/series/1207126/
version: 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants