← Back to Pull requests

fix(libcgroups): write each line of a unified value separately #3831

Closed
unknown closed this pull request without merging on Oct 31, 2026 01:28 UTC
View on GitHub
unknown unknown commented on Oct 18, 2026 04:45 UTC
Author

Description

Unified::apply_impl wrote each resources.unified value in a single write, and io.max takes one device entry per write, so a value with a line per device failed create with EINVAL (#3829).

The new common::write_cgroup_file_by_line writes each line, newline included, in its own write, the way runc's WriteFileByLine does, and Unified::apply_impl uses it for every value. A value with no newline is still a single write. write_cgroup_file_str is left alone, so its other callers still write their values whole.

This also adds the test I said I'd pick up on #3605: a port of runc's "per-device multiple iops via unified", which sets one io.max value for two devices and checks both lines.

Fixes #3829

Type of Change


<!-- Mark the appropriate option with an [x] -->
  • Bug fix (non-breaking change that fixes an issue)

  • New feature (non-breaking change that adds functionality)

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

  • Documentation update

  • Refactoring (no functional changes)

  • Performance improvement

  • Test updates

  • CI/CD related changes

  • Other (please describe):
  • Testing


    <!-- Describe the tests you ran and/or added to verify your changes -->
  • Added new unit tests

  • Added new integration tests

  • Ran existing test suite

  • Tested manually (please provide steps)
  • test_unified_io_max_multi_device takes the host's first two block devices, as the io tests take the first one, and is skipped when there are fewer or when io.max doesn't exist. As root on aarch64 with kernel 7.1 it fails on main at create, and passes with this change and with runc 1.5.2. The other four unified tests pass on all three. The two lines use different rates, so a rate written to the wrong device's line fails the test.

    test_write_by_line_writes_each_line_separately records each write call: one per line, and none for an empty value. Collapsing the helper back to a single write fails it. It only covers the helper, so putting write_cgroup_file_str back in Unified::apply_impl would leave it green; the contest test covers that.

    Manually, as root, a bundle with a two-line io.max fails create on main with Invalid argument (os error 22). With this change it creates and io.max holds both lines, as with runc. The cgroup_v2_io group still passes. The libcgroups tests pass with --all-features, and fmt and clippy report nothing new.

    Related Issues


    <!-- Link any related issues using the GitHub issue syntax: #issue-number
    If there is no open issue for this, please add details of the problem or open a new issue. -->
    Fixes #3829
    Refs #3605

    Additional Context


    <!-- Add any other context about the pull request here -->
    With the systemd driver, unified keys it doesn't map are never written at all (#3830). That fix will use this helper and comes separately.

    Diff: 367 lines (+275 / -92) across 4 files Reviewer: utam0k Review duration: 18522m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.43) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 367 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.353
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3831"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.7% (MEDIUM) · Higher = larger blast radius
    42.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.5% · Safe to merge
    18.5%