Page MenuHomeFreeBSD

hwpmc: fix event allocation on pre-Zen AMD CPUs
ClosedPublic

Authored by olivier on Sun, Jul 26, 12:33 PM.
Tags
None
Referenced Files
F164375874: D58468.diff
Fri, Jul 31, 7:10 AM
F164360875: D58468.id182970.diff
Fri, Jul 31, 4:24 AM
Unknown Object (File)
Thu, Jul 30, 6:10 AM
Unknown Object (File)
Wed, Jul 29, 8:22 AM
Subscribers
None

Details

Summary

amd_allocate_pmc() chose the pmu-events code path whenever pmc_cpuid was non-empty, and rejected any allocation lacking PMC_F_EV_PMU.
But pmc_cpuid is set for every AMD CPU, while the pmu-events tables only cover Zen and later (mapfile.csv: families 23/25/26).
On older families (K8, Bobcat, Jaguar/16h, Bulldozer) libpmc finds no pmu-events entry and falls back to the legacy path, which never sets PMC_F_EV_PMU.
The kernel then took the pmu-events path anyway and returned EINVAL for every row:

pmcstat: ERROR: Cannot allocate system-mode pmc with specification
"BU_CPU_CLK_UNHALTED": Invalid argument

Use PMC_F_EV_PMU as the discriminator, as c190fb35f35c intended: take the pmu-events path only when the flag is set, else fall through to the legacy handling.
Drop the early rejection that made the legacy path unreachable.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

olivier created this revision.
mhorne added reviewers: pmc, adrian.

Thanks. I was considering removing all this code, but it was premature. I am happy to keep it if it is useful.

Presumably, you can advocate that it actually functions correctly?

Also, please ensure the fix is merged to all stable branches.

This revision is now accepted and ready to land.Mon, Jul 27, 2:40 PM