LIBPFM(3)
π LIBPFM β the MIPS 74k era
okay bestie, so this is a page out of the Linux Programmer's Manual, section 3, and it's all about the libpfm side of things. it's literally called LIBPFM(3) and it's the whole glow-up guide for one very specific little processor family. let's get into it π«Ά
β¨ NAME β¨
libpfm_mips_74k β support for MIPS 74k processors
like, that's it. that's the whole job. it's giving "i have one hyper-specific niche and i am OBSESSED with it" π
πΈ SYNOPSIS πΈ
#include <perfmon/pfmlib.h>
also, for the record:
- PMU name:
mips_74k - PMU desc:
MIPS 74k
π¦ DESCRIPTION π¦
so the library supports MIPS 74k processors, and it does it in big or little endian modes β either way, it's got you, no cap. π
π₯ ENCODINGS π₯
okay this is the part where you gotta pay attention, bestie, because it's lowkey the whole plot twist.
on this processor, what is measured by an event depends on the event code AND on the counter it is programmed on. not just one β both. the way that the meaning of the event code changes between odd and even indexed counters is honestly iconic in a chaotic way. π
for instance, event code 0x2 means 'PREDICTED_JR31' when it's programmed on even-indexed counters, and it means 'JR_31_MISPREDICTIONS' when it's on odd-indexed counters. same code, different personality depending on where it lands. main character behavior fr fr.
so to correctly measure an event, you need both the event encoding and a list of possible counters. both. don't skip one. π
now, when pfm_get_os_event_encoding() is used with PFM_OS_NONE to return the raw PMU encoding, the library hands you back two values:
- the event encoding, as per the architecture manual
- a bitmask of valid counters to program it on
for example, for 'JR_31_MISPREDICTIONS', the library returns codes[0] = 0x4a, codes[1]= 0xa (supported on counter 1, 3). slay. β¨
and just so you know: the encoding for a specific kernel interface may vary, and that whole situation is handled internally by the library. so you don't gotta stress about it β it's taken care of. π
π MODIFIERS π
the following modifiers are supported on MIPS 74k:
uβ Measure at user level. this corresponds toPFM_PLM3. it's a boolean modifier. βkβ Measure at kernel level. this corresponds toPFM_PLM0. boolean modifier. βeβ Measure at exception level. this corresponds toPFM_PLM2. boolean modifier. βsβ Measure at supervisor level. this corresponds toPFM_PLM1. boolean modifier. β
β οΈ okay real talk: it should be noted that those modifiers are available for encoding as raw mode with PFM_OS_NONE, but they may not all be present with specific kernel interfaces. so like, don't assume the whole set shows up everywhere β vibe check your kernel interface first. π
π AUTHORS π
Stephane Eranian <eranian@gmail.com>
and that's the whole page, bestie!! π the source/version is LIBPFM(3), and it's dated September, 2011 β a vintage queen, honestly. mwah. ππ
π¦ where this page comes from
- debian bookworm: libpfm4-dev 4.13.0-1 Β· MIT
- debian trixie: libpfm4-dev 4.13.0+git99-gc5587f9-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