Skip to content

cgroup: Add cgroup_enable option - #6524

Merged
pelwell merged 1 commit into
raspberrypi:rpi-6.12.yfrom
pelwell:memcg
Dec 9, 2024
Merged

pelwell merged 1 commit into
raspberrypi:rpi-6.12.yfrom
pelwell:memcg

Conversation

@pelwell

@pelwell pelwell commented Dec 9, 2024

Copy link
Copy Markdown
Contributor

The upstream addition of the kernel parameter cgroup_disable makes it possible to configure cgroups at boot time. In theory, re-enabling a disabled cgroup is simply a case of removing the relevant cgroup_disable setting, but this is difficult if the setting comes from Device Tree.

Re-introduce cgroup_enable as a way around the problem.

The upstream addition of the kernel parameter cgroup_disable makes it
possible to configure cgroups at boot time. In theory, re-enabling a
disabled cgroup is simply a case of removing the relevant cgroup_disable
setting, but this is difficult if the setting comes from Device Tree.

Re-introduce cgroup_enable as a way around the problem.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
@pelwell

pelwell commented Dec 9, 2024

Copy link
Copy Markdown
Contributor Author

Thanks - I believe this is correct, but it may not be sufficient if legacy V1 memory cgroup support is needed.

@pelwell
pelwell merged commit 54bcf63 into raspberrypi:rpi-6.12.y Dec 9, 2024
@pelwell
pelwell deleted the memcg branch December 9, 2024 16:28
dkadioglu added a commit to dkadioglu/PKGBUILDs that referenced this pull request Dec 9, 2024
kelchm added a commit to kelchm/rpi-nixos that referenced this pull request Oct 18, 2026
The Pi 5 UPS hosts inherited `cgroup_disable=memory` from their DTBs,
leaving the metrics profile's systemd memory ceilings configured but
unenforced. Add `cgroup_enable=memory` only to `ups-compute-rack` and
`ups-office`, and document how to verify enforcement. This follows the
metrics rollout in #5.

The pinned Raspberry Pi generational boot builder writes NixOS
`boot.kernelParams` into `cmdline.txt`. On these hosts the firmware
appends that file after the DTB bootargs, so the enable takes effect
after the disable. This follows the [Raspberry Pi kernel maintainer's
explanation](raspberrypi/linux#6980) and the
[restored downstream
override](raspberrypi/linux#6524). No
`cgroup_memory=1` is added. The kernel, DTBs and package closure are
unchanged; the streamer already has an active memory controller and is
unchanged.

Validation:

- `nix flake check --accept-flake-config` passed for all three hosts.
Both UPS aarch64 toplevels built using the configured Linux builder.
- Independent Claude Opus review found no blockers. Its suggestion to
check all three metrics units' memory events is included in the live
checks below.
- README clarifies that the 32 MiB UPS-role ceiling applies to the NUT
exporter. The UPS daemon and monitor themselves remain outside these
metrics service ceilings.

Live rollout on 2026-10-18, explicitly authorized by the user:
compute-rack first, then office after backend confirmation. Both
rebooted successfully. On each host:

- `/proc/cmdline` has `cgroup_disable=memory` before
`cgroup_enable=memory`, and `/sys/fs/cgroup/cgroup.controllers` includes
`memory`.
- vmagent reports numeric `MemoryCurrent`, `MemoryHigh=67108864`, and
`MemoryMax=100663296`; its actual cgroup `memory.max` and
`vm_available_memory_bytes` are both `100663296` (96 MiB). Node-exporter
and NUT-exporter have actual cgroup maxima of 48 and 32 MiB.
- All three metrics services have zero restarts and zero `high`, `max`,
`oom` and `oom_kill` memory events during the initial post-boot checks.
This is a short verification, not a long-term load test.
- upsd/upsmon remained running through activation and returned after
reboot. The local monitor reconnected, and LAN reads on port 3493
succeeded before activation, after activation and after reboot.
Compute-rack remained `OL`; office remained `OL CHRG`. Only the local
monitor was persistently connected at the baseline checks.
- All three local scrape targets are healthy and successful remote
writes resumed. Queue pending, written and dropped counters were zero
after boot. Early local-DNS startup retries recovered automatically.

The dedicated home-lab thread independently confirmed both hosts'
backend limits changed from 974 MiB to 96 MiB, all three jobs healthy,
pressure present, NUT online and one missed scrape per host across
reboot. Compute-rack's first 96 MiB sample arrived at 16:31:17 UTC;
office's at 16:33:17 UTC. `PiUpsDataStale` remained empty, with no
queued or dropped data. All three enrolled Pis now report 96 MiB.
Home-lab PR #852's runbook was updated separately to record enforcement.

Built and running systems:

- Compute-rack:
`/nix/store/8wy5bks0frp10b40kfkcz8v6zskkq45m-nixos-system-ups-compute-rack-sd-card-25.11.20260313.3e20095`
- Office:
`/nix/store/zcli4qr373vnk966z7vam04dz6m66l4y-nixos-system-ups-office-sd-card-25.11.20260313.3e20095`

No token or home-lab backend change is needed. The dedicated home-lab
thread owns its runbook update. These two hosts currently run this
follow-up branch; redeploying unchanged main before this merges would
remove the override at the next reboot. Deployment was authorized
separately; this PR is left open for the user's merge decision.

<!-- attribution
model: gpt-6-astra
harness: codex
thread: mcp:a1f7fc77-fdba-472d-9f9f-23480f239e35
-->

Co-authored-by: gpt-6-astra <noreply@openai.com>
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