Skip to main content

Raw

Struct Raw 

Source
#[non_exhaustive]
pub struct Raw { pub config: u64, pub config1: u64, pub config2: u64, }
Expand description

A raw perf counter for the current CPU.

Most CPUs have additional counters beyond those provided by the kernel. Raw events allow you to access those events. Note that the values needed to configure raw events a liable to change between CPU vendors and even different hardware revisions of the same platform.

The event can be chosen by setting the config field. Most events will only need that, but others may require setting the config1 or config2 fields as well.

To find the config values required for counters consult your CPU manual.

  • For Intel CPUs, see the Intel Software Developer Manual, volume 3B.
  • For AMD, see the AMD BIOS and Kernel Developer Guide.
  • Other vendors should have equivalent documentation.

Example:

use perf_event::events::Raw;
use perf_event::{Builder, Group};

// Raw config values for an ARMv8 PMU.
let INSNS_RETIRED: Raw = Raw::new(0x08);
let CPU_CYCLES: Raw = Raw::new(0x11);

let mut group = Group::new()?;
let raw_insns_retired = group.add(&Builder::new(INSNS_RETIRED).include_kernel())?;
let raw_cpu_cycles = group.add(&Builder::new(CPU_CYCLES).include_kernel())?;

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§config: u64

Raw config of the event

§config1: u64

Raw config1 of the event

§config2: u64

Raw config2 of the event

Implementations§

Source§

impl Raw

Source

pub const fn new(config: u64) -> Self

Create a new raw event value with the given config value.

This sets all other config fields to zero. For most events this should be sufficient but in other cases methods are provided to set those fields as well.

Source

pub const fn config(self, config: u64) -> Self

Set config

Source

pub const fn config1(self, config1: u64) -> Self

Set config1

Source

pub const fn config2(self, config2: u64) -> Self

Set config2

Trait Implementations§

Source§

impl Clone for Raw

Source§

fn clone(&self) -> Raw

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Raw

Source§

impl Debug for Raw

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Raw

Source§

impl Event for Raw

Source§

fn update_attrs(self, attr: &mut perf_event_attr)

Update the perf_event_attr struct so that it will record the requested event. Read more
Source§

fn update_attrs_with_data( self, attr: &mut perf_event_attr, ) -> Option<Arc<dyn EventData>>

Update the perf_event_attr struct so that it will record the requested event. Read more
Source§

impl PartialEq for Raw

Source§

fn eq(&self, other: &Raw) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Raw

Auto Trait Implementations§

§

impl Freeze for Raw

§

impl RefUnwindSafe for Raw

§

impl Send for Raw

§

impl Sync for Raw

§

impl Unpin for Raw

§

impl UnsafeUnpin for Raw

§

impl UnwindSafe for Raw

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> EventData for T
where T: Send + Sync,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.