Compare commits

...

2 Commits

Author SHA1 Message Date
Guillaume DIDIER
a7ea11181f Add missing CPU model 2024-06-24 17:40:03 +02:00
Guillaume DIDIER
88775ea015 Fix issues in the monitoring logic 2024-06-24 17:37:14 +02:00
3 changed files with 12 additions and 8 deletions

View File

@ -18,11 +18,11 @@ pub(crate) fn determine_cpu_class() -> Option<CpuClass> {
// Todo, sift through the documentation to add support for more CPUs
match (info.family_id(), info.model_id()) {
(0x06, 0x4f)
| (0x06, 0x2d)
(0x06, 0x2d)
| (0x06, 0x3e)
| (06, 0x3f)
| (0x06, 0x56) => {
| (0x06, 0x56)
| (0x06, 0x4f) => {
Some(IntelXeon)
}
(0x06, 0x55) => {
@ -62,7 +62,7 @@ pub(crate) fn get_performance_counters_xeon() -> Option<&'static XeonPerfCounter
0x2d /* 45 */ => Some(&SANDY_BRIDGE_XEON),
0x3e /* 62 */ => Some(&IVY_BRIDGE_XEON),
0x3f /* 63 */ => Some(&HASWELL_XEON),
0x56 /* 86 */ => Some(&BROADWELL_XEON),
0x4f | 0x56 /* 86 */ => Some(&BROADWELL_XEON),
_ => None,
}
}

View File

@ -8,7 +8,7 @@ pub fn main() {
let nb_cores = core_per_package();
println!("Found {} cores", nb_cores);
let target = vec![0x0123456789abcdefu64, 64];
let target = vec![0x0123456789abcdefu64; 64];
let old = sched_getaffinity(Pid::from_raw(0)).unwrap();
let mut core_set = Vec::new();

View File

@ -49,7 +49,7 @@ unsafe fn monitor_xeon(addr: *const u8, cpu: u8, max_cbox: usize) -> Result<Vec<
// Reset counters
for i in 0..max_cbox {
write_msr_on_cpu(performance_counters.msr_pmon_ctl0[i], cpu, performance_counters.val_box_reset)?;
write_msr_on_cpu(performance_counters.msr_pmon_box_ctl[i], cpu, performance_counters.val_box_reset)?;
}
// Enable counting
@ -72,14 +72,18 @@ unsafe fn monitor_xeon(addr: *const u8, cpu: u8, max_cbox: usize) -> Result<Vec<
// Freeze counters
for i in 0..max_cbox {
write_msr_on_cpu(performance_counters.msr_pmon_ctr0[i], cpu, performance_counters.val_box_freeze)?;
write_msr_on_cpu(performance_counters.msr_pmon_box_ctl[i], cpu, performance_counters.val_box_freeze)?;
}
// Read counters
let mut results = Vec::new();
for i in 0..max_cbox {
let result = read_msr_on_cpu(performance_counters.msr_pmon_ctr0[i], cpu)?;
results.push(result)
if (result - NUM_POKE as u64) < 0 {
results.push(0);
} else {
results.push(result - NUM_POKE as u64);
}
}
Ok(results)