CPU_CAP_HELP

Constant CPU_CAP_HELP 

Source
pub const CPU_CAP_HELP: &str = "Reserve exactly N host CPUs for the build or \
     no-perf-mode shell. Integer ≥ 1; must be ≤ the calling process's \
     sched_getaffinity cpuset size (the allowed CPU count, NOT the \
     host's total online CPUs — under a cgroup-restricted runner the \
     allowed set is typically smaller). When absent, 30% of the \
     allowed CPUs are reserved (minimum 1). The planner walks whole \
     LLCs in consolidation- and NUMA-aware order, filtered to the \
     allowed cpuset, partial-taking the last LLC so `plan.cpus.len() \
     == N` exactly. The flock set may cover more LLCs than strictly \
     required (flock coordination is per-LLC even when the last LLC \
     is only partially used for the CPU budget). Run `ktstr locks \
     --watch 1s` to observe NUMA placement live. Under --cpu-cap, \
     make's `-jN` parallelism matches the reserved CPU count and the \
     kernel build runs inside a cgroup v2 sandbox that pins gcc/ld \
     to the reserved CPUs + NUMA nodes; if the sandbox cannot be \
     installed (missing cgroup v2, missing cpuset controller, \
     permission denied), the build aborts rather than running \
     without enforcement. Mutually exclusive with \
     KTSTR_BYPASS_LLC_LOCKS=1. On `ktstr shell`, requires \
     --no-perf-mode (perf-mode already holds every LLC exclusively). \
     Also settable via KTSTR_CPU_CAP env var (CLI flag wins when both \
     are present).";
Expand description

Help text for the --cpu-cap N flag. Shared across ktstr kernel build, cargo ktstr kernel build, and ktstr shell so the operator-facing wording is identical regardless of entry point.

This flag is the resource-budget contract: the operator promises (and the framework enforces) that the build or no-perf-mode shell VM will stay within N CPUs’ worth of reservation and the NUMA nodes hosting them. Setting --cpu-cap N flips several internal defaults on this run: the LLC discovery walks whole LLCs in consolidation- and NUMA-aware order until the CPU budget is met; make’s -jN parallelism matches the plan’s CPU count so gcc can’t fan out beyond the budget; a cgroup v2 sandbox binds make + gcc’s cpuset to the plan’s CPUs and cpuset.mems to the plan’s NUMA nodes, so any degradation is fatal under the flag rather than a silent warning.