PMC.AMD(3)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’… PMC.AMD(3) β€” measurement events for AMD Athlon 64 (K8 family) CPUs

Library Functions Manual Β· yes bestie, we’re in the manual-page era

🫢 NAME 🫢

pmc.amd, pmc.k8 β€” measurement events for AMD Athlon 64 (K8 family) CPUs.

πŸ“š LIBRARY πŸ“š

Performance Counters Library (libpmc, -lpmc)

✨ SYNOPSIS ✨

#include <pmc.h>

πŸ’– DESCRIPTION πŸ’–

Okay so, AMD K8 PMCs are literally present in the AMD Athlon64 and AMD Opteron series of CPUs. They are documented in the BIOS and Kernel Developer's Guide for the AMD Athlon(tm) 64 and AMD Opteron Processors, Publication No. 26094, Advanced Micro Devices, Inc., April 2004.

🌸 PMC Features 🌸

AMD K8 PMCs are 48 bits wide. Each CPU contains 4 PMCs with these capabilities:

  • PMC_CAP_CASCADE β€” No
  • PMC_CAP_EDGE β€” Yes
  • PMC_CAP_INTERRUPT β€” Yes
  • PMC_CAP_INVERT β€” Yes
  • PMC_CAP_READ β€” Yes
  • PMC_CAP_PRECISE β€” No
  • PMC_CAP_SYSTEM β€” Yes
  • PMC_CAP_TAGGING β€” No
  • PMC_CAP_THRESHOLD β€” Yes
  • PMC_CAP_USER β€” Yes
  • PMC_CAP_WRITE β€” Yes

πŸ’… Event Qualifiers πŸ’…

Event specifiers for AMD K8 PMCs can have these optional qualifiers:

  • count=value β€” Configure the counter to increment only if the number of configured events measured in a cycle is greater than or equal to value.
  • edge β€” Configure the counter to only count negated-to-asserted transitions of the conditions expressed by the other fields. In other words, the counter will increment only once whenever a given condition becomes true, irrespective of the number of clocks during which the condition remains true.
  • inv β€” Invert the sense of comparison when the count qualifier is present, making the counter increment when the number of events per cycle is less than the value specified by the count qualifier.
  • mask=qualifier β€” Many event specifiers for AMD K8 PMCs need to be additionally qualified using a mask qualifier. These additional qualifiers are event-specific and are documented along with their associated event specifiers below.
  • os β€” Configure the PMC to count events happening at privilege level 0.
  • usr β€” Configure the PMC to count events occurring at privilege levels 1, 2 or 3.
If neither the os nor usr qualifier is specified, the default is to enable both. Periodt.

🌈 AMD K8 Event Specifiers 🌈

The event specifiers supported on AMD K8 PMCs are:

  • k8-bu-cpu-clk-unhalted β€” (Event 76H) Count the number of clock cycles when the CPU is not in the HLT or STPCLK states.
  • k8-bu-fill-request-l2 [,mask=qualifier] β€” (Event 7EH) Count fill requests that missed in the L2 cache. This event may be further qualified using qualifier, which is a '+' separated set of the following keywords:
    • dc-fill β€” Count data cache fill requests.
    • ic-fill β€” Count instruction cache fill requests.
    • tlb-reload β€” Count TLB reloads.

The default is to count all types of requests.

  • k8-bu-fill-into-l2 [,mask=qualifier] β€” (Event 7FH) The number of lines written to and from the L2 cache. The event may be further qualified by using qualifier, which is a '+' separated set of the following keywords:
    • dirty-l2-victim β€” Count lines written into L2 cache due to victim writebacks from the Icache or Dcache, TLB page table walks or hardware data prefetches.
    • victim-from-l2 β€” Count writebacks of dirty lines from L2 to the system.
  • k8-bu-internal-l2-request [,mask=qualifier] β€” (Event 7DH) Count internally generated requests to the L2 cache. This event may be further qualified using qualifier, which is a '+' separated set of the following keywords:
    • cancelled β€” Count cancelled requests.
    • dc-fill β€” Count data cache fill requests.
    • ic-fill β€” Count instruction cache fill requests.
    • tag-snoop β€” Count tag snoop requests.
    • tlb-reload β€” Count TLB reloads.

The default is to count all types of requests.

  • k8-dc-access β€” (Event 40H) Count data cache accesses including microcode scratch pad accesses.
  • k8-dc-copyback [,mask=qualifier] β€” (Event 44H) Count data cache copyback operations. This event may be further qualified using qualifier, which is a '+' separated set of the following keywords:
    • exclusive β€” Count operations for lines in the β€œexclusive” state.
    • invalid β€” Count operations for lines in the β€œinvalid” state.
    • modified β€” Count operations for lines in the β€œmodified” state.
    • owner β€” Count operations for lines in the β€œowner” state.
    • shared β€” Count operations for lines in the β€œshared” state.

The default is to count operations for lines in all the above states.

  • k8-dc-dcache-accesses-by-locks [,mask=qualifier] β€” (Event 4CH) Count data cache accesses by lock instructions. This event is only available on processors of revision C or later vintage. This event may be further qualified using qualifier, which is a '+' separated set of the following keywords:
    • accesses β€” Count data cache accesses by lock instructions.
    • misses β€” Count data cache misses by lock instructions.

The default is to count all accesses.

  • k8-dc-dispatched-prefetch-instructions [,mask=qualifier] β€” (Event 4BH) Count the number of dispatched prefetch instructions. This event may be further qualified using qualifier, which is a '+' separated set of the following keywords:
    • load β€” Count load operations.
    • nta β€” Count non-temporal operations.
    • store β€” Count store operations.

The default is to count all operations.

  • k8-dc-l1-dtlb-miss-and-l2-dtlb-hit β€” (Event 45H) Count L1 DTLB misses that are L2 DTLB hits.
  • k8-dc-l1-dtlb-miss-and-l2-dtlb-miss β€” (Event 46H) Count L1 DTLB misses that are also misses in the L2 DTLB.
  • k8-dc-microarchitectural-early-cancel-of-an-access β€” (Event 49H) Count microarchitectural early cancels of data cache accesses.
  • k8-dc-microarchitectural-late-cancel-of-an-access β€” (Event 48H) Count microarchitectural late cancels of data cache accesses.
  • k8-dc-misaligned-data-reference β€” (Event 47H) Count misaligned data references.
  • k8-dc-miss β€” (Event 41H) Count data cache misses.
  • k8-dc-one-bit-ecc-error [,mask=qualifier] β€” (Event 4AH) Count one bit ECC errors found by the scrubber. This event may be further qualified using qualifier, which is a '+' separated set of the following keywords:
    • scrubber β€” Count scrubber detected errors.
    • piggyback β€” Count piggyback scrubber errors.

The default is to count both kinds of errors.

  • k8-dc-refill-from-l2 [,mask=qualifier] β€” (Event 42H) Count data cache refills from L2 cache. This event may be further qualified using qualifier, which is a '+' separated set of the following keywords:
    • exclusive β€” Count operations for lines in the β€œexclusive” state.
    • invalid β€” Count operations for lines in the β€œinvalid” state.
    • modified β€” Count operations for lines in the β€œmodified” state.
    • owner β€” Count operations for lines in the β€œowner” state.
    • shared β€” Count operations for lines in the β€œshared” state.

The default is to count operations for lines in all the above states.

  • k8-dc-refill-from-system [,mask=qualifier] β€” (Event 43H) Count data cache refills from system memory. This event may be further qualified using qualifier, which is a '+' separated set of the following keywords:
    • exclusive β€” Count operations for lines in the β€œexclusive” state.
    • invalid β€” Count operations for lines in the β€œinvalid” state.
    • modified β€” Count operations for lines in the β€œmodified” state.
    • owner β€” Count operations for lines in the β€œowner” state.
    • shared β€” Count operations for lines in the β€œshared” state.

The default is to count operations for lines in all the above states.

  • k8-fp-cycles-with-no-fpu-ops-retired β€” (Event 01H) Count cycles when no FPU ops were retired. This event is supported in revision B and later CPUs.
  • k8-fp-dispatched-fpu-fast-flag-ops β€” (Event 02H) Count dispatched FPU ops that use the fast flag interface. This event is supported in revision B and later CPUs.
  • k8-fp-dispatched-fpu-ops [,mask=qualifier] β€” (Event 00H) Count the number of dispatched FPU ops. This event is supported in revision B and later CPUs. This event may be further qualified using qualifier, which is a '+' separated set of the following keywords:
    • add-pipe-excluding-junk-ops β€” Count add pipe ops excluding junk ops.
    • add-pipe-junk-ops β€” Count junk ops in the add pipe.
    • multiply-pipe-excluding-junk-ops β€” Count multiply pipe ops excluding junk ops.
    • multiply-pipe-junk-ops β€” Count junk ops in the multiply pipe.
    • store-pipe-excluding-junk-ops β€” Count store pipe ops excluding junk ops
    • store-pipe-junk-ops β€” Count junk ops in the store pipe.

The default is to count all types of ops.

  • k8-fr-decoder-empty β€” (Event D0H) Count cycles when there was nothing to dispatch (i.e., the decoder was empty).
  • k8-fr-dispatch-stall-for-segment-load β€” (Event D4H) Count dispatch stalls for segment loads.
  • k8-fr-dispatch-stall-for-serialization β€” (Event D3H) Count dispatch stalls for serialization.
  • k8-fr-dispatch-stall-from-branch-abort-to-retire β€” (Event D2H) Count dispatch stalls from branch abort to retiral.
  • k8-fr-dispatch-stall-when-fpu-is-full β€” (Event D7H) Count dispatch stalls when the FPU is full.
  • k8-fr-dispatch-stall-when-ls-is-full β€” (Event D8H) Count dispatch stalls when the load/store unit is full.
  • k8-fr-dispatch-stall-when-reorder-buffer-is-full β€” (Event D5H) Counts dispatch stalls when the reorder buffer is full.
  • k8-fr-dispatch-stall-when-reservation-stations-are-full β€” (Event D6H) Counts dispatch stalls when the reservation stations are full.
  • k8-fr-dispatch-stall-when-waiting-far-xfer-or-resync-branch-pending β€” (Event DAH) Counts dispatch stalls when a far control transfer or a resync branch is pending.
  • k8-fr-dispatch-stall-when-waiting-for-all-to-be-quiet β€” (Event D9H) Counts dispatch stalls when waiting for everything to be quiet. πŸ¦‹
  • k8-fr-dispatch-stalls β€” (Event D1H) Counts all the dispatch stalls. The catch-all, the main character of stalls.
  • k8-fr-fpu-exceptions [,mask=qualifier] β€” (Event DBH) Counts FPU exceptions. πŸ‘‘ This event is supported in revision B and later CPUs. You can qualify it further with qualifier, which is a +-separated set of these keywords:
    • sse-and-x87-microtraps β€” Counts SSE and x87 microtraps.
    • sse-reclass-microfaults β€” Counts SSE reclass microfaults.
    • sse-retype-microfaults β€” Counts SSE retype microfaults.
    • x87-reclass-microfaults β€” Counts x87 reclass microfaults.

Default behavior? Count all types of exceptions. All of them. πŸ’…

  • k8-fr-interrupts-masked-cycles β€” (Event CDH) Counts cycles when interrupts were masked (that's when the CPU RFLAGS field IF was zero, iykyk).
  • k8-fr-interrupts-masked-while-pending-cycles β€” (Event CEH) Counts cycles while interrupts were masked and pending β€” literally the cycles when INTR was asserted while the CPU RFLAGS field IF was zero. 😭
  • k8-fr-number-of-breakpoints-for-dr0 β€” (Event DCH) Counts the number of breakpoints for DR0.
  • k8-fr-number-of-breakpoints-for-dr1 β€” (Event DDH) Counts the number of breakpoints for DR1.
  • k8-fr-number-of-breakpoints-for-dr2 β€” (Event DEH) Counts the number of breakpoints for DR2.
  • k8-fr-number-of-breakpoints-for-dr3 β€” (Event DFH) Counts the number of breakpoints for DR3. The whole squad, accounted for. 🫢
  • k8-fr-retired-branches β€” (Event C2H) Counts retired branches, exceptions and interrupts included.
  • k8-fr-retired-branches-mispredicted β€” (Event C3H) Counts mispredicted retired branches. Oops. πŸ™ˆ
  • k8-fr-retired-far-control-transfers β€” (Event C6H) Counts retired far control transfers, which are always mispredicted β€” no guessing required, they just are.
  • k8-fr-retired-fastpath-double-op-instructions [,mask=qualifier] β€” (Event CCH) Counts retired fastpath double op instructions. Supported in revision B and later CPUs. Qualify it with qualifier, a +-separated set of these keywords:
    • low-op-pos-0 β€” Counts instructions with the low op in position 0.
    • low-op-pos-1 β€” Counts instructions with the low op in position 1.
    • low-op-pos-2 β€” Counts instructions with the low op in position 2.

Default is to count all types of instructions. ✨

  • k8-fr-retired-fpu-instructions [,mask=qualifier] β€” (Event CBH) Counts retired FPU instructions. Supported in revision B and later CPUs. qualifier is a +-separated set of:
    • mmx-3dnow β€” Counts MMX and 3DNow! instructions.
    • packed-sse-sse2 β€” Counts packed SSE and SSE2 instructions.
    • scalar-sse-sse2 β€” Counts scalar SSE and SSE2 instructions.
    • x87 β€” Counts x87 instructions.

Default: all types of instructions. The whole buffet. πŸ“

  • k8-fr-retired-near-returns β€” (Event C8H) Counts retired near returns.
  • k8-fr-retired-near-returns-mispredicted β€” (Event C9H) Counts mispredicted near returns.
  • k8-fr-retired-resyncs β€” (Event C7H) Counts retired resyncs (those are non-control transfer branches, fyi).
  • k8-fr-retired-taken-branches β€” (Event C4H) Counts retired taken branches.
  • k8-fr-retired-taken-branches-mispredicted β€” (Event C5H) Counts retired taken branches that were mispredicted.
  • k8-fr-retired-taken-branches-mispredicted-by-addr-miscompare β€” (Event CAH) Counts retired taken branches that were mispredicted only due to an address miscompare. Precise queen behavior. πŸ’…
  • k8-fr-retired-taken-hardware-interrupts β€” (Event CFH) Counts retired taken hardware interrupts.
  • k8-fr-retired-uops β€” (Event C1H) Counts retired uops.
  • k8-fr-retired-x86-instructions β€” (Event C0H) Counts retired x86 instructions, exceptions and interrupts included.
  • k8-ic-fetch β€” (Event 80H) Counts instruction cache fetches.
  • k8-ic-instruction-fetch-stall β€” (Event 87H) Counts cycles in stalls due to instruction fetch.
  • k8-ic-l1-itlb-miss-and-l2-itlb-hit β€” (Event 84H) Counts L1 ITLB misses that are L2 ITLB hits.
  • k8-ic-l1-itlb-miss-and-l2-itlb-miss β€” (Event 85H) Counts ITLB misses that miss in both L1 and L2 ITLBs. Down bad in both levels. 😭
  • k8-ic-microarchitectural-resync-by-snoop β€” (Event 86H) Counts microarchitectural resyncs caused by snoops.
  • k8-ic-miss β€” (Event 81H) Counts instruction cache misses.
  • k8-ic-refill-from-l2 β€” (Event 82H) Counts instruction cache refills from L2 cache.
  • k8-ic-refill-from-system β€” (Event 83H) Counts instruction cache refills from system memory.
  • k8-ic-return-stack-hits β€” (Event 88H) Counts hits to the return stack.
  • k8-ic-return-stack-overflow β€” (Event 89H) Counts overflows of the return stack. It's giving full. πŸ’€
  • k8-ls-buffer2-full β€” (Event 23H) Counts load/store buffer2 full events.
  • k8-ls-locked-operation [,mask=qualifier] β€” (Event 24H) Counts locked operations. For revision C and later CPUs, these qualifiers are supported:
    • cycles-in-request β€” Counts the number of cycles in the lock request/grant stage.
    • cycles-to-complete β€” Counts the number of cycles a lock takes to complete once it is non-speculative and is the older load/store operation.
    • locked-instructions β€” Counts the number of lock instructions executed.

Default is to count the number of lock instructions executed. Solid choice ngl.

  • k8-ls-microarchitectural-late-cancel β€” (Event 25H) Counts microarchitectural late cancels of operations in the load/store unit.
  • k8-ls-microarchitectural-resync-by-self-modifying-code β€” (Event 21H) Counts microarchitectural resyncs caused by self-modifying code. Chaos code. πŸ”₯
  • k8-ls-microarchitectural-resync-by-snoop β€” (Event 22H) Counts microarchitectural resyncs caused by snoops.
  • k8-ls-retired-cflush-instructions β€” (Event 26H) Counts retired CFLUSH instructions.
  • k8-ls-retired-cpuid-instructions β€” (Event 27H) Counts retired CPUID instructions.
  • k8-ls-segment-register-load [,mask=qualifier] β€” (Event 20H) Counts segment register loads. Qualify it with qualifier, a +-separated set of:
    • cs β€” Counts CS register loads.
    • ds β€” Counts DS register loads.
    • es β€” Counts ES register loads.
    • fs β€” Counts FS register loads.
    • gs β€” Counts GS register loads.
    • ss β€” Counts SS register loads.

Default: counts all types of loads. ✨

  • k8-nb-ht-bus0-bandwidth [,mask=qualifier]
  • k8-nb-ht-bus1-bandwidth [,mask=qualifier]
  • k8-nb-ht-bus2-bandwidth [,mask=qualifier] β€” (Events F6H, F7H and F8H respectively) Counts events on the HyperTransport(tm) buses. Qualify these with qualifier, a +-separated set of:
    • buffer-release β€” Counts buffer release messages sent.
    • command β€” Counts command messages sent.
    • data β€” Counts data messages sent.
    • nop β€” Counts nop messages sent.

Default: counts all types of messages. πŸŽ€

  • k8-nb-memory-controller-bypass-saturation [,mask=qualifier] β€” (Event E4H) Counts memory controller bypass counter saturation events. qualifier is a +-separated set of:
    • dram-controller-interface-bypass β€” Counts DRAM controller interface bypass.
    • dram-controller-queue-bypass β€” Counts DRAM controller queue bypass.
    • memory-controller-hi-pri-bypass β€” Counts memory controller high priority bypasses.
    • memory-controller-lo-pri-bypass β€” Counts memory controller low priority bypasses.
  • k8-nb-memory-controller-dram-slots-missed β€” (Event E2H) Counts memory controller DRAM command slots missed (in MemClks).
  • k8-nb-memory-controller-page-access-event [,mask=qualifier] β€” (Event E0H) Counts memory controller page access events. qualifier is a +-separated set of:
    • page-conflict β€” Counts page conflicts.
    • page-hit β€” Counts page hits.
    • page-miss β€” Counts page misses.

Default: counts all types of events. πŸ’œ

  • k8-nb-memory-controller-page-table-overflow β€” (Event E1H) Counts memory control page table overflow events.
  • k8-nb-memory-controller-turnaround [,mask=qualifier] β€” (Event E3H) Counts memory control turnaround events. qualifier is a +-separated set of:
    • dimm-turnaround β€” Counts DIMM turnarounds.
    • read-to-write-turnaround β€” Counts read to write turnarounds.
    • write-to-read-turnaround β€” Counts write to read turnarounds.

Default: counts all types of events. She rotates. πŸ”„

  • k8-nb-probe-result [,mask=qualifier] β€” (Event ECH) Counts probe events. qualifier is a +-separated set of:
    • probe-hit β€” Counts all probe hits.
    • probe-hit-dirty-no-memory-cancel β€” Counts probe hits without memory cancels.
    • probe-hit-dirty-with-memory-cancel β€” Counts probe hits with memory cancels.
    • probe-miss β€” Counts probe misses.
  • k8-nb-sized-commands [,mask=qualifier] β€” (Event EBH) counts the sized commands being issued. πŸ’… You can get extra picky with this one by passing a qualifier, which is literally just a set of the keywords below glued together with +:
    • nonpostwrszbyte
    • nonpostwrszdword
    • postwrszbyte
    • postwrszdword
    • rdszbyte
    • rdszdword
    • rdmodwr

If you don't specify anything? The default is to count all the types of commands. Main character energy: everything gets counted, no cap. ✨


πŸ¦‹ Event Name Aliases πŸ¦‹

okay so this next bit is lowkey iconic 😭 β€” here's the mapping between the PMC-independent aliases that Performance Counters Library (libpmc, -lpmc) supports and the actual underlying hardware events they point at. It's giving translator bestie fr fr:

  • branches β†’ k8-fr-retired-taken-branches
  • branch-mispredicts β†’ k8-fr-retired-taken-branches-mispredicted
  • dc-misses β†’ k8-dc-miss
  • ic-misses β†’ k8-ic-miss
  • instructions β†’ k8-fr-retired-x86-instructions
  • interrupts β†’ k8-fr-taken-hardware-interrupts
  • unhalted-cycles β†’ k8-bu-cpu-clk-unhalted

Like, you can use the cute short alias OR the full hardware name β€” either way you're slaying. 🫢


🌈 SEE ALSO 🌈

go read these next, bestie, they're all part of the squad πŸ‘‘:


πŸŽ€ HISTORY πŸŽ€

The pmc library first appeared in FreeBSD 6.0. a whole era. an icon. ⭐


πŸ’– AUTHORS πŸ’–

The Performance Counters Library (libpmc, -lpmc) library was written by Joseph Koshy <jkoshy@FreeBSD.org>. shoutout to the legend, we stan πŸ«‘πŸ’œ


and that's a wrap on the whole page, bestie πŸŽ‰ this was the Debian build, dated June 24, 2023, and it's the PMC.AMD(3) manual β€” go forth and profile with main character energy, mwah πŸ’…πŸ’–

πŸ“¦ where this page comes from
  • freebsd 15.1: base 15.1
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms