Skip to content

iocost: addio.cost.boost cgroup interface - #2147

Closed
ecjtusbs wants to merge 1 commit into
deepin-community:linux-6.6.yfrom
ecjtusbs:linux-6.6.y
Closed

ecjtusbs wants to merge 1 commit into
deepin-community:linux-6.6.yfrom
ecjtusbs:linux-6.6.y

Conversation

@ecjtusbs

@ecjtusbs ecjtusbs commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Introduce a new per-cgroup file "io.cost.boost" that allows temporarily boosting an io.cost cgroup. Writing a duration in microseconds to the file enables boost mode for that cgroup. When a cgroup is boosted, iocost skips surplus evaluation for it and restores its inuse weight to active, ensuring the boosted cgroup keeps its full IO share during the boost period.

Summary by Sourcery

Add temporary per-cgroup IO cost boosting to preserve full IO shares for latency-sensitive workloads.

New Features:

  • Add a per-cgroup io.cost.boost interface for enabling temporary IO share boosting with a duration in microseconds.
  • Expose the remaining boost duration and support disabling boosts by writing zero, with a maximum duration limit of one minute.

Enhancements:

  • Preserve a boosted cgroup's active IO weight by skipping surplus evaluation during the boost period.

Introduce a new per-cgroup file "cost.boost" that allows temporarily
boosting an io.cost cgroup.  Writing a duration in microseconds to the
file enables boost mode for that cgroup.  When a cgroup is boosted,
iocost skips surplus evaluation for it and restores its inuse weight
to active, ensuring the boosted cgroup keeps its full IO share during
the boost period.
@sourcery-ai

sourcery-ai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Reviewer's Guide

Introduces the non-root io.cost.boost cgroup interface, backed by a bounded expiration deadline, and updates timer processing to temporarily preserve a boosted cgroup's full active IO share by bypassing surplus evaluation and restoring its in-use weight.

Sequence diagram for the io.cost.boost cgroup interface

sequenceDiagram
    actor Admin
    participant Cgroup as io.cost.boost
    participant Iocost as ioc_cgrp
    participant Timer as ioc_timer_fn

    Admin->>Cgroup: write duration_us
    Cgroup->>Iocost: kstrtou64(strim(buf), 10)
    alt duration_us <= MAX_BOOST_US
        Iocost->>Iocost: WRITE_ONCE(boost_deadline)
        Admin->>Cgroup: read remaining duration
        Cgroup->>Iocost: ktime_get_ns()
        Iocost-->>Cgroup: remaining_us
    else duration_us > MAX_BOOST_US
        Cgroup-->>Admin: -EINVAL
    end

    Timer->>Iocost: READ_ONCE(boost_deadline)
    alt boost_deadline > now.now_ns
        Iocost->>Iocost: __propagate_weights(active, active, true, &now)
        Iocost-->>Timer: skip surplus evaluation
    else boost expired
        Timer->>Timer: evaluate surplus
    end
Loading

File-Level Changes

Change Details Files
Add a per-cgroup boost deadline and expose it through a new io.cost control file.
  • Store the boost expiration timestamp in cgroup policy data.
  • Add a non-root cost.boost interface that reports remaining microseconds and accepts a duration in microseconds.
  • Cap requested boosts at 60 seconds and support zero to cancel an active boost.
block/blk-iocost.c
Modify iocost timer accounting to preserve full active weight while a cgroup is boosted.
  • Skip surplus evaluation for cgroups whose boost deadline has not expired.
  • Restore in-use weight to active weight when applicable and avoid propagation for cgroups with absolute virtual debt.
block/blk-iocost.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign avenger-285714 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ecjtusbs ecjtusbs closed this Sep 14, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="block/blk-iocost.c" line_range="2319-2331" />
<code_context>
 		usage_us = iocg->usage_delta_us;
 		usage_us_sum += usage_us;

+		/* skip surplus evaluation if this cgroup is boosted */
+		{
+			struct blkcg_gq *blkg = iocg_to_blkg(iocg);
+			struct ioc_cgrp *iocc = blkcg_to_iocc(blkg->blkcg);
+
+			if (READ_ONCE(iocc->boost_deadline) > now.now_ns) {
+				if (iocg->inuse != iocg->active &&
+				    !iocg->abs_vdebt) {
+					__propagate_weights(iocg, iocg->active,
+							    iocg->active, true,
+							    &now);
+				}
+				continue;
+			}
+		}
</code_context>
<issue_to_address>
**issue (broader_impact):** Boosting a non-leaf cgroup does not preserve the cgroup's full hierarchical IO share: the timer skips surplus evaluation only for the boosted cgroup's own `iocg`, while its active child `iocg`s continue donating weight. When the parent is restored, `__propagate_weights()` derives an internal node's in-use weight from its children's reduced weights, so the boosted parent remains throttled.

**Triggers:** When the boosted cgroup has active child cgroups that have donated surplus weight.

**Suggested fix:** Propagate the boost to the active descendants, or restore the entire boosted subtree's in-use weights rather than only evaluating the cgroup whose `boost_deadline` is set.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread block/blk-iocost.c
Comment on lines +2319 to +2331
/* skip surplus evaluation if this cgroup is boosted */
{
struct blkcg_gq *blkg = iocg_to_blkg(iocg);
struct ioc_cgrp *iocc = blkcg_to_iocc(blkg->blkcg);

if (READ_ONCE(iocc->boost_deadline) > now.now_ns) {
if (iocg->inuse != iocg->active &&
!iocg->abs_vdebt) {
__propagate_weights(iocg, iocg->active,
iocg->active, true,
&now);
}
continue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (broader_impact): Boosting a non-leaf cgroup does not preserve the cgroup's full hierarchical IO share: the timer skips surplus evaluation only for the boosted cgroup's own iocg, while its active child iocgs continue donating weight. When the parent is restored, __propagate_weights() derives an internal node's in-use weight from its children's reduced weights, so the boosted parent remains throttled.

Triggers: When the boosted cgroup has active child cgroups that have donated surplus weight.

Suggested fix: Propagate the boost to the active descendants, or restore the entire boosted subtree's in-use weights rather than only evaluating the cgroup whose boost_deadline is set.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants