@@ -21,7 +21,7 @@ use crate::HyperlightError::StackOverflow;
2121use crate :: error:: HyperlightError :: ExecutionCanceledByHost ;
2222use crate :: hypervisor:: regs:: { CommonFpu , CommonRegisters , CommonSpecialRegisters } ;
2323use crate :: mem:: memory_region:: { MemoryRegion , MemoryRegionFlags } ;
24- use crate :: metrics:: METRIC_GUEST_CANCELLATION ;
24+ use crate :: metrics:: { METRIC_ERRONEOUS_VCPU_KICKS , METRIC_GUEST_CANCELLATION } ;
2525#[ cfg( feature = "mem_profile" ) ]
2626use crate :: sandbox:: trace:: MemTraceInfo ;
2727use crate :: { HyperlightError , Result , log_then_return} ;
@@ -402,8 +402,12 @@ impl VirtualCPU {
402402 }
403403 Ok ( HyperlightExit :: Cancelled ( ) ) => {
404404 // If cancellation was not requested for this specific guest function call,
405- // the vcpu was interrupted by a stale cancellation from a previous call
405+ // the vcpu was interrupted by a stale cancellation. This can occur when:
406+ // - Linux: A signal from a previous call arrives late
407+ // - Windows: WHvCancelRunVirtualProcessor called right after vcpu exits but RUNNING_BIT is still true
406408 if !cancel_requested && !debug_interrupted {
409+ // Track that an erroneous vCPU kick occurred
410+ metrics:: counter!( METRIC_ERRONEOUS_VCPU_KICKS ) . increment ( 1 ) ;
407411 // treat this the same as a HyperlightExit::Retry, the cancel was not meant for this call
408412 continue ;
409413 }
0 commit comments