From 197c84fb920ca8bd5177d6027b86c7a4ae037727 Mon Sep 17 00:00:00 2001 From: bpetit Date: Fri, 6 Oct 2023 17:02:20 +0200 Subject: [PATCH] chore: loop to get informations about cores and sockets --- src/sensors/msr_rapl.rs | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/sensors/msr_rapl.rs b/src/sensors/msr_rapl.rs index c70c864e..6d2872a4 100644 --- a/src/sensors/msr_rapl.rs +++ b/src/sensors/msr_rapl.rs @@ -395,18 +395,32 @@ impl Sensor for MsrRAPLSensor { warn!("Couldn't get cpuinfo"); } } - for i in 0..5 { - match cpuid.get_extended_topology_info() { - Some(info) => { - warn!("Got CPU topo info {:?}", info); - for t in info { - if t.level_type() == TopologyType::Core { - logical_cpus_from_cpuid = t.processors() + for i in 0..logical_cpus.len() { + match core_affinity::get_core_ids() { + Some(core_ids) => { + for c in core_ids { + if c.id == i as usize { + core_affinity::set_for_current(c); + warn!("Set core_affinity to {}", c.id); + match cpuid.get_extended_topology_info() { + Some(info) => { + warn!("Got CPU topo info {:?}", info); + for t in info { + if t.level_type() == TopologyType::Core { + logical_cpus_from_cpuid = t.processors() + } + } + }, + None => { + warn!("Couldn't get cpu topo info"); + } + } + break; } - } + } }, None => { - warn!("Couldn't get cpu topo info"); + warn!("Could'nt get core ids from core_affinity."); } } }