LIBPFM(3)

πŸ“¦
version 4.14.1 Β· 2 versions
, in arch rolling, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– LIBPFM πŸ’–

ok so bestie, welcome to libpfm, aka the Linux Programmer's Manual page for the perfmon library. sit down, grab a strawberry, we're gonna talk about the very first thing you have to do. πŸ“βœ¨


🌸 NAME 🌸

pfm_initialize β€” initialize library


✨ SYNOPSIS ✨

#include <perfmon/pfmlib.h>

int pfm_initialize(void);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so this is the function. like, the one you literally have to call first. if you don't, the library just... does not operate. it's giving "you can't sit with us" energy. πŸ’…

so what does it actually do? it goes poking around in the underlying hardware, looking for valid PMU event tables to activate. and here's the slay part: multiple distinct PMU tables can be activated at the same time. not just one. several. at once. obsessed. πŸ‘‘

real talk though: this function must be called only once. if you call it more than once, it does not run the initialization multiple times β€” it just returns the same value as the first call. so don't be out here thinking you're re-initializing anything. you're not.

also, and this is important, this is not a reentrant function. only one thread at a time can call it. one. single. thread. no tag-teaming, no group chat, no parallel chaos. πŸ™ˆ


πŸ”₯ RETURN πŸ”₯

it tells you whether it worked or not β€” i.e. whether at least one PMU was activated.

  • a return value of PFMLIB_SUCCESS = success, we ate ✨
  • anything else = that value is an error code

πŸ’€ ERRORS πŸ’€

  • PFMLIB_ERR_NOTSUPP β€” no PMU was activated. that's it, that's the whole vibe. nothing got turned on. 😭

πŸ‘‘ AUTHOR πŸ‘‘

Stephane Eranian <eranian@gmail.com>


and that's the whole page, bestie!! go call pfm_initialize once, from one thread, and then go live your main character life. iykyk 🫢

πŸ’– this was LIBPFM(3), from the Linux Programmer's Manual, dated September, 2009 β€” mwah, bye!! πŸ’–