Skip to main content

Module linux_cgroup

Module linux_cgroup 

Source
Expand description

Helpers that translate spec.run.limits into cgroup v2 controller-file payloads.

Doctrine — D1 (no ambient defaults):

  • spec.run.limits.cpuMax is the primary source for the cgroup cpu.max controller value applied to the host-subprocess backend.
  • CELLOS_CGROUP_CPU_MAX is an explicit operator override. It only applies when the spec did not set cpuMax. Setting the env var alone is not a default — operators opt in by exporting it.

These helpers are pure (no I/O, no std::env::var reads at the call sites that exercise them in unit tests) so the resolution + normalization rules can be tested directly without a real cgroup v2 hierarchy. The actual file write is performed by supervisor::linux_cgroup_write_optional_controller_files.

These helpers are platform-agnostic at the type level — they operate on strings — but only the Linux subprocess path consumes their output.

Enums§

CpuMaxApplyOutcome
Outcome of apply_cpu_max_to_leaf — useful for tests and structured logs.
CpuMaxSource
Which source produced the cpu.max payload.

Constants§

DEFAULT_CPU_PERIOD_MICROS
Default cgroup v2 CPU period when the spec omits periodMicros. Matches the schema description (Defaults to 100000 when omitted by the runtime.) and the kernel default for cpu.max.

Functions§

apply_cpu_max_to_leaf
Apply the resolved cpu.max payload to <leaf>/cpu.max, if any.
cpu_max_env_validation_error
Whether the env override produced an unusable value. Useful for the supervisor’s warn log when the spec is silent and the env value is malformed.
cpu_max_to_write
Resolve the cpu.max payload for the host-subprocess cgroup leaf.