PERFMON(4)
π PERFMON(4) π
okay so real talk, this is from the i386 Kernel Interfaces Manual and it's giving very specific vintage CPU energy, but bestie, the details are all here, periodt.
β¨ NAME β¨
perfmon β the CPU performance-monitoring interface π
β¨ SYNOPSIS β¨
cpu I586_CPU
cpu I686_CPU
options PERFMON
β¨ DESCRIPTION β¨
The perfmon driver is literally your VIP pass to the internal performance-monitoring capabilities of the Intel Pentium and Pentium Pro CPUs. πΈ
These processors have two internal counters that you can configure to measure a whole bunch of events β either as a count or as a duration (in CPU cycles) β plus a cycle counter that counts clock cycles. The perfmon driver gives you a device-style interface to all of that. Slay. β¨
All access to the performance-monitoring counters happens through the special device file /dev/perfmon. This device supports a bunch of ioctl(2) requests, all defined in <machine/perfmon.h> β and that same header also holds the definitions of the various counters for both Pentium and Pentium Pro processors. iykyk.
NOTA BENE: π¨ the set of available events is not the same from processor to processor. It is the responsibility of the programmer to make sure the event numbers they're using are the correct ones for the CPU type being measured. No cap, check your CPU first.
The following ioctl(2) requests are defined:
PMIOSETUP(struct pmc)β set up a counter with the parameters and flags defined in the structure. The following fields are defined instruct pmc:int pmc_numβ the number of the counter in question; must be less thanNPMC(currently2).u_char pmc_eventβ the particular event number to be monitored, as defined in<machine/perfmon.h>.u_char pmc_unitβ the unit mask value, specific to the event type (see the Intel documentation).u_char pmc_flagsβ flags modifying the operation of the counter (see below).u_char pmc_maskβ the counter mask value; essentially this is a threshold used to restrict the count to events lasting more (or less) than the specified number of clocks.
The following pmc_flags values are defined:
PMCF_USRβ count events in user modePMCF_OSβ count events in kernel modePMCF_Eβ count the number of events rather than their durationPMCF_INVβ invert the sense of the counter mask comparison
PMIOGET(struct pmc)β returns the current configuration of the specified counter.PMIOSTART/PMIOSTOP(int)β starts (stops) the specified counter. π«Ά but lowkey due to hardware deficiencies, counters must be started and stopped in numerical order. (That is to say, counter0can never be stopped without first stopping counter1.) The driver will not enforce this restriction (since it may not be present in future CPUs). πPMIORESET(int)β reset the specified counter to zero. The counter should be stopped withPMIOSTOPbefore it is reset. All counters are automatically reset byPMIOSETUP.PMIOREAD(struct pmc_data)β get the current value of the counter. Thepmc_datastructure defines two fields:int pmcd_numβ the number of the counter to readquad_t pmcd_valueβ the resulting value as a 64-bit signed integer
In the future, it may be possible to use the RDPMC instruction on Pentium Pro processors to read the counters directly. β¨ manifesting β¨
PMIOTSTAMP(struct pmc_tstamp)β read the time stamp counter. Thepmc_tstampstructure defines two fields:int pmct_rateβ the approximate rate of the counter, in MHzquad_t pmct_valueβ the current value of the counter as a 64-bit integer
It is important to note that the counter rate, as provided in the pmct_rate field, is often incorrect because of calibration difficulties and non-integral clock rates. This field should be considered more of a hint or sanity-check than an actual representation of the rate of clock ticks. π fr fr don't trust it.
β¨ FILES β¨
/dev/perfmonβ character device interface to counters/usr/include/machine/perfmon.hβ include file with definitions of structures and event types/usr/share/examples/perfmonβ sample source code demonstrating use of all theioctl()commands
β¨ SEE ALSO β¨
Intel Corporation, Pentium Pro Family Developer's Manual, vol. 3, January 1996, Operating System Writer's Manual. π
β¨ HISTORY β¨
The perfmon device first appeared in FreeBSD 2.2. π¦
β¨ AUTHORS β¨
The perfmon driver was written by Garrett A. Wollman, MIT Laboratory for Computer Science. π
π okay that's the whole page bestie! this one's from Debian, dated March 26, 1996, and the page is PERFMON(4) β go forth and monitor those CPU events, you icon. π
β¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright 1996 Massachusetts Institute of Technology
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms