Add <sys/pmc_sample.h>: an in-kernel KPI for consumers that want raw
PMU sampling callchains without going through pmclog/pmcstat(8). A
consumer registers a callback and requests a per-CPU sampling PMC at a
target frequency; callbacks run from the existing hwpmc sample-delivery
path (NMI context: no sleeping, no malloc(9), no sleepable locks). One
session at a time; no in-tree consumer yet.
Supports Intel (IAF CPU_CLK_UNHALTED.REF, frequency-invariant by
design) and AMD/Hygon (K8 BU_CPU_CLK_UNHALTED). AMD's counter tracks
real core clocks rather than a fixed reference rate, so its reload is
rescaled each interrupt by the live APERF/MPERF ratio to keep the
sampling period accurate across P-state transitions; the same
APERF/MPERF data is also surfaced as an optional effective-frequency
(MHz) field per sample. Both the rescale and the frequency report are
confined to this KPI's own sampler PMCs, so pmcstat(8) sessions are
unaffected.
Also fixes a PMC row leak: the standalone-row disposition counter
wasn't unmarked when pcd_write_pmc()/pcd_start_pmc() failed and left
the row in PMC_STATE_STOPPED rather than PMC_STATE_ALLOCATED.
Sponsored by: Netflix