LIBPFM(3)
π LIBPFM β the libpfm_perf_event_raw era π
okay bestie, sit down, hydrate, because we're talking about libpfm_perf_event_raw β the part of the Linux Programmer's Manual (LIBPFM(3)) that lets you do raw perf_events event syntax. no cap, it's giving raw hex realness. π¦
β¨ NAME β¨
libpfm_perf_event_raw β support for perf_events raw events syntax π
πΈ SYNOPSIS πΈ
#include <perfmon/pfmlib.h>
PMU name: perf_raw
PMU desc: Raw perf_events event syntax
π DESCRIPTION π
So the library has this pseudo PMU model whose whole job is letting you do raw encodings of PMU events for the Linux perf_events kernel interface. literally its entire personality. π
With this PMU, you can hand over the raw hexadecimal encoding of any hardware event for any PMU model. that raw encoding gets passed as-is straight to the kernel β no editing, no glow-up, no nothing. β¨
All events are encoded as PERF_TYPE_RAW. Which means β and this is the important part, bestie β perf_events generic events, like cycles or instructions, cannot be encoded by this PMU. not it. π
The syntax is stupidly simple: rX. that's it. X is the hexadecimal 64-bit value for the event. On some PMU models it may also include event filters. the hex number goes in without the 0x prefix, like r01c4. periodt. π
The library's standard perf_events attributes? fully supported by this PMU model. they get separated with colons, as is customary with the library. π
π₯ MODIFIERS π₯
Here's the whole menu, bestie β every modifier this PMU model supports:
uβ measure at user level, which includes privilege levels 1, 2, 3. this corresponds toPFM_PLM3. it's a boolean modifier. π«Άkβ measure at kernel level, which includes privilege level 0. corresponds toPFM_PLM0. also boolean. πhβ measure at the hypervisor level. corresponds toPFM_PLMH. boolean, yes. β¨mgβ measure guest execution only. boolean modifier. π¦mhβ measure host execution only. boolean modifier. πΈperiodβ specify the sampling period value. the value can be written in decimal or hexadecimal, and it's 64-bit wide. this option is mutually exclusive withfreq. the period is expressed in the unit of the event. there is no default value. πfreqβ specify the sampling frequency value. value can be decimal or hexadecimal, 64-bit wide. mutually exclusive withperiod. the value is expressed in Hertz β so for instance,freq=100means the event should be sampled 100 times per second on average. there is no default value. πexclβ the associated event is the only event measured on the PMU. this applies only to hardware events. this attribute requires admin privileges. default is off. πpreciseβ enables precise sampling mode. this option is only valid when sampling on events. it takes an integer argument, and here are the values it can have:1=enable precise sampling,2=enable precise sampling and eliminate skid,3=enable precise sampling, eliminate skid and bias. not all events necessarily support precise mode at all levels β that's dependent on the underlying PMU, so it's a vibe check you can't always pass. eliminating skid is a best effort feature; it may not work for all samples. this option is mutually exclusive withhw_smpl, and it implies using the hardware assist sampling mechanism. βhw_smplβ enables hardware assist sampling. boolean option, false by default. on some processors it's possible to have the hardware record samples in a buffer and then notify the kernel when it's full β iconic behaviour. such a feature may not be available for all events though. using a hardware buffer does not necessarily eliminate skid and bias; it usually lowers the overhead of interrupt-based sampling by amortizing the interrupt over multiple samples. this option is usually implicit with precise sampling events. π₯cpuβ this integer option is used with system-wide events, i.e. events attached to a CPU instead of a thread. the value designates the CPU to attach the event to. it is up to the caller of the library to use thecpufield in the library event encoding argument to create the event. the library makes no verification on the validity of the CPU number. default value for this field is-1. πpinnedβ this boolean option is used with system-wide events, i.e. events attached to a CPU instead of a thread. if set, the event is marked as pinned β meaning it needs to remain on the counters at all times, i.e. it cannot be multiplexed. there can only be as many pinned events as there are counters, but the library does not check for that β theperf_eventsubsystem does. the default value for this field isfalse, i.e. the event is not pinned. π
π AUTHORS π
Stephane Eranian <eranian@gmail.com>
and that's the whole page, bestie β February, 2014, LIBPFM(3), from the Linux Programmer's Manual. go forth and encode raw events responsibly, mwah πβ¨π
π¦ where this page comes from
- arch rolling: libpfm 4.14.1-1 Β· MIT
- centos-stream 10: libpfm-devel 4.14.1-1.el10 Β· MIT
- centos-stream 9: libpfm-devel 4.14.1-1.el9 Β· MIT
- centos-stream 9: libpfm-devel 4.14.1-1.el9 Β· MIT
- debian bookworm: libpfm4-dev 4.13.0-1 Β· MIT
- debian trixie: libpfm4-dev 4.13.0+git99-gc5587f9-1 Β· MIT
- fedora 43: libpfm-devel 4.13.0-16.fc43 Β· MIT
- fedora 43: libpfm-devel 4.13.0-16.fc43 Β· MIT
- fedora 43: libpfm-devel 4.13.0-20.fc43
- fedora 43: libpfm-devel 4.13.0-20.fc43
- fedora 43: libpfm-devel 4.14.1-2.fc43 Β· MIT
- fedora 43: libpfm-devel 4.14.1-2.fc43 Β· MIT
- fedora 44: libpfm-devel 4.13.0-19.fc44 Β· MIT
- fedora 44: libpfm-devel 4.13.0-19.fc44 Β· MIT
- fedora 44: libpfm-devel 4.13.0-20.fc44
- fedora 44: libpfm-devel 4.13.0-20.fc44
- fedora 44: libpfm-devel 4.14.1-2.fc44 Β· MIT
- fedora 44: libpfm-devel 4.14.1-2.fc44 Β· MIT
- nixos 26.05: libpfm 4.13.0
- nixos 26.05: papi 7.2.0
- nixpkgs unstable: libpfm 4.14.1
- nixpkgs unstable: papi 7.2.0
- opensuse-leap 16.0: libpfm-devel 4.13.0-160000.3.1 Β· MIT
- opensuse-leap 16.0: libpfm-devel 4.13.0-160000.3.1 Β· MIT
- opensuse-leap 16.0: libpfm-devel 4.13.0-160000.3.1 Β· MIT
- opensuse-leap 16.0: libpfm-devel 4.13.0-160000.3.1 Β· MIT
- ubuntu jammy: libpfm4-dev 4.11.1+git32-gd0b85fb-1 Β· BSD-like
- ubuntu jammy: libpfm4-dev 4.11.1+git32-gd0b85fb-1ubuntu0.1 Β· BSD-like
- ubuntu noble: libpfm4-dev 4.13.0+git32-g0d4ed0e-1 Β· MIT
- ubuntu noble: libpfm4-dev 4.13.0+git32-g0d4ed0e-1ubuntu0.1 Β· MIT
- ubuntu questing: libpfm4-dev 4.13.0+git99-gc5587f9-1
- ubuntu resolute: libpfm4-dev 4.13.0+git106-g3e4031b-1 Β· MIT
- ubuntu resolute: libpfm4-dev 4.13.0+git106-g3e4031b-1ubuntu0.1 Β· MIT
- ubuntu stonking: libpfm4-dev 4.13.0+git106-g3e4031b-1ubuntu1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms