From 2e5af76dbbf60e3edd49031d47b9f3354daef59c Mon Sep 17 00:00:00 2001 From: David Venhoff Date: Wed, 3 Sep 2025 12:03:23 +0200 Subject: [PATCH] Track time in main and time disabled --- pt-dump-decoder/src/lib.rs | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/pt-dump-decoder/src/lib.rs b/pt-dump-decoder/src/lib.rs index 264ddba..8538073 100644 --- a/pt-dump-decoder/src/lib.rs +++ b/pt-dump-decoder/src/lib.rs @@ -11,11 +11,13 @@ pub struct AnalyzeData { pub packets: u64, pub cycles: u64, pub time: Duration, - pub time_outside_hypervisor: Duration, + pub time_main: Duration, + pub time_disabled: Duration, } -#[derive(Debug)] +#[derive(Debug, Eq, PartialEq)] enum Scope { + Disabled, Main, PreRun, PostRun, @@ -42,8 +44,11 @@ pub fn analyze_dump(path: impl AsRef) -> Result { segments.last_mut().unwrap().1 += cyc.value(); } - Ok(Packet::Vmcs(_)) => { - // last_packet_vmcs = true; + Ok(Packet::TipPge(_)) => { + segments.push((Scope::Main, 0)); + } + Ok(Packet::TipPgd(_)) => { + segments.push((Scope::Disabled, 0)); } Ok(Packet::Ptw(ptwrite)) => { if ptwrite.payload() == 42 { @@ -61,18 +66,27 @@ pub fn analyze_dump(path: impl AsRef) -> Result Duration { + let total_cycles = segments + .into_iter() + .filter(|(it, _)| *it == scope) + .map(|(_, cycles)| *cycles) + .sum::(); + let total_seconds = total_cycles as f64 / 2_700_000_000.0; + Duration::from_secs_f64(total_seconds) +}