Skip to content

Commit 84b5e9b

Browse files
Copilotsimongdavies
andcommitted
Add metric for tracking erroneous vCPU kicks
Co-authored-by: simongdavies <1397489+simongdavies@users.noreply.github.com>
1 parent c3bc3fe commit 84b5e9b

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/hyperlight_host/src/hypervisor/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::hypervisor::regs::{
2323
CommonFpu, CommonRegisters, CommonSegmentRegister, CommonSpecialRegisters,
2424
};
2525
use crate::mem::memory_region::{MemoryRegion, MemoryRegionFlags};
26-
use crate::metrics::METRIC_GUEST_CANCELLATION;
26+
use crate::metrics::{METRIC_ERRONEOUS_VCPU_KICKS, METRIC_GUEST_CANCELLATION};
2727
#[cfg(feature = "mem_profile")]
2828
use crate::sandbox::trace::MemTraceInfo;
2929
use crate::{HyperlightError, Result, log_then_return};
@@ -471,6 +471,8 @@ impl VirtualCPU {
471471
// If cancellation was not requested for this specific guest function call,
472472
// the vcpu was interrupted by a stale cancellation from a previous call
473473
if !cancel_requested && !debug_interrupted {
474+
// Track that an erroneous vCPU kick occurred
475+
metrics::counter!(METRIC_ERRONEOUS_VCPU_KICKS).increment(1);
474476
// treat this the same as a HyperlightExit::Retry, the cancel was not meant for this call
475477
continue;
476478
}

src/hyperlight_host/src/metrics/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ pub(crate) static METRIC_GUEST_ERROR_LABEL_CODE: &str = "code";
2121
// Counter metric that counts the number of times a guest function was called due to timing out
2222
pub(crate) static METRIC_GUEST_CANCELLATION: &str = "guest_cancellations_total";
2323

24+
// Counter metric that counts the number of times a vCPU was erroneously kicked by a stale signal
25+
// This happens when a signal from a previous guest call arrives late and interrupts a new call
26+
pub(crate) static METRIC_ERRONEOUS_VCPU_KICKS: &str = "erroneous_vcpu_kicks_total";
27+
2428
// Histogram metric that measures the duration of guest function calls
2529
#[cfg(feature = "function_call_metrics")]
2630
pub(crate) static METRIC_GUEST_FUNC_DURATION: &str = "guest_call_duration_seconds";

0 commit comments

Comments
 (0)