Function pmu_x86::handle_sample
source · pub fn handle_sample(
stack_frame: &InterruptStackFrame
) -> Result<bool, &'static str>
Expand description
This function is designed to be invoked from an interrupt handler when a sampling interrupt has (or may have) occurred.
It takes a sample by logging the the instruction pointer and task ID at the point at which the sampling interrupt occurred. The counter is then either reset to its starting value (if there are more samples that need to be taken) or disabled entirely if the final sample has been taken.
Argument
stack_frame
: the stack frame that was pushed onto the stack automatically by the CPU and passed into the interrupt/exception handler. This is used to determine during which instruction the sampling interrupt occurred.
Return
- Returns
Ok(true)
if a PMU sample occurred and was handled. - Returns
Ok(false)
if PMU isn’t supported, or if PMU wasn’t yet initialized, or if there was not a pending sampling interrupt. - Returns an
Err
if PMU is supported and initialized and a sample was pending, but an error occurred while logging the sample.