pub struct PerfEvent { /* private fields */ }
Expand description
A program that can be attached at a perf event.
Minimum kernel version
The minimum kernel version required to use this feature is 4.9.
Examples
use std::convert::TryInto;
use aya::util::online_cpus;
use aya::programs::perf_event::{
perf_sw_ids::PERF_COUNT_SW_CPU_CLOCK, PerfEvent, PerfEventScope, PerfTypeId, SamplePolicy,
};
let prog: &mut PerfEvent = bpf.program_mut("observe_cpu_clock").unwrap().try_into()?;
prog.load()?;
for cpu in online_cpus()? {
prog.attach(
PerfTypeId::Software,
PERF_COUNT_SW_CPU_CLOCK as u64,
PerfEventScope::AllProcessesOneCpu { cpu },
SamplePolicy::Period(1000000),
)?;
}
Implementations
sourceimpl PerfEvent
impl PerfEvent
sourcepub fn load(&mut self) -> Result<(), ProgramError>
pub fn load(&mut self) -> Result<(), ProgramError>
Loads the program inside the kernel.
See also Program::load
.
sourcepub fn attach(
&mut self,
perf_type: PerfTypeId,
config: u64,
scope: PerfEventScope,
sample_policy: SamplePolicy
) -> Result<LinkRef, ProgramError>
pub fn attach(
&mut self,
perf_type: PerfTypeId,
config: u64,
scope: PerfEventScope,
sample_policy: SamplePolicy
) -> Result<LinkRef, ProgramError>
Attaches to the given perf event.
The possible values and encoding of the config
argument depends on the
perf_type
. See perf_sw_ids
, perf_hw_id
, perf_hw_cache_id
,
perf_hw_cache_op_id
and perf_hw_cache_op_result_id
.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for PerfEvent
impl !Send for PerfEvent
impl !Sync for PerfEvent
impl Unpin for PerfEvent
impl !UnwindSafe for PerfEvent
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more