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:
AffinityIntent::RandomSubset:frompool empty after cpuset intersection, orcount == 0.AffinityIntent::LlcAligned: every LLC’s CPUs disjoint from the cpuset (no LLC has any CPU inside the cpuset).AffinityIntent::SingleCpu: cpuset is empty.AffinityIntent::Exact: requested CPU set is empty (Exact(BTreeSet::new())is intent-only unsatisfiable), or requested CPU set disjoint from the cpuset (intersection empty).AffinityIntent::SmtSiblingPair: no physical core with ≥2 SMT siblings inside the cpuset.AffinityIntent::CrossCgroup: topology exposes zero CPUs. The publiccrate::topology::TestTopologyconstructors all reject this at construction; reaching this case requires a private-field construction or a future API addition.
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.