LIBPFM(3)
π LIBPFM π
okay so bestie, welcome to the libpfm page β that's the Linux Programmer's Manual corner of the universe, and today's main character is one very specific little function. pull up a chair, grab a strawberry π, we're doing this.
β¨ NAME β¨
pfm_get_pmu_info β get PMU information. that's it, that's the whole vibe. π
πΈ SYNOPSIS πΈ
#include <perfmon/pfmlib.h>
int pfm_get_pmu_info(pfm_pmu_t pmu, pfm_pmu_info_t *info);
π¦ DESCRIPTION π¦
so like. this function hands you back, inside info, all the tea about a PMU model β and you tell it which PMU you're asking about by passing its identifier in pmu. simple as that. π«Ά
the pfm_pmu_info structure is defined like this, and yes you need to see the whole thing:
typedef struct {
const char *name;
const char *desc;
pfm_pmu_t pmu;
pfm_pmu_type_t type;
int size;
int nevents;
int first_event;
int max_encoding;
int num_cntrs;
int num_fixed_cntrs;
struct {
int is_present:1;
int is_arch_default:1;
int is_core:1;
int is_uncore:1;
int reserved:28;
};
} pfm_pmu_info_t;
and now, field by field, because we do NOT skip the details in this house:
nameβ the symbolic name of the PMU. you can literally use this name as a prefix in an event string. it's a read-only string, so hands off, don't touch. πdescβ the description of the PMU. also read-only. also don't touch.pmuβ the unique PMU identification code. it's identical to the value you passed inpmu; it's only here for completeness, i.e. it's giving "I'm just here so I don't get fined." πtypeβ what kind of PMU this is. these are the types that exist:PFM_PMU_TYPE_UNKNOWNβ couldn't figure out the type of the PMU. mystery era. πPFM_PMU_TYPE_COREβ this field is set to one when the PMU is implemented by the processor core.PFM_PMU_TYPE_UNCOREβ this field is set to one when the PMU is implemented on the processor die but at the socket level, i.e., capturing events for all cores. socket-level behavior, very demure, very mindful.
neventsβ how many events are available for this PMU model, based on the host processor. only valid ifis_presentis set to1, okay? and no cap: event identifiers are not guaranteed contiguous. like, just becauseneventsequals100does not mean event identifiers run from0to99. so you have to use the iterator functionpfm_get_event_next()to go from one identifier to the next. do not freestyle this. πfirst_eventβ the opaque index of the first event for this PMU model. you can use that index with thepfm_get_event_info()orpfm_get_event_next()functions. if no event is available at all, this field contains-1. sad girl hours. πnum_cntrsβ how many generic counters the PMU supports. a counter is generic if it can count more than one event. when it's not possible to determine the number of generic counters, this field contains-1.num_fixed_cntrsβ how many fixed counters the PMU supports. a counter is fixed if it's hardwired to count only one event. when it's not possible to determine the number of generic counters, this field contains-1.sizeβ the size of the struct you passed. this field exists so the struct can grow in the future without breaking backward compatibility β iconic forward-thinking behavior honestly. you should set the value tosizeof(pfm_pmu_info_t). if instead you specify a value of0, the library assumes the struct you passed is identical to the first ABI version, whose size isPFM_PMU_INFO_ABI0. so if fields were added after that first ABI, the library will not set them for you. also, the library does check that bytes beyond what's implemented are zeroes. it's thorough like that. βmax_encodingβ how many event codes are returned bypfm_get_event_encoding().is_presentβ set to one if the PMU model has been detected on the host system. πis_dflβ set to one if the PMU is the default PMU for this architecture. otherwise this field is zero.
π₯ RETURN π₯
if everything goes right, the function returns PFM_SUCCESS and drops the PMU information into info. if not, it returns an error code. that's the whole deal. β¨
π ERRORS π
PFMLIB_ERR_NOINITβ the library has not been initialized properly. bestie. initialize it.PFMLIB_ERR_NOTSUPPβ the PMU model is not supported by the library. it's just not that girl, we move on.PFMLIB_ERR_INVALβ thepmuargument is invalid, orinfoisNULL, orsizeis not zero. fix ur inputs. π«
π SEE ALSO π
π AUTHOR π
Stephane Eranian <eranian@gmail.com> β absolute legend, wrote this whole thing, we stan. π
and that's the page!! this was the libpfm manual, dating all the way back to December, 2009 β vintage, retro, still slaying. take care of urself, go count some events, and remember: read the struct before you write the struct. 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