Fix issues in the monitoring logic
This commit is contained in:
parent
f6494a82b2
commit
88775ea015
@ -8,7 +8,7 @@ pub fn main() {
|
|||||||
let nb_cores = core_per_package();
|
let nb_cores = core_per_package();
|
||||||
println!("Found {} cores", nb_cores);
|
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 old = sched_getaffinity(Pid::from_raw(0)).unwrap();
|
||||||
let mut core_set = Vec::new();
|
let mut core_set = Vec::new();
|
||||||
|
@ -49,7 +49,7 @@ unsafe fn monitor_xeon(addr: *const u8, cpu: u8, max_cbox: usize) -> Result<Vec<
|
|||||||
|
|
||||||
// Reset counters
|
// Reset counters
|
||||||
for i in 0..max_cbox {
|
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
|
// Enable counting
|
||||||
@ -72,14 +72,18 @@ unsafe fn monitor_xeon(addr: *const u8, cpu: u8, max_cbox: usize) -> Result<Vec<
|
|||||||
|
|
||||||
// Freeze counters
|
// Freeze counters
|
||||||
for i in 0..max_cbox {
|
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
|
// Read counters
|
||||||
let mut results = Vec::new();
|
let mut results = Vec::new();
|
||||||
for i in 0..max_cbox {
|
for i in 0..max_cbox {
|
||||||
let result = read_msr_on_cpu(performance_counters.msr_pmon_ctr0[i], cpu)?;
|
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)
|
Ok(results)
|
||||||
|
Loading…
Reference in New Issue
Block a user