fix(libcgroups): write each line of a unified value separately #3831
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
utam0k
Description
Unified::apply_implwrote eachresources.unifiedvalue in a singlewrite, andio.maxtakes one device entry perwrite, so a value with a line per device failedcreatewithEINVAL(#3829).The new
common::write_cgroup_file_by_linewrites each line, newline included, in its ownwrite, the way runc'sWriteFileByLinedoes, andUnified::apply_impluses it for every value. A value with no newline is still a single write.write_cgroup_file_stris 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.maxvalue for two devices and checks both lines.Fixes #3829
Type of Change
<!-- Mark the appropriate option with an [x] -->
Testing
<!-- Describe the tests you ran and/or added to verify your changes -->
test_unified_io_max_multi_devicetakes the host's first two block devices, as the io tests take the first one, and is skipped when there are fewer or whenio.maxdoesn't exist. As root on aarch64 with kernel 7.1 it fails on main atcreate, 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_separatelyrecords eachwritecall: 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 puttingwrite_cgroup_file_strback inUnified::apply_implwould leave it green; the contest test covers that.Manually, as root, a bundle with a two-line
io.maxfailscreateon main withInvalid argument (os error 22). With this change it creates andio.maxholds both lines, as with runc. Thecgroup_v2_iogroup still passes. Thelibcgroupstests 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.