resolve_affinity_for_cgroup

Function resolve_affinity_for_cgroup 

Source
pub fn resolve_affinity_for_cgroup(
    kind: &AffinityIntent,
    cpuset: Option<&BTreeSet<usize>>,
    topo: &TestTopology,
) -> Result<ResolvedAffinity>
Expand description

Resolve an AffinityIntent to a concrete ResolvedAffinity for workers in a cgroup with the given effective cpuset.

§Errors

Returns Err when the test author’s affinity intent cannot be satisfied against the cgroup’s effective cpuset. Per the project-wide no-silent-drops invariant, an unsatisfiable intent must surface as a returnable error rather than silently degrading to “no affinity applied” — silent degradation lets the workload run with the wrong placement while the test reports success (vacuously-passing assertions).

The unsatisfiable cases by variant:

Every error diagnostic names the offending intent and a remediation hint. Diagnostics for cpuset-narrowed pools (RandomSubset empty intersection, LlcAligned, SingleCpu, Exact disjoint-intersection, SmtSiblingPair) also render the cpuset that narrowed the pool. The intent-only errors — RandomSubset { count: 0 } and Exact(BTreeSet::new()) — omit the cpuset because the cpuset is irrelevant to the failure (the intent itself names zero CPUs). Remediation hints include switching to AffinityIntent::Inherit to deliberately inherit the cpuset, widening the cgroup’s cpuset, or picking CPUs inside the cpuset.