pub enum PerfEventType {
    Hardware(HardwareEventIdPmuTypeId),
    Software(SoftwareCounterType),
    Tracepoint(u64),
    HwCache(HardwareCacheIdHardwareCacheOpHardwareCacheOpResultPmuTypeId),
    Breakpoint(HwBreakpointTypeHwBreakpointAddrHwBreakpointLen),
    DynamicPmu(u32u64u64u64),
}
Expand description

The type of perf event

Variants§

§

Hardware(HardwareEventIdPmuTypeId)

A hardware perf event. (PERF_TYPE_HARDWARE)

§

Software(SoftwareCounterType)

A software perf event. (PERF_TYPE_SOFTWARE)

Special “software” events provided by the kernel, even if the hardware does not support performance events. These events measure various physical and sw events of the kernel (and allow the profiling of them as well).

§

Tracepoint(u64)

A tracepoint perf event. (PERF_TYPE_TRACEPOINT)

§

HwCache(HardwareCacheIdHardwareCacheOpHardwareCacheOpResultPmuTypeId)

A hardware cache perf event. (PERF_TYPE_HW_CACHE)

Selects a certain combination of CacheId, CacheOp, CacheOpResult, PMU type ID.

{ L1-D, L1-I, LLC, ITLB, DTLB, BPU, NODE } x
{ read, write, prefetch } x
{ accesses, misses }
§

Breakpoint(HwBreakpointTypeHwBreakpointAddrHwBreakpointLen)

A hardware breakpoint perf event. (PERF_TYPE_BREAKPOINT)

Breakpoints can be read/write accesses to an address as well as execution of an instruction address.

§

DynamicPmu(u32u64u64u64)

Dynamic PMU

(pmu, config, config1, config2)

Acceptable values for each of config, config1 and config2 parameters are defined by corresponding entries in /sys/bus/event_source/devices/<pmu>/format/*.

From the perf_event_open man page:

Since Linux 2.6.38, perf_event_open() can support multiple PMUs. To enable this, a value exported by the kernel can be used in the type field to indicate which PMU to use. The value to use can be found in the sysfs filesystem: there is a subdirectory per PMU instance under /sys/bus/event_source/devices. In each subdirectory there is a type file whose content is an integer that can be used in the type field. For instance, /sys/bus/event_source/devices/cpu/type contains the value for the core CPU PMU, which is usually 4.

(I don’t fully understand this - the value 4 also means PERF_TYPE_RAW. Maybe the type Raw is just one of those dynamic PMUs, usually “core”?)

Among the “dynamic PMU” values, there are two special values for kprobes and uprobes:

kprobe and uprobe (since Linux 4.17) These two dynamic PMUs create a kprobe/uprobe and attach it to the file descriptor generated by perf_event_open. The kprobe/uprobe will be destroyed on the destruction of the file descriptor. See fields kprobe_func, uprobe_path, kprobe_addr, and probe_offset for more details.

union {
    __u64 kprobe_func; /* for perf_kprobe */
    __u64 uprobe_path; /* for perf_uprobe */
    __u64 config1; /* extension of config */
};

union {
    __u64 kprobe_addr; /* when kprobe_func == NULL */
    __u64 probe_offset; /* for perf_[k,u]probe */
    __u64 config2; /* extension of config1 */
};

Implementations§

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.