[PR #3893] [Engine] read the available RAM on sysvinit + elogind hosts (a cgroup without the memory controller has no limit) #4818

Open
opened 2026-11-07 15:39:15 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3893
Author: @crhy
Created: 10/23/2026
Status: 🔄 Open

Base: main ← Head: fix-elogind-cgroup


📝 Commits (1)

  • b1a1bbb engine: a cgroup v2 group without the memory controller has no limit at that level (elogind sessions on sysvinit hosts read "RAM unknown")

📊 Changes

2 files changed (+30 additions, -3 deletions)

View changed files

📝 src/core/expert_source.cpp (+15 -3)
📝 tests/core/file_expert_source_test.cpp (+15 -0)

📄 Description

Problem and result

On a Linux host that runs sysvinit with elogind instead of systemd (Devuan, and Spaced Linux, which is built on it), the engine cannot read the available RAM: detail::host_available_memory() returns false.

elogind puts the login session in its own cgroup v2 group (0::/1 here), but the root's cgroup.subtree_control is empty, so the memory controller is never enabled below the root. The session group therefore has no memory.max and an empty cgroup.controllers. The probe treats every non-root group without a readable memory.max as an unreadable limit and gives up.

After this change, a group whose cgroup.controllers is readable and does not list memory adds no limit at that level. Its ancestors are still checked, so a limit set higher up still applies. A group that does list the memory controller but has no readable memory.max still fails, as before.

none (a focused fix; I found no existing issue or PR about elogind or sysvinit cgroups)

Approach

The only change is in the cgroup v2 walk of host_available_memory(): the existing root-group exception is extended to non-root groups whose cgroup.controllers shows the memory controller is off. That file is the kernel's own statement of which controllers the group has, so the check does not guess from missing files. Nothing changes for systemd hosts, containers or cgroup v1: those groups either list memory or are not affected by this branch.

The host's layout, for reference:

$ cat /proc/self/cgroup
0::/1
$ cat /sys/fs/cgroup/cgroup.subtree_control
(empty)
$ cat /sys/fs/cgroup/1/cgroup.controllers
(empty)
$ ls /sys/fs/cgroup/1/memory.max
ls: cannot access '/sys/fs/cgroup/1/memory.max': No such file or directory

Validation

Environment: Spaced Linux (Devuan based, sysvinit + elogind), kernel 7.2.11, RTX 4070 Ti SUPER (sm_89), CUDA build.

Passed:

  • host_available_memory() on this host, compiled verbatim from expert_source.cpp into a small standalone probe: at origin/main (7ddc17a3) it returns false; with this change it returns true, available 19.4 GiB, no cgroup limit (/proc/meminfo MemAvailable at the time: 19.5 GiB).
  • test_host_memory() with the three new cases (a group with the memory controller but no memory.max still fails; a group without the controller reads MemAvailable alone; the same group under a 48 GiB parent limit gets the parent's limit). They fail at origin/main (v2 group without the memory controller: MemAvailable alone) and pass with the change.
  • CUDA build of file_expert_source_test on this branch (-DSTRATA_ENABLE_CUDA=ON -DSTRATA_BUILD_TESTS=ON -DCMAKE_CUDA_ARCHITECTURES=89, CUDA 13.4, GCC 16.2): builds with no warnings from expert_source.cpp; build-cuda/file_expert_source_test ends with file_expert_source_test: PASS.

Failed:
none observed

Not run:

  • HIP and SYCL builds: no AMD or Intel card or toolchain here. The change is plain C++ in a Linux-only block, with no backend code.
  • An end-to-end model start on upstream main: an earlier form of this fix has run as a local patch since 2026-10-17 on engine 0.1.38 built from source, serving the Coder IQ1_M model daily; the current main with this change has not served a model here.

Limits

Only cgroup v2 is affected. A host that limits memory some other way (for example ulimit -v) is still not seen, as before.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/3893 **Author:** [@crhy](https://github.com/crhy) **Created:** 10/23/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix-elogind-cgroup` --- ### 📝 Commits (1) - [`b1a1bbb`](https://github.com/Niko1221/Strata/commit/b1a1bbbf65d8033d9c6339ba0500688bd88fabab) engine: a cgroup v2 group without the memory controller has no limit at that level (elogind sessions on sysvinit hosts read "RAM unknown") ### 📊 Changes **2 files changed** (+30 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/core/expert_source.cpp` (+15 -3) 📝 `tests/core/file_expert_source_test.cpp` (+15 -0) </details> ### 📄 Description ## Problem and result On a Linux host that runs sysvinit with elogind instead of systemd (Devuan, and Spaced Linux, which is built on it), the engine cannot read the available RAM: `detail::host_available_memory()` returns false. elogind puts the login session in its own cgroup v2 group (`0::/1` here), but the root's `cgroup.subtree_control` is empty, so the memory controller is never enabled below the root. The session group therefore has no `memory.max` and an empty `cgroup.controllers`. The probe treats every non-root group without a readable `memory.max` as an unreadable limit and gives up. After this change, a group whose `cgroup.controllers` is readable and does not list `memory` adds no limit at that level. Its ancestors are still checked, so a limit set higher up still applies. A group that does list the memory controller but has no readable `memory.max` still fails, as before. ## Related discussion none (a focused fix; I found no existing issue or PR about elogind or sysvinit cgroups) ## Approach The only change is in the cgroup v2 walk of `host_available_memory()`: the existing root-group exception is extended to non-root groups whose `cgroup.controllers` shows the memory controller is off. That file is the kernel's own statement of which controllers the group has, so the check does not guess from missing files. Nothing changes for systemd hosts, containers or cgroup v1: those groups either list `memory` or are not affected by this branch. The host's layout, for reference: ```text $ cat /proc/self/cgroup 0::/1 $ cat /sys/fs/cgroup/cgroup.subtree_control (empty) $ cat /sys/fs/cgroup/1/cgroup.controllers (empty) $ ls /sys/fs/cgroup/1/memory.max ls: cannot access '/sys/fs/cgroup/1/memory.max': No such file or directory ``` ## Validation Environment: Spaced Linux (Devuan based, sysvinit + elogind), kernel 7.2.11, RTX 4070 Ti SUPER (sm_89), CUDA build. **Passed:** - `host_available_memory()` on this host, compiled verbatim from `expert_source.cpp` into a small standalone probe: at `origin/main` (7ddc17a3) it returns `false`; with this change it returns `true`, available 19.4 GiB, no cgroup limit (`/proc/meminfo` MemAvailable at the time: 19.5 GiB). - `test_host_memory()` with the three new cases (a group with the memory controller but no `memory.max` still fails; a group without the controller reads MemAvailable alone; the same group under a 48 GiB parent limit gets the parent's limit). They fail at `origin/main` (`v2 group without the memory controller: MemAvailable alone`) and pass with the change. - CUDA build of `file_expert_source_test` on this branch (`-DSTRATA_ENABLE_CUDA=ON -DSTRATA_BUILD_TESTS=ON -DCMAKE_CUDA_ARCHITECTURES=89`, CUDA 13.4, GCC 16.2): builds with no warnings from `expert_source.cpp`; `build-cuda/file_expert_source_test` ends with `file_expert_source_test: PASS`. **Failed:** none observed **Not run:** - HIP and SYCL builds: no AMD or Intel card or toolchain here. The change is plain C++ in a Linux-only block, with no backend code. - An end-to-end model start on upstream `main`: an earlier form of this fix has run as a local patch since 2026-10-17 on engine 0.1.38 built from source, serving the Coder IQ1_M model daily; the current `main` with this change has not served a model here. ## Limits Only cgroup v2 is affected. A host that limits memory some other way (for example `ulimit -v`) is still not seen, as before. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4818
No description provided.