From 8a95390f1cab3ddda53f0a534188750ff2c16c34 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 16 Jan 2026 06:42:26 +0000 Subject: [PATCH] Default affinity mask to cores available rather than nil. Signed-off-by: Jason Volk --- src/core/utils/sys/compute.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/core/utils/sys/compute.rs b/src/core/utils/sys/compute.rs index 8bb4f704..68cfdf0e 100644 --- a/src/core/utils/sys/compute.rs +++ b/src/core/utils/sys/compute.rs @@ -65,7 +65,15 @@ where } /// Get the core affinity for this thread. -pub fn get_affinity() -> impl Iterator { from_mask(CORE_AFFINITY.get()) } +pub fn get_affinity() -> impl Iterator { + CORE_AFFINITY + .get() + .ne(&0) + .then_some(from_mask(CORE_AFFINITY.get())) + .or_else(|| Some(from_mask(*CORES_AVAILABLE))) + .into_iter() + .flatten() +} /// List the cores sharing SMT-tier resources pub fn smt_siblings() -> impl Iterator {