LIBPFM(3)

πŸ“¦
version 4.14.1 Β· 2 versions
  • 4.14.1 Β· arch rolling, centos-stream 10, centos-stream 9, debian bookworm, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 4.11.1+git32-gd0b85fb Β· ubuntu jammy
, in arch rolling, centos-stream 10, centos-stream 9, debian bookworm, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸŽ€ LIBPFM(3) β€” Linux Programmer's Manual πŸŽ€

okay bestie, welcome to the libpfm_intel_ivb page, living inside the big LIBPFM(3) manual. it's giving "let me tell you about this one specific Intel chip" and honestly? iconic. let's go πŸ’…


✨ NAME ✨

libpfm_intel_ivb β€” support for Intel Ivy Bridge core PMU


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <perfmon/pfmlib.h>
PMU name: ivb
PMU desc: Intel Ivy Bridge
PMU name: ivb_ep
PMU desc: Intel Ivy Bridge EP

two PMUs, one vibe check, no notes πŸ’–


🌸 DESCRIPTION 🌸

so this library supports the Intel Ivy Bridge core PMU, periodt. but before you get too excited β€” it only covers each core's PMU, not the socket level PMU. like, per-core energy only, bestie. don't come for the socket stuff.

here's the tea on generic counters on Ivy Bridge: the number depends on Hyperthreading (HT) mode 😭

  • when HT is on β†’ only 4 generic counters are available
  • when HT is off β†’ a whole 8 generic counters are available

and if you need to know the max, pfm_get_pmu_info() returns it for you in num_cntrs. slay, function doing its job 🫢


πŸ’… MODIFIERS πŸ’…

these are the modifiers supported on Intel Ivy Bridge processors, and every single one matters, no skipping:

  • u β€” measure at user level, which includes privilege levels 1, 2, 3. this corresponds to PFM_PLM3. this is a boolean modifier.
  • k β€” measure at kernel level, which includes privilege level 0. this corresponds to PFM_PLM0. also a boolean modifier.
  • i β€” invert the meaning of the event ✨. the counter will now count cycles in which the event is not occurring. yes, it's a boolean modifier.
  • e β€” enable edge detection, i.e. count only when there's a state transition from no occurrence of the event to at least one occurrence. ⚠️ this modifier must be combined with a counter mask modifier (m) with a value greater or equal to one. it's a boolean modifier.
  • c β€” set the counter mask value. the mask acts like a threshold: the counter will count the number of cycles in which the number of occurrences of the event is greater or equal to the threshold. this is an integer modifier with values in the range [0:255].
  • t β€” measure on both threads at the same time, assuming hyper-threading is enabled. boolean modifier, obviously.
  • ldlat β€” pass a latency threshold to the MEM_TRANS_RETIRED:LATENCY_ABOVE_THRESHOLD event. this is an integer attribute that must be in the range [1:65535], and it is required for this event. πŸ‘€ note that the event must be used with precise sampling (PEBS).

πŸ”₯ OFFCORE_RESPONSE events πŸ”₯

Intel Ivy Bridge provides two offcore_response events, and their names are:

  • OFFCORE_RESPONSE_0
  • OFFCORE_RESPONSE_1

these events need special treatment in the performance monitoring infrastructure because each event uses an extra register to store some settings. so if multiple offcore_response events are being monitored simultaneously, the kernel needs to manage the sharing of that extra register. teamwork, but make it kernel 😌

the offcore_response events are exposed as normal events by the library. the extra settings are exposed as regular umasks, and the library takes care of encoding the events according to the underlying kernel interface. we love a library that handles the admin πŸ’–

on Intel Ivy Bridge, the umasks are divided into three categories:

  1. request
  2. supplier
  3. snoop

the user must provide at least one umask for each category. the categories are shown in the umask descriptions. πŸ‘‘

there's also a special response umask called ANY_RESPONSE. when this umask is used, it overrides any supplier and snoop umasks. in other words, users can specify either ANY_RESPONSE or any combinations of supplier + snoops. pick a lane, bestie 🌈

in case no supplier or snoop is specified, the library defaults to using ANY_RESPONSE.

for instance, the following are valid event selections:

OFFCORE_RESPONSE_0:DMND_DATA_RD:ANY_RESPONSE

OFFCORE_RESPONSE_0:ANY_REQUEST

OFFCORE_RESPONSE_0:ANY_RFO:LLC_HITM:SNOOP_ANY

but the following are illegal:

OFFCORE_RESPONSE_0:ANY_RFO:LLC_HITM:ANY_RESPONSE

OFFCORE_RESPONSE_0:ANY_RFO:LLC_HITM:SNOOP_ANY:ANY_RESPONSE
yeah those last two? not the move. do not pass go, do not collect your counters πŸ’€

🫢 AUTHORS 🫢

Stephane Eranian <eranian@gmail.com>


and that's the whole page, bestie!! this one shipped back in August, 2012 under the LIBPFM(3) name β€” shoutout to the Linux Programmer's Manual for housing it πŸ’– stay perf-y, mwah πŸŽ€βœ¨

πŸ“¦ where this page comes from