LIBPFM(3)

๐Ÿ’– LIBPFM ๐Ÿ’–

okay bestie, welcome to the Linux Programmer's Manual, page LIBPFM(3). this one's about the Intel Sandy Bridge-EP U-Box uncore PMU and she is niche but she is serving. let's get into it ๐ŸŽ€


โœจ NAME โœจ

libpfm_intel_snbep_unc_ubo โ€” the whole entire support package for the Intel Sandy Bridge-EP U-Box uncore PMU. yes that's a mouthful. no we're not shortening it. ๐Ÿ’…


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

#include <perfmon/pfmlib.h>

and also, like, the important little identity card:

PMU name: snbep_unc_ubo
PMU desc: Intel Sandy Bridge-EP U-Box uncore PMU

๐ŸŒธ DESCRIPTION ๐ŸŒธ

so the library does support the Intel Sandy Bridge system configuration unit (U-Box) uncore PMU. ๐Ÿซถ

heads up though โ€” this PMU model only exists on Sandy Bridge model 45. like, that's it, that's the whole guest list. and there is only one U-Box PMU per processor socket. one. singular. iconic main character behavior honestly ๐Ÿ‘‘


๐Ÿ’… MODIFIERS ๐Ÿ’…

here's the modifier lineup for the Intel Sandy Bridge U-Box uncore PMU. these are the little seasoning packets you sprinkle on your events, and every single one of them matters:

  • i โ€” invert the meaning of the event. so instead of counting the thing, the counter now counts HA cycles in which the event is not occurring. it's a boolean modifier. plot twist energy ๐Ÿ’€
  • e โ€” enable edge detection, meaning count only when there is a state transition from no occurrence of the event to at least one occurrence. โš ๏ธ this modifier must be combined with a threshold modifier (t) with a value greater or equal to one. it's a boolean modifier. no solo runs allowed bestie, it's a duet ๐ŸŽ€
  • t โ€” set the threshold value. when you set it to a non-zero value, the counter counts the number of HA cycles in which the number of occurrences of the event is greater or equal to the threshold. it's an integer modifier with values in the range [0:15]. small range, big power โœจ
  • oi โ€” invert the meaning of the occupancy event POWER_STATE_OCCUPANCY. the counter will now count PCU cycles in which the event is not occurring. it's a boolean modifier. same flip energy, different event ๐Ÿฆ‹
  • oe โ€” enable edge detection for the occupancy event POWER_STATE_OCCUPANCY. the event now counts only when there is a state transition from no occurrence of the event to at least one occurrence. โš ๏ธ this one must be combined with a threshold modifier (t) with a value greater or equal to one. it's a boolean modifier.
  • ff โ€” enable frequency band filtering. ๐ŸŽš๏ธ this modifier applies only to the UNC_P_FREQ_BANDx_CYCLES events, where x is [0-3]. the modifier expects an integer in the range [0-255]. that value gets interpreted as a frequency value to be multiplied by 100Mhz. so like, if the value is 32, then all cycles where the processor is running at 3.2GHz and more are counted. math girlies rise ๐Ÿงฎ๐Ÿ’–

๐ŸŒˆ Frequency band filtering ๐ŸŒˆ

okay so there are 3 events that support frequency band filtering... and then the list names four of them, which, yes, we're just reading the manual as written, don't come for me ๐Ÿ™ˆ:

  • UNC_P_FREQ_BAND0_CYCLES
  • UNC_P_FREQ_BAND1_CYCLES
  • UNC_P_FREQ_BAND2_CYCLES
  • UNC_P_FREQ_BAND3_CYCLES

the frequency filter (available via the ff modifier) is stored into a PMU shared register which holds all 4 possible frequency bands, one per event. ๐Ÿ”ฅ

but here's the tea โ˜•: the library generates the encoding for each event individually, because it processes events one at a time. so the caller or the underlying kernel interface may have to merge the band filter settings to program the filter register properly. like, you're gonna have to do some assembly required, bestie ๐Ÿงฉ

ngl this is the part where you double-check your register plumbing. the library does its one-at-a-time thing, you do the merging. teamwork ๐Ÿ’ช

๐Ÿ‘‘ AUTHORS ๐Ÿ‘‘

  • Stephane Eranian <eranian@gmail.com>

and that's the whole page, fr fr โœจ written down in August, 2012, and it's the LIBPFM(3) page from the Linux Programmer's Manual โ€” so like, shoutout to the era that gave us this one. mwah ๐Ÿ’‹ slay, go count some cycles ๐Ÿฆ‹๐Ÿ’–

๐Ÿ“ฆ where this page comes from