From f0c9a3932d0b02f1662b52ed567f4a9975e5d3a7 Mon Sep 17 00:00:00 2001 From: Daniel Hodges Date: Thu, 29 Aug 2024 05:21:56 -0700 Subject: [PATCH] scx_utils: Add cores helper to node topology Add a helper for getting the cores per node. Signed-off-by: Daniel Hodges --- rust/scx_utils/src/topology.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rust/scx_utils/src/topology.rs b/rust/scx_utils/src/topology.rs index 5d3113b73..048d38c13 100644 --- a/rust/scx_utils/src/topology.rs +++ b/rust/scx_utils/src/topology.rs @@ -265,6 +265,17 @@ impl Node { cpus } + /// Get the map of all Cores for this NUMA node. + pub fn cores(&self) -> BTreeMap { + let mut cores = BTreeMap::new(); + for (_, llc) in &self.llcs { + for (core_id, core) in llc.cores() { + cores.insert(*core_id, core.clone()); + } + } + cores + } + // Get the map of all GPUs for this NUMA node. pub fn gpus(&self) -> &BTreeMap { &self.gpus